[petsc-users] Check snes->domainerror for SNESComputeJacobian?

Fande Kong fdkong.jd at gmail.com
Wed Dec 12 17:39:34 CST 2018


Hi PETSc Developers,

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.

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.

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.

Any suggestions are welcome.

Thanks,

Fande,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181212/9c76e019/attachment.html>


More information about the petsc-users mailing list