# KSPGetConvergedReason

Gets the reason the KSP iteration was stopped.

### Synopsis

    #include "petscksp.h"
    PetscErrorCode PETSCKSP_DLLEXPORT KSPGetConvergedReason(KSP ksp,KSPConvergedReason *reason)

Not Collective

### Input Parameter

ksp -the KSP context

### Output Parameter

reason -negative value indicates diverged, positive value converged, see KSPConvergedReason

### Possible values for reason

| KSP_CONVERGED_RTOL (residual 2 | - norm decreased by a factor of rtol, from 2-norm of right hand side)
| KSP_CONVERGED_ATOL (residual 2 | - norm less than abstol)
| KSP_CONVERGED_ITS (used by the preonly preconditioner that always uses ONE iteration) | - . KSP_CONVERGED_QCG_NEG_CURVE
| KSP_CONVERGED_QCG_CONSTRAINED | - . KSP_CONVERGED_STEP_LENGTH
| KSP_DIVERGED_ITS (required more than its to reach convergence) | - . KSP_DIVERGED_DTOL (residual norm increased by a factor of divtol)
| KSP_DIVERGED_NAN (residual norm became Not | - a-number likely do to 0/0)
| KSP_DIVERGED_BREAKDOWN (generic breakdown in method) | - - KSP_DIVERGED_BREAKDOWN_BICG (Initial residual is orthogonal to preconditioned initial residual. Try a different preconditioner, or a different initial guess.)

Notes: Can only be called after the call the KSPSolve() is complete.

### Keywords

KSP, nonlinear, set, convergence, test

### See Also

KSPSetConvergenceTest(), KSPDefaultConverged(), KSPSetTolerances(), KSPConvergedReason

Level:beginner
Location:src/ksp/ksp/interface/iterativ.c
Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/pc/examples/tutorials/ex1.c.html
src/ksp/pc/examples/tutorials/ex2.c.html
src/ksp/ksp/examples/tutorials/ex10.c.html