[petsc-users] About the "PetscOptionsSetValue" usage

Filippo Spiga filippo.spiga at disco.unimib.it
Fri Dec 10 12:54:51 CST 2010


Interesting. This

KSPSetOptionsPrefix(ksp,"a_");
PetscOptionsSetValue("a_A", "1");
PetscOptionsSetValue("a_B", "2");
PetscOptionsSetValue("a_C", "3");
ierr = KSPSolve();

SNESSetOptionsPrefix(snes,"b_");
PetscOptionsSetValue("b_A", "10");
PetscOptionsSetValue("b_B", "20");
ierr = SNESSolve();

should work because the preset will be
- KSP : {A=1, B=2, C=3}
- SNES : {A=10, B=20, C=PETSC_DEFAULT}.
exactly as I want.

I know that it is possible to use API to set parameters (KSPSetType,
SNESSetType). But a lot of options of HYPRE or SUPERLU for example have no
API. Instead of mix option from command-line and API I would like to put
everything in a config file, read it and use PetscOptionsSetValue in the
right way. It seems reasonable to me.

Anyway, every suggestion is welcome (-:

Thanks a lot!

--
Filippo SPIGA, MSc Computer Science
~ homepage: http://tinyurl.com/fspiga ~

«Nobody will drive us out of Cantor's paradise.»
    -- David Hilbert

*****
Disclaimer: "Please note this message and any attachment are CONFIDENTIAL an
may be privileged or otherwise protected from disclosure. The contents are
not to be disclosed to anyone other than the addressee. Unauthorized
recipients are requested to preserve this confidentiality and to advise the
sender immediately of any error in transmission."



On Fri, Dec 10, 2010 at 1:46 PM, Jed Brown <jed at 59a2.org> wrote:

> 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/6c9c2389/attachment-0001.htm>


More information about the petsc-users mailing list