dmmg residuals and AMG

Barry Smith bsmith at mcs.anl.gov
Wed Dec 13 11:11:56 CST 2006

``` Nicolas,

On Wed, 13 Dec 2006, Nicolas Bathfield wrote:

> Dear Barry and Petsc users,
>
> I dig into the code to understand a bit better the output from the options
> -ksp_view -dmmg_ksp_monitor, but I am still confused (There is a printout
> of ksp/ksp/example/tutorial/ex29.c slightly modified below).
>
> -ksp_view gives:
>  MG: type is FULL, levels=3 cycles=1, pre-smooths=1, post-smooths=1;
> Does that really mean that I perform only 1 multigrid cycle? How can I
> control the number of cycles and the convergence criteria?

The cycles 1 is INSIDE the information for the MG preconditioner. This means
that it is using 1 cycle of FULL mg as a PRECONDITIONER inside the outter (FLEXIBLE) GMRES.
If you do not want to use the fgmres acceleration then use -ksp_type richardson
-pc_mg_type multiplicative and it will do the usual v-cycle multigrid until
the ksp convergence tolerance (in your case reduction of residual norm by 1e5)
is achieved. To use a W cycle instead use -pc_mg_cycles 2. (I notice I don't have a
hook for using 2 V or W cycles as a preconditioner)

So in short it is not doing 1 cycle and stopping it is using 1 cycle as
a preconditioner for a usual KSP method.

> What does the first index (0,1,2 or 3)in front of KSP residual represent?
>
Sorry the formatting of the output got screwed up in that last release. Here is
what it should look like

[barry-smiths-computer:snes/examples/tutorials] bsmith% ./ex19 -dmmg_nlevels 3 -dmmg_ksp_monitor -dmmg_snes_monitor
lid velocity = 0.00591716, prandtl # = 1, grashof # = 1
0 SNES Function norm 7.886953101160e-02
0 KSP Residual norm 7.886953101160e-02           (initial residual of complete linear system)
0 KSP Residual norm 2.578939596744e+00       (initial residual on level 1
1 KSP Residual norm 8.580502942028e-01        residual after the pre smooth step on level 1
Note it does not print residuals on level 0 coarse grid because a direct LU solver is used (by default)
0 KSP Residual norm 7.094309025479e-01        residual (after the coarse grid correction) on level 1
1 KSP Residual norm 1.957760982966e-01        residual after post-smooth on level 1
0 KSP Residual norm 2.075431534545e+00          initial residual on level 2
1 KSP Residual norm 6.045540957388e-01          residual on level 2 after pre-smooth
0 KSP Residual norm 6.594930640698e-01        initial residual on level 1 after restriction
1 KSP Residual norm 1.873678881899e-01            level 1 after pre-smooth
0 KSP Residual norm 3.181690759952e-01            level 1 after coarse grid correction
1 KSP Residual norm 6.667286758128e-02            level 1 after post-smooth
0 KSP Residual norm 1.612193634389e+00          level 2 after level 1 coarse correction
1 KSP Residual norm 4.428777921897e-01          level 2 after post-smooth
1 KSP Residual norm 2.757385168519e-02          (residual after one iteration of FGMRES on the entire system)
0 KSP Residual norm 2.371988427435e+00
1 KSP Residual norm 4.603841291940e-01
0 KSP Residual norm 9.537098076551e-01
1 KSP Residual norm 2.372055351128e-01
0 KSP Residual norm 2.711798509188e+00
1 KSP Residual norm 6.529602589787e-01
0 KSP Residual norm 1.107566255572e+00
1 KSP Residual norm 2.612091585278e-01
0 KSP Residual norm 3.201409476039e-01
1 KSP Residual norm 8.889931894491e-02
0 KSP Residual norm 1.371722591156e+00
1 KSP Residual norm 4.736289571173e-01
2 KSP Residual norm 6.009911728204e-03
0 KSP Residual norm 2.085355246785e+00
1 KSP Residual norm 3.940644584596e-01
0 KSP Residual norm 7.653134098239e-01
1 KSP Residual norm 1.914404634341e-01
0 KSP Residual norm 2.385479137738e+00
1 KSP Residual norm 5.858823293243e-01
0 KSP Residual norm 1.104077971916e+00
1 KSP Residual norm 2.411330383552e-01
0 KSP Residual norm 2.979088078743e-01
1 KSP Residual norm 5.916390357483e-02
0 KSP Residual norm 1.295627867427e+00
1 KSP Residual norm 4.389707070240e-01
3 KSP Residual norm 4.890428781555e-04
0 KSP Residual norm 2.047523195596e+00
1 KSP Residual norm 4.264677474628e-01
0 KSP Residual norm 1.029983323961e+00
1 KSP Residual norm 2.539427868572e-01
0 KSP Residual norm 2.553639453818e+00
1 KSP Residual norm 5.757990843674e-01
0 KSP Residual norm 1.138585506415e+00
1 KSP Residual norm 2.355704751953e-01
0 KSP Residual norm 3.092827768419e-01
1 KSP Residual norm 6.071447174488e-02
0 KSP Residual norm 1.358066234308e+00
1 KSP Residual norm 4.505697416265e-01
4 KSP Residual norm 2.690993167559e-05
0 KSP Residual norm 1.816339210351e+00
1 KSP Residual norm 4.389412798513e-01
0 KSP Residual norm 1.064334150012e+00
1 KSP Residual norm 2.361933072662e-01
0 KSP Residual norm 2.157389468526e+00
1 KSP Residual norm 5.693236871123e-01
0 KSP Residual norm 9.333422097061e-01
1 KSP Residual norm 2.239182808762e-01
0 KSP Residual norm 3.848098361086e-01
1 KSP Residual norm 1.015246663039e-01
0 KSP Residual norm 1.312503155715e+00
1 KSP Residual norm 4.374736783054e-01
5 KSP Residual norm 2.159855734129e-06
0 KSP Residual norm 1.152776829315e+00
1 KSP Residual norm 2.640188473397e-01
0 KSP Residual norm 3.473379921732e-01
1 KSP Residual norm 6.973067016139e-02
0 KSP Residual norm 1.674499511581e+00
1 KSP Residual norm 3.691885478016e-01
0 KSP Residual norm 5.881350233350e-01
1 KSP Residual norm 1.623887401757e-01
0 KSP Residual norm 1.899371906578e-01
1 KSP Residual norm 5.283607577248e-02
0 KSP Residual norm 6.796871956361e-01
1 KSP Residual norm 2.167234174310e-01
6 KSP Residual norm 3.259317892179e-07
1 SNES Function norm 7.468268333544e-06

>
>
> Best regards,
>
> Nicolas.
>
>
0 KSP Residual norm 1.421285957034e-02
>                1 KSP Residual norm 1.609288367464e-03
>              0 KSP Residual norm 2.699978999993e-01
>              1 KSP Residual norm 3.406567948849e-02
>       0 KSP Residual norm 2.101495954238e-02
>       1 KSP Residual norm 1.846013302069e-03
>       0 KSP Residual norm 8.326606206788e-04
>       1 KSP Residual norm 4.344001727320e-05
>       0 KSP Residual norm 1.577985727128e-02
>         1 KSP Residual norm 1.969730522207e-03
>       1 KSP Residual norm 2.116914409872e-02
>       0 KSP Residual norm 1.029801283683e-01
>       1 KSP Residual norm 7.594550723847e-03
>       0 KSP Residual norm 7.254183286194e-03
>       1 KSP Residual norm 6.000261158570e-04
>       0 KSP Residual norm 2.966998198077e-01
>       1 KSP Residual norm 5.201133083048e-02
>       0 KSP Residual norm 3.786415700595e-02
>       1 KSP Residual norm 3.901313528873e-03
>       0 KSP Residual norm 3.502275405186e-03
>       1 KSP Residual norm 2.803439371866e-04
>       0 KSP Residual norm 2.150042336470e-02
>       1 KSP Residual norm 3.280472811048e-03
>       2 KSP Residual norm 1.206584038156e-04
>       0 KSP Residual norm 1.010495676349e-01
>       1 KSP Residual norm 5.373641377818e-03
>       0 KSP Residual norm 3.177241089754e-03
>       1 KSP Residual norm 2.956553309307e-04
>       0 KSP Residual norm 2.439978649540e-01
>       1 KSP Residual norm 2.775398636052e-02
>       0 KSP Residual norm 2.197619585488e-02
>       1 KSP Residual norm 1.465557162804e-03
>       0 KSP Residual norm 1.119259726469e-03
>       1 KSP Residual norm 6.758059074616e-05
>       0 KSP Residual norm 1.390217147343e-02
>       1 KSP Residual norm 1.994861880977e-03
>       3 KSP Residual norm 5.385911324388e-07
>     KSP Object:
>       type: fgmres
>         GMRES: restart=30, using Classical (unmodified) Gram-Schmidt
> Orthogonalization with no iterative refinement
>         GMRES: happy breakdown tolerance 1e-30
>       maximum iterations=10000, initial guess is zero
>       tolerances:  relative=1e-05, absolute=1e-50, divergence=10000
>       right preconditioning
>     PC Object:
>       type: mg
>         MG: type is FULL, levels=3 cycles=1, pre-smooths=1, post-smooths=1
>       Coarse gride solver -- level 0 -------------------------------
>         KSP Object:(mg_coarse_)
>           type: preonly
>           maximum iterations=1, initial guess is zero
>           tolerances:  relative=1e-05, absolute=1e-50, divergence=10000
>           left preconditioning
>         PC Object:(mg_coarse_)
>           type: lu
>             LU: out-of-place factorization
>               matrix ordering: nd
>             LU: tolerance for zero pivot 1e-12
>             LU: factor fill ratio needed 1.54545
>                  Factored matrix follows
>                 Matrix Object:
>                   type=seqaij, rows=9, cols=9
>                   total: nonzeros=51, allocated nonzeros=51
>                     not using I-node routines
>           linear system matrix = precond matrix:
>           Matrix Object:
>             type=seqaij, rows=9, cols=9
>             total: nonzeros=33, allocated nonzeros=33
>               not using I-node routines
>
>
>
> >
> >
> > On Mon, 11 Dec 2006, Nicolas Bathfield wrote:
> >
> >>  Hi,
> >>
> >> I would like to compare PETSc DMMG convergence to some theoretical
> >> convergence rate given by local Fourier analysis for a simple diffusion
> >> problem.
> >> To do so, I need to extract the residuals after each multigrid
> >> iteration.
> >> Unfortunately, I only managed to obtain the residuals at the last
> >> iteration.
> >> Is it possible to get the residual printed out after each multigrid
> >> iteration without modifying the source code?
> >
> >   Nicolas,
> >
> >   -dmmg_ksp_monitor prints the residual after each V/W cycle.
> > -pc_mg_monitor
> > prints the residual norm before and after each smoothing step.
> >
> >   BTW: always run with -ksp_view to see exactly what solver options
> > are being used. The defaults are non-standard (e.g. we default to having a
> > Krylov solver turned on for each smoother and the V/W cycle).
> >
> >
> >>
> >> Furthermore, I'd like to test the AMG from the PC type from HYPRE
> >> Is
> >> there any example available somewhere?
> >
> >   -pc_type hypre -pc_hypre_type boomeramg
> >
> > Run with -help to see the boomeramg options; again use -ksp_view we
> > default
> > to accelerating boomeramg with GMRES which is non-standard. Use -ksp_type
> > richardson
> > to get the usual V/W cycle.
> >
> >   Good luck,
> >
> >    Barry
> >
> > Why the non-standard defaults? We want to provide a default MG that is as
> > robust
> > (more likely to converge) as possible. Hence we turn on ILU(0) smoothing
> > with GMRES
> > acceleration of the smoother and Krylov method. You can turn off these
> > options one
> > at a time to see the effect on the convergence rate. For model problems
> > the accelerators
> > only improve convergence a little. For more complex problems, for example
> > src/snes/examples/tutorials/ex19.c
> > convergence gets much worse without the accelerators.
> >
> >>
> >> Best regards,
> >>
> >> Nicolas.
> >>  --
> >>  Nicolas BATHFIELD
> >>  Chalmers University of Technology
> >>  Shipping and Marine Technology
> >>  phone: +46 (0)31 772 1476
> >>  fax:   +46 (0)31 772 3699
> >>
> >>
> >
> >
>
>
>

```