<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div>   You should have very similar behavior, but not identical behavior. The Jacobian-vector product will produce slightly different values with the two approaches, which means that the computed residual norms displayed with -ksp_monitor -snes_monitor etc will be somewhat different. With long runs that involve many nonlinear solves the differences in the norms computed will become nontrivial and you will start getting different iteration counts, but the solutions computed should remain very similar.<div><br></div><div>   Barry</div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Aug 23, 2025, at 10:03 AM, Zou, Ling via petsc-users <petsc-users@mcs.anl.gov> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Thank you both Jed and Stefano.<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Then, somehow, I may have introduced inconsistence in my code, because I expected they have exactly the same behavior.<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Best,<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">-Ling<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div id="mail-editor-reference-message-container"><div><div><div style="border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) currentcolor currentcolor; border-image: none; padding: 3pt 0in 0in;"><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 10pt; font-family: Aptos, sans-serif;"><b><span style="font-size: 12pt;">From:<span class="Apple-converted-space"> </span></span></b><span style="font-size: 12pt;">Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" style="color: blue; text-decoration: underline;">stefano.zampini@gmail.com</a>><br><b>Date:<span class="Apple-converted-space"> </span></b>Friday, August 22, 2025 at 4:42</span><span style="font-size: 12pt; font-family: Arial, sans-serif;"> </span><span style="font-size: 12pt;">PM<br><b>To:<span class="Apple-converted-space"> </span></b>Zou, Ling <<a href="mailto:lzou@anl.gov" style="color: blue; text-decoration: underline;">lzou@anl.gov</a>><br><b>Cc:<span class="Apple-converted-space"> </span></b>PETSc <<a href="mailto:petsc-users@mcs.anl.gov" style="color: blue; text-decoration: underline;">petsc-users@mcs.anl.gov</a>><br><b>Subject:<span class="Apple-converted-space"> </span></b>Re: [petsc-users] Understanding 'snes' object<o:p></o:p></span></p></div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 1pt; color: white;">Il giorno sab 23 ago 2025 alle ore 00:</span><span style="font-size: 1pt; font-family: Arial, sans-serif; color: white;"> </span><span style="font-size: 1pt; color: white;">25 Zou, Ling via petsc-users <petsc-users@</span><span style="font-size: 1pt; font-family: Arial, sans-serif; color: white;"> </span><span style="font-size: 1pt; color: white;">mcs.</span><span style="font-size: 1pt; font-family: Arial, sans-serif; color: white;"> </span><span style="font-size: 1pt; color: white;">anl.</span><span style="font-size: 1pt; font-family: Arial, sans-serif; color: white;"> </span><span style="font-size: 1pt; color: white;">gov> ha scritto: Hi all, Can someone please help me understand the output of the following two outputs using ‘-snes_view’? Option 1: SNES Object: 1<o:p></o:p></span></div></div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 1pt; color: white;">ZjQcmQRYFpfptBannerStart<o:p></o:p></span></div></div><div id="pfptBannerhl1yxxp" style="border-right-width: medium; border-bottom-width: medium; border-left-width: medium; border-right-style: none; border-bottom-style: none; border-left-style: none; border-right-color: currentcolor; border-bottom-color: currentcolor; border-left-color: currentcolor; border-image: none; display: block !important; text-align: left !important; margin: 0px !important; padding: 16px !important; border-radius: 4px !important; min-width: 200px !important; background-color: rgb(208, 216, 220) !important; border-top-width: medium !important; border-top-style: none !important; border-top-color: rgb(144, 164, 174) !important;"><div id="pfptBannerhl1yxxp"><div id="pfptBannerhl1yxxp"><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: rgb(208, 216, 220);"><b><span style="font-size: 12pt; font-family: Arial, sans-serif;">This Message Is From an External Sender<o:p></o:p></span></b></div></div><div id="pfptBannerhl1yxxp"><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif; line-height: 13.5pt; background: rgb(208, 216, 220);"><span style="font-size: 12pt; font-family: Arial, sans-serif;">This message came from outside your organization.<o:p></o:p></span></div></div></div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif; background: rgb(208, 216, 220);"><span style="font-size: 12pt;"> </span><span style="font-size: 12pt;"><o:p></o:p></span></div></div></div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 1pt; color: white;">ZjQcmQRYFpfptBannerEnd<o:p></o:p></span></div></div><div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;"><o:p> </o:p></span></div></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;"><o:p> </o:p></span></div><div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;">Il giorno sab 23 ago 2025 alle ore 00:25 Zou, Ling via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" style="color: blue; text-decoration: underline;">petsc-users@mcs.anl.gov</a>> ha scritto:<o:p></o:p></span></div></div><blockquote style="border-width: medium medium medium 1pt; border-style: none none none solid; border-color: currentcolor currentcolor currentcolor rgb(204, 204, 204); border-image: none; padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;"><div><div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Hi all,</span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"> </span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Can someone please help me understand the output of the following two outputs using ‘-snes_view’?</span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"> </span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Option 1:</span><span style="font-size: 12pt;"><o:p></o:p></span></div><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812s1">SNES Object: 1 MPI process</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">type: newtonls</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">maximum iterations=15, maximum function evaluations=10000</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">tolerances: relative=1e-08, absolute=1e-50, solution=1e-08</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">total number of linear solver iterations=5</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">total number of function evaluations=14</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">norm schedule ALWAYS</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"><span style="color: rgb(0, 176, 80);"> <span class="Apple-converted-space"> </span></span></span><span class="m-7958132393732476812s1"><span style="color: rgb(0, 176, 80);">Jacobian is built using finite differences with coloring</span></span><o:p></o:p></p><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"> </span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Option 2:</span><span style="font-size: 12pt;"><o:p></o:p></span></div><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812s1">SNES Object: 1 MPI process</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">type: newtonls</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">maximum iterations=50, maximum function evaluations=10000</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">tolerances: relative=1e-08, absolute=1e-50, solution=1e-08</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">total number of linear solver iterations=8</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">total number of function evaluations=17</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"> <span class="Apple-converted-space"> </span></span><span class="m-7958132393732476812s1">norm schedule ALWAYS</span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"><span style="color: rgb(0, 176, 80);"> <span class="Apple-converted-space"> </span></span></span><span class="m-7958132393732476812s1"><span style="color: rgb(0, 176, 80);">Jacobian is applied matrix-free with differencing</span></span><o:p></o:p></p><p class="m-7958132393732476812p1" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span class="m-7958132393732476812apple-converted-space"><span style="color: rgb(0, 176, 80);"> <span class="Apple-converted-space"> </span></span></span><span class="m-7958132393732476812s1"><span style="color: rgb(0, 176, 80);">Preconditioning Jacobian is built using finite differences with coloring</span></span><o:p></o:p></p><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"> </span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"> </span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Does it mean that</span><span style="font-size: 12pt;"><o:p></o:p></span></div><ul type="disc" style="margin-bottom: 0in;"><li class="m-7958132393732476812msolistparagraph" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Option 1 uses Newton’s method, such that J du = b is solved with J being explicitly constructed?</span><o:p></o:p></li></ul></div></div></div></blockquote><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;">yes<o:p></o:p></span></div></div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;"> <o:p></o:p></span></div></div><blockquote style="border-width: medium medium medium 1pt; border-style: none none none solid; border-color: currentcolor currentcolor currentcolor rgb(204, 204, 204); border-image: none; padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;"><div><div><div><ul type="disc" style="margin-bottom: 0in;"><li class="m-7958132393732476812msolistparagraph" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><o:p> </o:p></li><li class="m-7958132393732476812msolistparagraph" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Option 2 uses matrix free method, such that J du = b is solved with  J v ~ (F(u + dv) – F(u)) / h when needed, e.g., in a Krylov method.</span><o:p></o:p></li></ul></div></div></div></blockquote><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;"><o:p> </o:p></span></div></div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;">yes, and the preconditioner is constructed using an explicitly constructed Jacobian matrix<o:p></o:p></span></div></div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;"> <o:p></o:p></span></div></div><blockquote style="border-width: medium medium medium 1pt; border-style: none none none solid; border-color: currentcolor currentcolor currentcolor rgb(204, 204, 204); border-image: none; padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;"><div><div><div><ul type="disc" style="margin-bottom: 0in;"><li class="m-7958132393732476812msolistparagraph" style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: Aptos, sans-serif;"><o:p> </o:p></li></ul><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"> </span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">Thanks,</span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;">-Ling</span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"> </span><span style="font-size: 12pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 11pt;"> </span><span style="font-size: 12pt;"><o:p></o:p></span></div></div></div></div></blockquote></div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;"><br clear="all"><o:p></o:p></span></div></div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;"><o:p> </o:p></span></div></div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span class="gmailsignatureprefix"><span style="font-size: 12pt;">--</span></span><span style="font-size: 12pt;"><o:p></o:p></span></div><div><div style="margin: 0in; font-size: 10pt; font-family: Aptos, sans-serif;"><span style="font-size: 12pt;">Stefano</span></div></div></div></div></div></div></div></div></blockquote></div><br></div></body></html>