[petsc-users] Options database in petsc4py
Matthew Knepley
knepley at gmail.com
Mon Oct 27 05:26:42 CDT 2025
On Mon, Oct 27, 2025 at 10:24 AM SCOTTO Alexandre via petsc-users <
petsc-users at mcs.anl.gov> wrote:
> Dear PETSc Community,
>
>
>
> In my developments, I am managing possibly several KSP solvers with
> options handled by the Options database. During my tests, I encountered the
> following behavior:
>
>
>
> *Code*:
>
> options = PETSc.Options("ksp_")
>
> options.setValue("atol", 7e-8)
>
> options.view()
>
>
>
> options.clear()
>
> options.view()
>
>
>
> *Output*:
>
> #PETSc Option Table entries:
>
> -ksp_atol 7e-08 # (source: code)
>
> #End of PETSc Option Table entries
>
>
>
> #PETSc Option Table entries:
>
> -ksp_atol 7e-08 # (source: code)
>
> #End of PETSc Option Table entries
>
>
>
> It seems that the clear() method does not really clear the Option
> database. To ensure that the several KSP I deal with are set with their own
> options (without getting options from a KSP previously set), the only way I
> found was to explicitly call the delValue() method for all the option
> keys passed:
>
>
>
> 1. Iterate over a dictionary of options and use setValue(name,
> value)
>
> 2. Set the KSP with option database: KSP.setFromOptions()
>
> 3. Iterate over a the keys of the dictionary and use delValue(name)
> to effectively clear the option database.
>
>
>
> Does it seem normal to you, is there something I am missing out?
>
That for pointing out this bug.
However, I don't think I would manage options this way. We normally give
each separate solver a new _prefix_, meaning a string that prefaces all its
options. That way they do not collide.
Thanks,
Matt
> Regards,
>
> Alexandre Scotto.
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Yl5kWH4le9b9AulQe-MHUTGMJnJLSAUWTWCPTgED4vuWOpxiWWocOZMgkQeMjxEXM-FS5bHHbw1ItcybTP-F$ <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Yl5kWH4le9b9AulQe-MHUTGMJnJLSAUWTWCPTgED4vuWOpxiWWocOZMgkQeMjxEXM-FS5bHHbw1ItTjXdzbQ$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20251027/2a20bf35/attachment.html>
More information about the petsc-users
mailing list