<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi PETSc Developers,<div><br></div><div>If we hit some exceptions in function evaluations, we will try to call SNESSetFunctionDomainError(), and then PETSc will gently  ``stop" with  SNES_DIVERGED_FNORM_NAN. After PETSc stops, we can cut time steps or do other things, and then call SNESSolve again. This works pretty well for us. </div><div><br></div><div>However, the same thing does not work in Jacobian evaluations. PETSc always calls KSPSolve regardless of SNESDomainError after Jacobian evaluations. If we have an exception during Jacobian evaluations, we also want to stop immediately instead of KSPSolve. KSPSolve can be expensive and not necessary. Sometimes, the matrix is not properly setup because we are in middle of Jacobian evaluations, and some preconditioners will error out and the whole simulation crashes. </div><div><br></div><div>After exploring PETSc source code a little bit with a MOOSE team member, Alex,  it looks like it might be possible to stop Newton (we use NEWTONLS for 99.9% of our simulations) immediately right before a KSPSolve is called.  We could contribute a PR if you think it is reasonable.</div><div><br></div><div>Any suggestions are welcome.</div><div><br></div><div>Thanks,</div><div><br></div><div>Fande,</div><div><br></div><div><br></div></div></div></div></div></div>