<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr"></div><div dir="ltr"><br></div><div dir="ltr"><br><blockquote type="cite">On 18 Nov 2022, at 2:47 PM, Karthikeyan Chockalingam - STFC UKRI <karthikeyan.chockalingam@stfc.ac.uk> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style>@font-face { font-family: "Cambria Math"; }
@font-face { font-family: Calibri; }
@font-face { font-family: Menlo; }
p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; }
p.p1, li.p1, div.p1 { margin: 0cm; background-color: white; font-size: 9pt; font-family: Menlo; color: black; }
p.p2, li.p2, div.p2 { margin: 0cm; background-color: white; font-size: 9pt; font-family: Menlo; color: rgb(196, 26, 22); }
span.s1 { color: rgb(108, 54, 169); }
span.s2 { color: rgb(155, 35, 147); }
span.s3 { color: rgb(196, 26, 22); }
span.s4 { color: rgb(100, 56, 32); }
span.apple-converted-space { }
span.s5 { }
.MsoChpDefault { font-size: 10pt; }
@page WordSection1 { size: 612pt 792pt; margin: 72pt; }
div.WordSection1 { page: WordSection1; }</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->


<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Thank you. I added<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">    ierr =
</span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">KSPSetFromOptions</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ksp);
</span><span style="font-size:9.0pt;font-family:Menlo;color:#643820">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ierr);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">before </span><span class="s1">PetscOptionsSetValue
</span><span style="mso-fareast-language:EN-US">but still I don’t see the ksp iterations or any other info flags I set.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">I am not passing anything via the command line and believe
</span><span class="s1">PetscOptionsSetValue </span><span style="mso-fareast-language:EN-US">would set the flags.</span></p></div></div></blockquote><div><br></div><div>If you call KSPSetFromOptions() before you set any options, there is nothing to set.</div><div>Usually, you want to delay calling that function up until you are done setting options.</div><div><br></div><div>Thanks,</div><div>Pierre</div><br><blockquote type="cite"><div dir="ltr"><div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Best,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Karthik.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Pierre Jolivet <pierre@joliv.et><br>
<b>Date: </b>Friday, 18 November 2022 at 13:36<br>
<b>To: </b>Chockalingam, Karthikeyan (STFC,DL,HC) <karthikeyan.chockalingam@stfc.ac.uk><br>
<b>Cc: </b>petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Subject: </b>Re: [petsc-users] PetscOptionsSetValue syntax<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
<br>
</p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt">On 18 Nov 2022, at 2:32 PM, Karthikeyan Chockalingam - STFC UKRI via petsc-users <petsc-users@mcs.anl.gov> wrote:</p>
</blockquote>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Hello,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I would like to move from code to using options. </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#3900A0">   KSP</span><span style="font-size:9.0pt;font-family:Menlo;color:black">           ksp;</span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">    </span><span style="font-size:9.0pt;font-family:Menlo;color:#3900A0">PC</span><span style="font-size:9.0pt;font-family:Menlo;color:black">         
   pc;</span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">    KSPCreate(PETSC_COMM_WORLD, &ksp);</span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">    </span><span style="font-size:9.0pt;font-family:Menlo;color:#6C36A9">KSPSetOperators</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(ksp,
 A, A);</span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></p>
<p class="MsoNormal" style="background:white"><span style="color:black">I tried using PetscOptionsSetValue as below</span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></p>
<p class="p1"><span class="apple-converted-space">    </span>ierr = <span class="s1">
PetscOptionsSetValue</span>(<span class="s2"><b>NULL</b></span>,<span class="s3">"-ksp_type"</span>,
<span class="s3">"cg"</span>); <span class="s4">CHKERRQ</span>(ierr);</p>
<p class="p1"><span class="apple-converted-space">    </span>ierr = <span class="s1">
PetscOptionsSetValue</span>(<span class="s2"><b>NULL</b></span>,<span class="s3">"-pc_type"</span>,
<span class="s3">"jacobi"</span>); <span class="s4">CHKERRQ</span>(ierr);</p>
<p class="p1"><span class="apple-converted-space">    </span>ierr = <span class="s1">
PetscOptionsSetValue</span>(<span class="s2"><b>NULL</b></span>, <span class="s3">
"-ksp_monitor"</span>, <span class="s2"><b>NULL</b></span>);<span class="s4">CHKERRQ</span>(ierr);</p>
<p class="p1"><span class="apple-converted-space">    </span>ierr = <span class="s1">
PetscOptionsSetValue</span>(<span class="s2"><b>NULL</b></span>, <span class="s3">
"-ksp_view"</span>, <span class="s2"><b>NULL</b></span>);<span class="s4">CHKERRQ</span>(ierr);</p>
<p class="p2"><span class="apple-converted-space">    </span><span class="s5">ierr =
</span><span class="s1">PetscOptionsSetValue</span><span class="s5">(</span><span class="s2"><b>NULL</b></span><span class="s5">,
</span>"-ksp_monitor_true_residual"<span class="s5">, </span><span class="s2"><b>NULL</b></span><span class="s5">);</span><span class="s4">CHKERRQ</span><span class="s5">(ierr);</span></p>
<p class="p1"><span class="apple-converted-space">    </span>ierr = <span class="s1">
PetscOptionsSetValue</span>(<span class="s2"><b>NULL</b></span>, <span class="s3">
"-ksp_converged_reason"</span>, <span class="s2"><b>NULL</b></span>);<span class="s4">CHKERRQ</span>(ierr);</p>
<p class="p1"> </p>
<p class="p1"><span class="apple-converted-space">    </span><span class="s1">KSPSolve</span>(ksp, b, x);</p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;color:black"> </span></p>
<p class="MsoNormal">But I believe none of the string flags where picked up by PETSc. What am I missing?</p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">KSPSetFromOptions()<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Pierre<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">Thank you for your help.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Kind regards,</p>
<p class="MsoNormal">Karthik.</p>
<p><span style="font-size:6.0pt">This email and any attachments are intended solely for the use of the named recipients. If you are not the intended recipient you must not use, disclose, copy or distribute this email or any of its attachments and should notify
 the sender immediately and delete this email from your system. UK Research and Innovation (UKRI) has taken every reasonable precaution to minimise risk of this email or any attachments containing viruses or malware but the recipient should carry out its own
 virus and malware checks before opening the attachments. UKRI does not accept any liability for any losses or damages which the recipient may sustain due to presence of any viruses. </span></p>
</div>
</blockquote>
</div>


</div></blockquote></body></html>