<div dir="ltr"><div dir="ltr">On Mon, Oct 27, 2025 at 10:24 AM SCOTTO Alexandre via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:</div><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-5483869375695487431">





<div lang="EN-US">
<div class="m_-5483869375695487431WordSection1">
<p class="MsoNormal">Dear PETSc Community,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">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:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b>Code</b>:<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver">options = PETSc.Options("ksp_")<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver">options.setValue("atol", 7e-8)<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver">options.view()<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver">options.clear()<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver">options.view()</span><span style="font-family:"Courier New""><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b>Output</b>:<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver">#PETSc Option Table entries:<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span lang="FR" style="font-family:"Courier New";background:silver">-ksp_atol 7e-08 # (source: code)<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver">#End of PETSc Option Table entries<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver">#PETSc Option Table entries:<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver">-ksp_atol 7e-08 # (source: code)<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New";background:silver">#End of PETSc Option Table entries</span><span style="font-family:"Courier New""><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal">It seems that the <span style="font-family:"Courier New";background:silver">
clear()</span> 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
<span style="font-family:"Courier New";background:silver">delValue()</span> method for all the option keys passed:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="m_-5483869375695487431MsoListParagraph"><u></u><span>1.<span style="font:7pt "Times New Roman"">      
</span></span><u></u>Iterate over a dictionary of options and use <span style="font-family:"Courier New";background:silver">
setValue(name, value)</span><u></u><u></u></p>
<p class="m_-5483869375695487431MsoListParagraph"><u></u><span>2.<span style="font:7pt "Times New Roman"">      
</span></span><u></u>Set the KSP with option database: <span style="font-family:"Courier New";background:silver">
KSP.setFromOptions()</span><u></u><u></u></p>
<p class="m_-5483869375695487431MsoListParagraph"><u></u><span>3.<span style="font:7pt "Times New Roman"">      
</span></span><u></u>Iterate over a the keys of the dictionary and <span style="font-family:"Courier New"">
use <span style="background:silver">delValue(name)</span></span> to effectively clear the option database.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Does it seem normal to you, is there something I am missing out?</p></div></div></div></blockquote><div><br></div><div>That for pointing out this bug.</div><div><br></div><div>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.</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-5483869375695487431"><div lang="EN-US"><div class="m_-5483869375695487431WordSection1">
<p class="MsoNormal">Regards,<u></u><u></u></p>
<p class="MsoNormal">Alexandre Scotto.<u></u><u></u></p>
</div>
</div>

</div></blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Yl5kWH4le9b9AulQe-MHUTGMJnJLSAUWTWCPTgED4vuWOpxiWWocOZMgkQeMjxEXM-FS5bHHbw1ItTjXdzbQ$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>