<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div>  Yikes, bug-city. I'll send you a fix shortly.<div class=""><br class=""></div><div class="">  Barry</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Apr 7, 2022, at 11:21 AM, Alfredo J Duarte Gomez <<a href="mailto:aduarteg@utexas.edu" class="">aduarteg@utexas.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hello Barry,</div><div class=""><br class=""></div><div class="">Thank you for the clarification, the petsc user manual does list <code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre">snes_mf_type</span> <span class="gmail-pre"><default</span> <span class="gmail-pre">or</span> <span class="gmail-pre">wp> <font face="arial,sans-serif" class="">as the options so I was confused.</font></span></code></div><div class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class=""><br class=""></font></span></code></div><div class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class="">I believe the function accuracy is fine, but I would like to experiment with other "h" routines to see if I can get some improvement for small time steps. However, i am still having  trouble switching that routine at least from what I see from the message I described in my previous email. I tried out <code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre">-snes_mf_type dp, <font face="arial,sans-serif" class="">but it did not change the output.</font></span></code></font></span></code></div><div class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class=""><br class=""></font></span></code></font></span></code></div><div class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class="">I am currently only calling SNESSetFromOptions() on my snes object, which I assumed would handle the -snes_mf_type option. Do I need to get the Jacobian from the snes and then call a MatSetFromOptions() on my matrix-free jacobian to use this option?</font></span></code></font></span></code></div><div class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class=""><br class=""></font></span></code></font></span></code></div><div class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class="">Thank you,</font></span></code></font></span></code></div><div class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class=""><br class=""></font></span></code></font></span></code></div><div class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class=""><code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre"><font face="arial,sans-serif" class="">-Alfredo </font><br class=""></span></code></font></span></code></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 6, 2022 at 6:35 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class=""><br class=""><div class=""><div class="">I notice that this part of the message does not change even when I specify "-snes_mf_type default" (which is the alternative to wp), so I am a bit confused on how I interact to the -snes_mf_type or if I am interpreting the message wrong. Could you clarify this?</div><div class=""><br class=""></div><div class="">  Hmm, the two possibilities are -snes_mf_type wp or ds. I would expect an error message if you passed default.</div><div class=""><br class=""></div><div class=""> Regarding selecting the </div><div class=""><br class=""></div><div class="">   err=1.49012e-08 (relative error in function evaluation)</div><div class=""><br class=""></div><div class="">this number should be the square root of the expected error in the function evaluation. So for double-precision numbers and a function evaluation with no noise (so computed accurately to double precision) the tolerance is the square root of the machine epsilon. </div><div class=""><br class=""></div><div class="">You should only change this number (make it bigger) if you know that your function evaluations are not fully accurate. For example, if you know your function evaluation is only accurate to 10 decimal digits you could use an err of 1e-5. </div><div class=""><br class=""></div><div class="">But if your function evaluations are accurate to double precision then changing this number is unlikely to help anything.</div><div class=""><br class=""></div><div class="">  Barry</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><blockquote type="cite" class=""><div class="">On Apr 6, 2022, at 3:13 PM, Alfredo J Duarte Gomez <<a href="mailto:aduarteg@utexas.edu" target="_blank" class="">aduarteg@utexas.edu</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class="">Good afternoon petsc team, <div class=""><br class=""></div><div class="">I have a few questions regarding the matrixfree in the snes context.</div><div class=""><br class=""></div><div class="">I am currently using the matrix-free method with my own preconditioner to solve a TS problem. I currently trigger this with the -snes_mf_operator option.</div><div class=""><br class=""></div><div class="">So far the default values have been working great, but I ran into trouble during a convergence study when I made the time step very small, which I suspect is probably happening because it's dropping below the matrix-vector product tolerance.</div><div class=""><br class=""></div><div class="">I wanted to explore the parameters of the matrix-vector product but using the -snes_view option I notice that the following full message comes out:</div><div class=""><br class=""></div><div class="">-----------------------------------------------------------------------------------</div><div class=""><div class="">SNES Object: 96 MPI processes</div><div class="">  type: newtonls</div><div class="">  maximum iterations=20, maximum function evaluations=10000</div><div class="">  tolerances: relative=1e-06, absolute=1e-06, solution=1e-15</div><div class="">  total number of linear solver iterations=14</div><div class="">  total number of function evaluations=35</div><div class="">  norm schedule ALWAYS</div><div class="">  Jacobian is never rebuilt</div><div class="">  Jacobian is applied matrix-free with differencing</div><div class="">  Jacobian is applied matrix-free with differencing, no explict Jacobian</div><div class="">  SNESLineSearch Object: 96 MPI processes</div><div class="">    type: l2</div><div class="">    maxstep=1.000000e+08, minlambda=1.000000e-12</div><div class="">    tolerances: relative=1.000000e-08, absolute=1.000000e-15, lambda=1.000000e-08</div><div class="">    maximum iterations=1</div><div class="">  KSP Object: 96 MPI processes</div><div class="">    type: gmres</div><div class="">      restart=100, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement</div><div class="">      happy breakdown tolerance 1e-30</div><div class="">    maximum iterations=400, initial guess is zero</div><div class="">    tolerances:  relative=0.01, absolute=1e-50, divergence=10000.</div><div class="">    left preconditioning</div><div class="">    using PRECONDITIONED norm type for convergence test</div><div class="">  PC Object: 96 MPI processes</div><div class="">    type: shell</div><div class="">      MyPreconditioner</div><div class="">    linear system matrix followed by preconditioner matrix:</div><div class="">    Mat Object: 96 MPI processes</div><div class="">      type: mffd</div><div class="">      rows=8400000, cols=8400000</div><div class="">        Matrix-free approximation:</div><div class="">          err=1.49012e-08 (relative error in function evaluation)</div><div class="">          Using wp compute h routine</div><div class="">              Does not compute normU</div><div class="">    Mat Object: 96 MPI processes</div><div class="">      type: mpiaij</div><div class="">      rows=8400000, cols=8400000, bs=4</div><div class="">      total: nonzeros=2041029504, allocated nonzeros=2041029504</div><div class="">      total number of mallocs used during MatSetValues calls=0</div></div><div class="">--------------------------------------------------------------------------------</div><div class=""><br class=""></div><div class="">I have been focusing specifically on the part:</div><div class=""><br class=""></div><div class=""><div class="">        Matrix-free approximation:</div><div class="">          err=1.49012e-08 (relative error in function evaluation)</div><div class="">          Using wp compute h routine</div><div class="">              Does not compute normU</div></div><div class=""><br class=""></div><div class="">I notice that this part of the message does not change even when I specify "-snes_mf_type default" (which is the alternative to wp), so I am a bit confused on how I interact to the -snes_mf_type or if I am interpreting the message wrong. Could you clarify this?</div><div class=""><br class=""></div><div class="">Also let me know if you have any general suggestions on tightening the tolerance of the matricxvector products.</div><div class=""><br class=""></div><div class="">Thank you,</div><div class=""><br class=""></div><div class="">-Alfredo  </div><div class=""><br class=""></div><div class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><font face="arial, sans-serif" class="">Alfredo Duarte</font><div class=""><font face="arial, sans-serif" class="">Graduate Research Assistant</font></div><div class=""><font face="arial, sans-serif" class="">The University of Texas at Austin</font></div></div></div></div></div></div></div></div></div>
</div></blockquote></div><br class=""></div></blockquote></div><br clear="all" class=""><br class="">-- <br class=""><div dir="ltr" class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><font face="arial, sans-serif" class="">Alfredo Duarte</font><div class=""><font face="arial, sans-serif" class="">Graduate Research Assistant</font></div><div class=""><font face="arial, sans-serif" class="">The University of Texas at Austin</font></div></div></div></div></div>
</div></blockquote></div><br class=""></div></body></html>