[petsc-users] MatSOR and GaussSeidel

Jed Brown jed at jedbrown.org
Tue Aug 23 09:54:20 CDT 2016


Cyrill Vonplanta <cyrill.von.planta at usi.ch> writes:

> Dear PETSc-Users,
>
> I am debugging a smoother of ours and i was wondering what settings of MatSOR exactly form one ordinary Gauss Seidel smoothing step. Currently I use:
>
> ierr = MatSOR(A,b,1.0,(MatSORType)(SOR_ZERO_INITIAL_GUESS | SOR_FORWARD_SWEEP),0,1,1,x); CHKERRV(ierr);

Yes, this is a standard forward sweep of GS.  Note that your code below
computes half zeros (because the vector starts as 0), but that it
handles the diagonal incorrectly if you were to use a nonzero initial
guess.

> I expect this to be the same as this naïve Gauss-Seidel step:
>
>
> for (int i=0;i<m;i++){
>
>       sum_i = 0;
>
>       sum_i += ps_b_values[i];
>
>       for (int j=0;j<m;j++){
>
>         sum_i -= ps_A_values[i+j*m]*ps_x_values[j];
>
>       }
>
>       ps_x_values[i] += sum_i/ps_A_values[i*m +i];
>
> }
>
> The ps_* refer to the data parts of PETSc types (everything is serial and dense in my toy example. Initial x is zero.m is dimension of A). However the convergence history looks different. Am I missing something here?
>
> Best Cyrill
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160823/c0f4652b/attachment.pgp>


More information about the petsc-users mailing list