[petsc-users] Equivalent function call for -mg_levels_ksp_type & -mg_levels_pc_type

Barry Smith bsmith at petsc.dev
Thu May 6 11:51:31 CDT 2021


   Milan,

     The simplest way is to use PetscOptionsSetValue() in the code to set the options. If you have multiple solvers you can use PetscObjectSetOptionsPrefix() to use different prefixes for each solver and control them separately. 

      The number of levels and the solvers at each level are created "on the fly" based on the matrix, there is  currently no "function call" way to set these options manually by function calls.

  Barry
 

> On May 6, 2021, at 10:08 AM, Milan Pelletier via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Dear users,
> 
> I would like to know what function call would allow me to achieve the same result as using the two flags 
> -mg_levels_ksp_type richardson
> -mg_levels_pc_type jacobi
> and then PCSetFromOptions().
> I would prefer not to rely on command-line options and rather do the setup "by hand".
> 
> To achieve that, what should I add after these lines:
> KSPCreate(PETSC_COMM_WORLD, solver);
> KSPSetType(solver, KSPCG);
> KSPGetPC(solver, &pc);
> PCSetType(pc, PCGAMGAGG);
> <here I don't know what to set>
> 
> Thanks for your help,
> Regards,
> 
> Milan Pelletier
> 



More information about the petsc-users mailing list