[petsc-users] Test convergence with non linear preconditioners

Adolfo Rodriguez adantra at gmail.com
Thu Aug 6 21:07:15 CDT 2020


Considering the output produced by snes_view (attachment), would be
possible to change the linear solver tolerances and the preconditioning
level or type?

Adolfo

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Wed, Aug 5, 2020 at 8:31 PM Barry Smith <bsmith at petsc.dev> wrote:

>
>    Turtles on top of turtles on top of turtles.
>
>    It is probably easiest for you to look at the actual code to see how it
> handles things
>
>   1) the SNESFAS uses SNES for each of the levels, for each of these level
> SNES you can control the convergence criteria (either from the command
> lineor with appropriate prefix (highly recommended) or with function calls
> (not recommended)); and even provide your own convergence functions  run
> with -snes_view to see the various solvers and their prefixes).
>
>   2) at the finest level of SNESFAS it does call
>
>     /* Test for convergence */
>     if (isFine) {
>       ierr =
> (*snes->ops->converged)(snes,snes->iter,0.0,0.0,snes->norm,&snes->reason,snes->cnvP);CHKERRQ(ierr);
>       if (snes->reason) break;
>     }
>
> src/snes/impls/fas/fas.c line 881 so at least in theory you can provide
> your own convergence test function.
>
>   It was certainly our intention that users can control all the
> convergence knobs for arbitrary imbedded nonlinear solvers including FAS
> but, of course, there may be bugs so let us know what doesn't work.
>
>  Generally the model for FAS is to run a single (or small number of)
> iteration(s) on the level solves and so not directly use convergence
> tolerances like rtol to control the number of iterations on a level but you
> should be able to set any criteria you want.
>
>   You should be able to run with -snes_view and change some of the
> criteria on the command line and see the changes presented in the
> -snes_view output, plus see differences in convergence behavior.
>
>
>
>   Barry
>
>
>
> On Aug 5, 2020, at 8:10 PM, Adolfo Rodriguez <adantra at gmail.com> wrote:
>
> It looks like I cannot really change the test function or anything else
> for this particular SNES solver  (I am using SNESFas). Basically, I am
> trying to use the ideas exposed in the paper on Composing scalable solvers
> but it seems that SNESFas does not allow to change the function for testing
> convergence, or anything else. Is this correct?
>
> Adolfo
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
>
> On Wed, Aug 5, 2020 at 3:41 PM Barry Smith <bsmith at petsc.dev> wrote:
>
>>
>>    Adolfo,
>>
>>      You can also just change the tolerances for the inner solve using
>> the options data base and the prefix for the inner solve.
>>
>>      When you run with -snes_view it will show the prefix for each of the
>> (nested) solvers. You can also run with -help to get all the possible
>> options for the inner solvers.
>>
>>      In this case I think the prefix is npc so you can set tolerances
>> with -npc_snes_rtol <rtol> -npc_ksp_rtol <rtol> etc.  From the program you
>> can use SNESGetNPC() and then call SNESSetXXX() to set options, for the
>> linear solver (if there is one) call SNESGetKSP() on the npc and then set
>> options on that KSP.
>>
>>
>>    Barry
>>
>>
>> On Aug 5, 2020, at 3:30 PM, Adolfo Rodriguez <adantra at gmail.com> wrote:
>>
>> Jed,
>>
>> I tred your suggestion
>>
>>   SNESGetNPC(snes, &inner);
>>   SNESSetConvergenceTest(inner, YourFunc, ...);
>>
>> and it is working as expected. I had not pieced together the fact that
>> "inner" is a "snes" object as well.
>>
>> Thanks!
>>
>>
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free.
>> www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
>>
>> On Wed, Aug 5, 2020 at 3:11 PM Jed Brown <jed at jedbrown.org> wrote:
>>
>>> Adolfo Rodriguez <adantra at gmail.com> writes:
>>>
>>> > Actually I can set the non-linear pc. My problem relates to the
>>> convergence
>>> > test. I have not found a way to set the tolerances for the inner
>>> problem,
>>> > are they hard coded?
>>>
>>> I suggested code to set a custom convergence test.  Nothing is
>>> hard-coded.  What have you done?
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200806/b479366a/attachment.html>
-------------- next part --------------
SNES Object: 1 MPI processes
  type: anderson
    Number of stored past updates: 30
    Residual selection: gammaA=2e+00, gammaC=2e+00
    Difference restart: epsilonB=1e-01, deltaB=9e-01
    Restart on F_M residual increase: FALSE
  maximum iterations=10000, maximum function evaluations=30000
  tolerances: relative=1e-08, absolute=1e-50, solution=1e-08
  total number of function evaluations=2
  norm schedule ALWAYS
  SNESLineSearch Object: 1 MPI processes
    type: basic
    maxstep=1.000000e+08, minlambda=1.000000e-12
    tolerances: relative=1.000000e-08, absolute=1.000000e-15, lambda=1.000000e-08
    maximum iterations=1
  SNES Object: (npc_) 1 MPI processes
    type: fas
      type is MULTIPLICATIVE, levels=1, cycles=1
      Not using Galerkin computed coarse grid function evaluation
      Coarse grid solver -- level 0 -------------------------------
      SNES Object: (npc_fas_coarse_) 1 MPI processes
        type: newtonls
        maximum iterations=50, maximum function evaluations=10000
        tolerances: relative=1e-08, absolute=1e-50, solution=1e-08
        total number of linear solver iterations=43
        total number of function evaluations=3
        norm schedule FINALONLY
        SNESLineSearch Object: (npc_fas_coarse_) 1 MPI processes
          type: bt
            interpolation: cubic
            alpha=1.000000e-04
          maxstep=1.000000e+08, minlambda=1.000000e-12
          tolerances: relative=1.000000e-08, absolute=1.000000e-15, lambda=1.000000e-08
          maximum iterations=40
        KSP Object: (npc_fas_coarse_) 1 MPI processes
          type: gmres
            restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement
            happy breakdown tolerance 1e-30
          maximum iterations=10000, initial guess is zero
          tolerances:  relative=1e-05, absolute=1e-50, divergence=10000.
          left preconditioning
          using PRECONDITIONED norm type for convergence test
        PC Object: (npc_fas_coarse_) 1 MPI processes
          type: ilu
            out-of-place factorization
            0 levels of fill
            tolerance for zero pivot 2.22045e-14
            matrix ordering: natural
            factor fill ratio given 1., needed 1.
              Factored matrix follows:
                Mat Object: 1 MPI processes
                  type: seqaij
                  rows=786, cols=786
                  package used to perform factorization: petsc
                  total: nonzeros=6060, allocated nonzeros=6060
                  total number of mallocs used during MatSetValues calls=0
                    not using I-node routines
          linear system matrix = precond matrix:
          Mat Object: 1 MPI processes
            type: seqaij
            rows=786, cols=786
            total: nonzeros=6060, allocated nonzeros=6060
            total number of mallocs used during MatSetValues calls=0
              not using I-node routines
    maximum iterations=1, maximum function evaluations=30000
    tolerances: relative=0., absolute=0., solution=0.
    total number of function evaluations=0
    norm schedule FINALONLY


More information about the petsc-users mailing list