[petsc-users] API cal to set mg_levels_pc_type
Barry Smith
bsmith at petsc.dev
Fri May 20 15:11:29 CDT 2022
> Yes, this is what I did.
> But I have a function that sets up the preconditioner by taking a KSP
> as an argument. Depending on the problem being solved, it can be a
> single KSP or a sub-KSP coming from a field split (which if there are
> lagrange multipliers, can be further split again). So I was looking for
> a call that would work on the KSP passed as an argument. The option
> string won't work in the general field-split case.
You can provide multiple options with PetscOptionsSetValue() for example
>> PetscOptionsSetValue(NULL,"-mg_levels_pc_type","sor");
>> PetscOptionsSetValue(NULL,"-fieldsplit_0_mg_levels_pc_type","sor");
etc
and any "extra" ones not appropriate for your particular case will just be ignored.
> On May 20, 2022, at 3:25 PM, Jeremy Theler <jeremy at seamplex.com> wrote:
>
> On Fri, 2022-05-20 at 14:48 -0400, Barry Smith wrote:
>>>
>>> The default smoothing PC changed from sor to jacobi in 3.17.
>>
>> Note that this is only for GAMG, it is not for geometric multigrid
>> (using PCMG directly).
>
> Indeed, I was asking about GAMG specifically.
>
>>
>>> The
>>> Changelog says the old behavior can be recovered by using
>>> -mg_levels_pc_type sor.
>>
>> The easiest is just doing
>>
>> PetscOptionsSetValue(NULL,"-mg_levels_pc_type","sor");
>
> Yes, this is what I did.
> But I have a function that sets up the preconditioner by taking a KSP
> as an argument. Depending on the problem being solved, it can be a
> single KSP or a sub-KSP coming from a field split (which if there are
> lagrange multipliers, can be further split again). So I was looking for
> a call that would work on the KSP passed as an argument. The option
> string won't work in the general field-split case.
>
>>
>> Unfortunately, there is no good way to set it with calls directly
>> on the KSP or MG object. One
>> needs to loop through the levels and set it for the PC on each level.
>
> Maybe this is doable. I'll take a stab with this approach.
> Thanks Barry.
>
> --
> jeremy
More information about the petsc-users
mailing list