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

Smith, Barry F. bsmith at mcs.anl.gov
Wed Dec 12 17:41:46 CST 2018



> On Dec 12, 2018, at 5:39 PM, Fande Kong via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> 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.

   Yes, this functionality seems right, go ahead and make a pull request.

    Barry

> 
> Any suggestions are welcome.
> 
> Thanks,
> 
> Fande,
> 
> 



More information about the petsc-users mailing list