Skip to main content
`Ctrl`+`K`

# KSPConvergedReason

reason a Krylov method was determined to have converged or diverged

## Synopsis

    typedef enum { /* converged */
      KSP_CONVERGED_RTOL_NORMAL_DEPRECATED    = 1,
      KSP_CONVERGED_RTOL_NORMAL_EQUATIONS     = 1,
      KSP_CONVERGED_ATOL_NORMAL_DEPRECATED    = 9,
      KSP_CONVERGED_ATOL_NORMAL_EQUATIONS     = 9,
      KSP_CONVERGED_RTOL                      = 2,
      KSP_CONVERGED_ATOL                      = 3,
      KSP_CONVERGED_ITS                       = 4,
      KSP_CONVERGED_NEG_CURVE                 = 5,
      KSP_CONVERGED_CG_NEG_CURVE_DEPRECATED   = 5,
      KSP_CONVERGED_CG_CONSTRAINED_DEPRECATED = 6,
      KSP_CONVERGED_STEP_LENGTH               = 6,
      KSP_CONVERGED_HAPPY_BREAKDOWN           = 7,
      KSP_CONVERGED_USER                      = 8,
      /* diverged */
      KSP_DIVERGED_NULL                      = -2,
      KSP_DIVERGED_ITS                       = -3,
      KSP_DIVERGED_DTOL                      = -4,
      KSP_DIVERGED_BREAKDOWN                 = -5,
      KSP_DIVERGED_BREAKDOWN_BICG            = -6,
      KSP_DIVERGED_NONSYMMETRIC              = -7,
      KSP_DIVERGED_INDEFINITE_PC             = -8,
      KSP_DIVERGED_NANORINF                  = -9,
      KSP_DIVERGED_INDEFINITE_MAT            = -10,
      KSP_DIVERGED_PC_FAILED                 = -11,
      KSP_DIVERGED_PCSETUP_FAILED_DEPRECATED = -11,
      KSP_DIVERGED_USER                      = -12,

      KSP_CONVERGED_ITERATING = 0
    } KSPConvergedReason;

## Values

- `KSP_CONVERGED_RTOL_NORMAL_EQUATIONS` - requested decrease in the residual of the normal equations, for `KSPLSQR`

- `KSP_CONVERGED_ATOL_NORMAL_EQUATIONS` - requested absolute value in the residual of the normal equations, for `KSPLSQR`

- `KSP_CONVERGED_RTOL` - requested decrease in the residual

- `KSP_CONVERGED_ATOL` - requested absolute value in the residual

- `KSP_CONVERGED_ITS` - requested number of iterations

- `KSP_CONVERGED_NEG_CURVE` - see note below

- `KSP_CONVERGED_STEP_LENGTH` - see note below

- `KSP_CONVERGED_HAPPY_BREAKDOWN` - happy breakdown (meaning early convergence of the `KSPType` occurred).

- `KSP_CONVERGED_USER` - the user has indicated convergence for an arbitrary reason

- `KSP_DIVERGED_NULL` - breakdown when solving the Hessenberg system within `KSPGMRES`

- `KSP_DIVERGED_ITS` - requested number of iterations

- `KSP_DIVERGED_DTOL` - large increase in the residual norm indicating the solution is diverging

- `KSP_DIVERGED_BREAKDOWN` - breakdown in the Krylov method

- `KSP_DIVERGED_BREAKDOWN_BICG` - breakdown in the `KSPBCGS` Krylov method

- `KSP_DIVERGED_NONSYMMETRIC` - the operator or preonditioner was not symmetric for a `KSPType` that requires symmetry

- `KSP_DIVERGED_INDEFINITE_PC` - the preconditioner was indefinite for a `KSPType` that requires it be definite, such as `KSPCG`

- `KSP_DIVERGED_NANORINF` - a not a number of infinity was detected in a vector during the computation

- `KSP_DIVERGED_INDEFINITE_MAT` - the operator was indefinite for a `KSPType` that requires it be definite, such as `KSPCG`

- `KSP_DIVERGED_PC_FAILED` - the action of the preconditioner failed for some reason

- `KSP_DIVERGED_USER` - the user has indicated divergence for an arbitrary reason

## Note

The values `KSP_CONVERGED_NEG_CURVE`, and `KSP_CONVERGED_STEP_LENGTH` are returned only by `KSPCG`, `KSPMINRES` and by the special `KSPNASH`, `KSPSTCG`, and `KSPGLTR` solvers which are used by the `SNESNEWTONTR` (trust region) solver.

## Developer Note

The string versions of these are `KSPConvergedReasons`; if you change any of the values here also change them that array of names.

## See Also

KSP: Linear System Solvers, `KSP`, `KSPSolve()`, `KSPGetConvergedReason()`, `KSPSetTolerances()`, `KSPConvergedReasonView()`

## Level

beginner

## Location

include/petscksp.h

## Examples

src/ksp/ksp/tutorials/ex77.c

## Examples

src/ksp/ksp/tutorials/ex1f.F90
src/ksp/ksp/tutorials/ex59.c
src/ksp/ksp/tutorials/ex57f.F90
src/ksp/ksp/tutorials/ex76.c
src/dm/impls/stag/tutorials/ex4.c
src/ksp/ksp/tutorials/ex72.c
src/ksp/ksp/tutorials/ex77.c
src/dm/impls/stag/tutorials/ex8.c
src/ksp/ksp/tutorials/ex2f.F90
src/ksp/ksp/tutorials/ex87.c

Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages