# Double solve on the coarse level?

Barry Smith bsmith at mcs.anl.gov
Mon Dec 8 15:51:05 CST 2008

```On Dec 8, 2008, at 12:59 PM, ntardieu at giref.ulaval.ca wrote:

> Dear PETSc users,
>
> We designed a multigrid solver based on the PCMG framework.
> But when one looks at the output, it seems that the system on the
> coarsest
> level is solved twice : indeed the same residuals appear twice. Is
> it a
> consequence of using a W cycle with an iteratif solver on the coarsest
> level?

No. It happens also with a direct coarse grid solver. This is an
error
that happens with the W cycle. In PCMGMCycle_Private() is the line
while (cycles--) {
ierr = PCMGMCycle_Private(pc,mglevels-1,reason);CHKERRQ(ierr);
}
when cycles is 2 (which is w cycle). I have put a correction into
petsc-dev
to define cycles to be 1 on the 1st level even for w cycle.
PetscInt       cycles = (mg->level == 1) ? 1 : (PetscInt) mg->cycles;

Thanks for reporting the problem,

Barry

>
> The PC object and a typical output are given below.
>
> Thanks,
>
> Nicolas
>
> =
> ======================================================================
> PC Object:
>  type: mg
>    MG: type is MULTIPLICATIVE, levels=2 cycles=w, pre-smooths=1,
> post-smooths=1
>  Coarse gride solver -- level 0 -------------------------------
>    KSP Object:(mg_coarse_)
>      type: cr
>      maximum iterations=30, initial guess is zero
>      tolerances:  relative=1e-06, absolute=1e-50, divergence=10000
>      left preconditioning
>    PC Object:(mg_coarse_)
>      type: sor
>        SOR: type = local_symmetric, iterations = 1, omega = 1
>      linear system matrix = precond matrix:
>      Matrix Object:
>        type=seqaij, rows=24497, cols=24497
>        total: nonzeros=936401, allocated nonzeros=0
>          not using I-node routines
>  Down solver (pre-smoother) on level 1 -------------------------------
>    KSP Object:(mg_levels_1_)
>      type: chebychev
>        Chebychev: eigenvalue estimates:  min = 0.01, max = 100
>      maximum iterations=3, initial guess is zero
>      tolerances:  relative=1e-05, absolute=1e-50, divergence=10000
>      left preconditioning
>    PC Object:(mg_levels_1_)
>      type: sor
>        SOR: type = local_symmetric, iterations = 1, omega = 1
>      linear system matrix = precond matrix:
>      Matrix Object:
>        type=seqaij, rows=59833, cols=59833
>        total: nonzeros=670149, allocated nonzeros=670149
>          not using I-node routines
>  Up solver (post-smoother) on level 1 -------------------------------
>    KSP Object:(mg_levels_1_)
>      type: chebychev
>        Chebychev: eigenvalue estimates:  min = 0.01, max = 100
>      maximum iterations=3
>      tolerances:  relative=1e-05, absolute=1e-50, divergence=10000
>      left preconditioning
>    PC Object:(mg_levels_1_)
>      type: sor
>        SOR: type = local_symmetric, iterations = 1, omega = 1
>      linear system matrix = precond matrix:
>      Matrix Object:
>        type=seqaij, rows=59833, cols=59833
>        total: nonzeros=670149, allocated nonzeros=670149
>          not using I-node routines
>  linear system matrix = precond matrix:
>  Matrix Object:
>    type=seqaij, rows=59833, cols=59833
>    total: nonzeros=670149, allocated nonzeros=670149
>      not using I-node routines
>
> =
> ======================================================================
> Typical output :
>
>    0 KSP Residual norm 8.529532792227e-01
>    1 KSP Residual norm 8.312168822014e-01
>    2 KSP Residual norm 7.962289819435e-01
>    3 KSP Residual norm 7.498665547818e-01
>      0 KSP Residual norm 8.623070846983e-01 <<<<<<<<<<
>      1 KSP Residual norm 4.994728639387e-01
>      2 KSP Residual norm 4.441045285060e-01
>      3 KSP Residual norm 4.036899174922e-01
>      4 KSP Residual norm 3.741251351308e-01
>      5 KSP Residual norm 3.449669992123e-01
>      6 KSP Residual norm 3.220670285389e-01
>      7 KSP Residual norm 2.974753633724e-01
>      8 KSP Residual norm 2.786493949211e-01
>      9 KSP Residual norm 2.666365822398e-01
>     10 KSP Residual norm 2.615313007214e-01
>     11 KSP Residual norm 2.580757152907e-01
>     12 KSP Residual norm 2.549505151556e-01
>     13 KSP Residual norm 2.509670840632e-01
>     14 KSP Residual norm 2.464315316006e-01
>     15 KSP Residual norm 2.416198261586e-01
>     16 KSP Residual norm 2.359854861997e-01
>     17 KSP Residual norm 2.298769116813e-01
>     18 KSP Residual norm 2.232203276735e-01
>     19 KSP Residual norm 2.153461917946e-01
>     20 KSP Residual norm 2.072492142809e-01
>     21 KSP Residual norm 1.983342705665e-01
>     22 KSP Residual norm 1.894778760982e-01
>     23 KSP Residual norm 1.803772952130e-01
>     24 KSP Residual norm 1.718394016178e-01
>     25 KSP Residual norm 1.639952865611e-01
>     26 KSP Residual norm 1.571843225056e-01
>     27 KSP Residual norm 1.512651261054e-01
>     28 KSP Residual norm 1.459688114323e-01
>     29 KSP Residual norm 1.410245577886e-01
>     30 KSP Residual norm 1.364936912778e-01
>      0 KSP Residual norm 8.623070846983e-01  <<<<<<<<<<
>      1 KSP Residual norm 4.994728639387e-01
>      2 KSP Residual norm 4.441045285060e-01
>      3 KSP Residual norm 4.036899174922e-01
>      4 KSP Residual norm 3.741251351308e-01
>      5 KSP Residual norm 3.449669992123e-01
>      6 KSP Residual norm 3.220670285389e-01
>      7 KSP Residual norm 2.974753633724e-01
>      8 KSP Residual norm 2.786493949211e-01
>      9 KSP Residual norm 2.666365822398e-01
>     10 KSP Residual norm 2.615313007214e-01
>     11 KSP Residual norm 2.580757152907e-01
>     12 KSP Residual norm 2.549505151556e-01
>     13 KSP Residual norm 2.509670840632e-01
>     14 KSP Residual norm 2.464315316006e-01
>     15 KSP Residual norm 2.416198261586e-01
>     16 KSP Residual norm 2.359854861997e-01
>     17 KSP Residual norm 2.298769116813e-01
>     18 KSP Residual norm 2.232203276735e-01
>     19 KSP Residual norm 2.153461917946e-01
>     20 KSP Residual norm 2.072492142809e-01
>     21 KSP Residual norm 1.983342705665e-01
>     22 KSP Residual norm 1.894778760982e-01
>     23 KSP Residual norm 1.803772952130e-01
>     24 KSP Residual norm 1.718394016178e-01
>     25 KSP Residual norm 1.639952865611e-01
>     26 KSP Residual norm 1.571843225056e-01
>     27 KSP Residual norm 1.512651261054e-01
>     28 KSP Residual norm 1.459688114323e-01
>     29 KSP Residual norm 1.410245577886e-01
>     30 KSP Residual norm 1.364936912778e-01
>    0 KSP Residual norm 2.864424649239e+00
>    1 KSP Residual norm 2.719941822422e+00
>    2 KSP Residual norm 2.486679927440e+00
>    3 KSP Residual norm 2.176182306332e+00
>  0 KSP preconditioned resid norm 3.133018965496e+02 true resid norm
> 5.229629619561e+01 ||Ae||/||Ax|| 1.000000000000e+00
>
> =
> ======================================================================
>

```