[petsc-users] Stop KSP if diverging

Smith, Barry F. bsmith at mcs.anl.gov
Wed May 29 13:22:26 CDT 2019


   Hmm, in the lastest couple of releases of PETSc the KSPSolve is suppose to end as soon as it hits a NaN or Infinity. Is that not happening for you? If you run with -ksp_monitor does it print multiple lines with Nan or Inf? If so please send use the -ksp_view output so we can track down which solver is not correctly handling the Nan or Info.

  That said if you call KSPSolve() multiple times in a loop or from SNESSolve() each new solve may have Nan or Inf (from the previous) but it should only do one iteration before exiting.

   You should always call KSPGetConvergedReason() after KSPSolve() and confirm that the reason is positive, if it is native it indicates something failed in the solve.

   Barry


> On May 29, 2019, at 2:06 AM, Edoardo alinovi via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Dear PETSc friends,
> 
> Hope you are doing all well.
> 
> I have a quick question for you that I am not able to solve by my self. Time to time, while testing new code features, it happens that KSP diverges but it does not stop automatically and the iterations continue even after getting a NaN. 
> 
> In the KSP setup I use the following instruction to set the divergence stopping criteria (div = 10000):
> 
> call KSPSetTolerances(myksp,  rel_tol,  abs_tol, div,  itmax,  ierr)
> 
> But is does not help. Looking into the documentation I have found also:
> KSPConvergedDefault(KSP ksp,PetscInt n,PetscReal rnorm,KSPConvergedReason *reason,void *ctx)
> Which I am not calling in the code. Is this maybe the reason of my problem? If yes how can I use KSPConvergedDefault in FORTRAN? 
> 
> Thanks,
> 
> Edo
> 
> ------
> 
> Edoardo Alinovi, Ph.D.
> 
> DICCA, Scuola Politecnica,
> Universita' degli Studi di Genova,
> 1, via Montallegro,
> 16145 Genova, Italy
> 
> Email: edoardo.alinovi at dicca.unige.it
> Tel: +39 010 353 2540
> Website: https://www.edoardoalinovi.com/
> 
> 



More information about the petsc-users mailing list