[petsc-users] Options database in petsc4py

SCOTTO Alexandre alexandre.scotto at irt-saintexupery.com
Mon Oct 27 04:23:50 CDT 2025


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?

Regards,
Alexandre Scotto.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20251027/373a3570/attachment.html>


More information about the petsc-users mailing list