[petsc-users] Test convergence with non linear preconditioners

Dave May dave.mayhem23 at gmail.com
Fri Aug 7 15:15:54 CDT 2020


On Fri 7. Aug 2020 at 18:21, Adolfo Rodriguez <adantra at gmail.com> wrote:

> Great, that works. What would be the way to change the ilu level, I need
> to use ilu(1). I
>

You want to use the option

-xxx_pc_factor_levels 1

Where xxx is the appropriate FAS prefix level.

See here

https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCILU.html





would assume that I can accomplish that by means of:
>
> -npc_fas_coarse_pc_type ilu
> -npc_fas_coarse_pc_ilu_levels 1
>
> I noticed that the first line actually works, but I am not sure about the
> second one.
>

If you want to see which options are used / unused, add the command line
option

-options_left 1

Thanks,
Dave



> Thanks,
> 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>
> <#m_5466096191530741685_m_-242385451441738719_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Thu, Aug 6, 2020 at 9:23 PM Matthew Knepley <knepley at gmail.com> wrote:
>
>> On Thu, Aug 6, 2020 at 10:08 PM Adolfo Rodriguez <adantra at gmail.com>
>> wrote:
>>
>>> Considering the output produced by snes_view (attachment), would be
>>> possible to change the linear solver tolerances and the preconditioning
>>> level or type?
>>>
>>
>> Yes. The options prefix is shown for each subsolver. For example, you can
>> change the linear solver type for the coarse level of FAS using
>>
>>   -npc_fas_coarse_ksp_type bigcg
>>
>> Notice that you are using 1 level of FAS, so its the same as just Newton.
>>
>>   Thanks,
>>
>>      Matt
>>
>>
>>> 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>
>>> <#m_5466096191530741685_m_-242385451441738719_m_5425691679335133860_m_9065914518290907664_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?
>>>>>>
>>>>>
>>>>>
>>>>
>>
>> --
>> What most experimenters take for granted before they begin their
>> experiments is infinitely more interesting than any results to which their
>> experiments lead.
>> -- Norbert Wiener
>>
>> https://www.cse.buffalo.edu/~knepley/
>> <http://www.cse.buffalo.edu/~knepley/>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200807/f3a15223/attachment-0001.html>


More information about the petsc-users mailing list