[petsc-users] About the "PetscOptionsSetValue" usage

Jed Brown jed at 59A2.org
Fri Dec 10 12:46:36 CST 2010


On Fri, Dec 10, 2010 at 19:22, Filippo Spiga
<filippo.spiga at disco.unimib.it>wrote:

> So SNES runs with C=3 that is different from the default. But I would like
> to use the default because C=3 produces wrong errors. How I can easily reset
> the options' database?


You're making this much more complicated than necessary.  Call

KSPSetOptionsPrefix(ksp,"a_");
SNESSetOptionsPrefix(snes,"b_");

KSPSetFromOptions(ksp);
SNESSetFromOptions(snes);

KSPSolve(ksp,...);
SNESSolve(snes,...);


Then you run the program with

  -a_ksp_type gmres -a_pc_type asm -b_snes_monitor -b_ksp_type ibcgs
-b_pc_type bjacobi

or whatever.  You can control all the details of each solver independently.

If you *need* to control the solvers in code (usually only if you have an
adaptive method where *your program* takes *active* control of the solution
process), you should pull out the objects and use the API instead of strings
to get what you need:

SNESGetKSP(snes,&inner_ksp);
KSPSetType(inner_ksp,KSPIBCGS);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101210/b41a9c40/attachment.htm>


More information about the petsc-users mailing list