[petsc-users] About the "PetscOptionsSetValue" usage

Filippo Spiga filippo.spiga at disco.unimib.it
Mon Dec 13 00:35:30 CST 2010


I was referring to the input file of my application, I do not want to pass
PETSc option by the command line or using another specific file input.

Anyway, I tried the strategy "KSPSetOptionsPrefix(..)"/"SNES
SetOptionsPrefix(...);" + "PetscOptionsSetValue(...)" and it works very
well!!! But now I have another question. Using these routines, every time
I cyclically call KSP and/or SNES in my program I put new options inside the
PETSc option database. Most of these options, that have the same prefix, are
replicated.  Is this a problem? Is it always true that I will use the last
one inserted?


Let's consider this example:

begin program
  begin program iteration number 1
     CreateKSP(myksp1);
     PetscOptionsSetValue("-a", "1");
     PetscOptionsSetValue("-b", "2");
     KSPSolve(myksp1)
     DestroyKSP(myksp1);
  end program iteration number 1

  begin program iteration number 2
     CreateKSP(myksp2);
     PetscOptionsSetValue("-a", "5");
     PetscOptionsSetValue("-c", "5");
     KSPSolve(myksp2);
     DestroyKSP(myksp2);
  end program iteration number 2

  begin program iteration number 3
     CreateKSP(myksp3);
     PetscOptionsSetValue("-a", "10");
     PetscOptionsSetValue("-b", "20");
     KESPSolve(myksp3);
     DestroyKSP(myksp3);
   end program iteration number 3
end program

In the iteration 2 appears the option "-c", what can I do to remove the
option "-b" inside the internal PETSc option database?
And similar, in the iteration 3 the option "-c" disappears and the option
"-b" returns with a different value. What can I do to remove the option "-c"
inside the internal PETSc option database?

Is there a routine that reset/empty completely the internal PETSc database
option without terminate the program? Or the only way is to assign a
different prefix for every program iteration?

Thanks very much in advance,
Cheers!

--
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 2:09 PM, Jed Brown <jed at 59a2.org> wrote:

> On Fri, Dec 10, 2010 at 19:54, Filippo Spiga <
> filippo.spiga at disco.unimib.it> wrote:
>
>> 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
>
>
> You might be interested in the -options_file command line option and
> PetscOptionsInsertFile.  Also, any options present in
>
> ~/.petscrc
> .petscrc (in current directory)
> petscrc (in current directory)
>
> get slurped in automatically, as well as the string in the PETSC_OPTIONS
> environment variable.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101213/dc21bf3f/attachment-0001.htm>


More information about the petsc-users mailing list