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 <[email protected]> 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
> [email protected]