[petsc-users] How to replace the default global database?

Lucas Clemente Vella lvella at gmail.com
Mon May 29 13:20:33 CDT 2017


Hi. Not really what I need. Every time I run my program, I need to pass the
non-trivial solver setup that works as a command line argument (I am using
Schur complement with BCGS and Hypre as internal KSP and PC). I want to
hardcode the complex solver setup so that I can use it depending on a
runtime switch. Like this:

if(use_schur) {
  // change global PETSc options to the settings I know to work.
}

my_solver_struct *s = create_petsc_solver();

if(use_schur) {
  // restore original PETSc options.
}

2017-05-26 19:55 GMT-03:00 Barry Smith <bsmith at mcs.anl.gov>:

>
>    I do not think you want to do this. The standard way we handle what it
> seems you need is to use PetscObjectSetOptionsPrefix() for the different
> PETSc objects giving them different prefixes and then appending the prefix
> for the options when you provide them to the options database. For example
> if you have a KSP for a flow solver and a KSP for a pressure solver you
> might do
>
>     KSPCreate(PETSC_COMM_WORLD,&flow);
>     KSPSetOptionsPrefix(flow,"u");
>
>     KSPCreate(PETSC_COMM_WORLD,&pressure);
>     KSPSetOptionsPrefix(pressure,"p");
>
>     and set options like
>
>      -u_pc_type jacobi
>
>      -p_pc_type gamg
>
>     Will this do what you need?
>
>    Barry
>
>      Because the options data base can be accessed by any object at any
> time (not just when it is created), it doesn't make sense to change the
> default options database ever because it would be uncertain what objects
> the change affected or did not affect.
>
>
>
>
>
>
> > On May 26, 2017, at 4:20 PM, Lucas Clemente Vella <lvella at gmail.com>
> wrote:
> >
> > Here is what I want to do:
> > - Take the global PetscOptions and store it somewhere;
> > - Create my own PetscOptions;
> > - Populate it with my options;
> > - Set my new PetscOptions as the global default;
> > - Create some PETSc objects;
> > - Restore old PetscOptions as default global;
> > - Destroy the PetscOptions I created.
> >
> > I could not find a function to replace global PetscOptions, or to copy
> one PetscOptions to another. Is it possible to do what I want to do? How?
> >
> > --
> > Lucas Clemente Vella
> > lvella at gmail.com
>
>


-- 
Lucas Clemente Vella
lvella at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170529/a49e866e/attachment.html>


More information about the petsc-users mailing list