Skip to main content
`Ctrl`+`K`

# KSPGetConvergedReason

Gets the reason the `KSP` iteration was stopped.

## Synopsis

    #include "petscksp.h"
    PetscErrorCode 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` for the possible values

## Options Database Key

- -ksp_converged_reason - prints the reason to standard out when the solve ends

## Note

If this routine is called before or doing the `KSPSolve()` the value of `KSP_CONVERGED_ITERATING` is returned

## See Also

KSP: Linear System Solvers, `KSPConvergedReason`, `KSP`, `KSPSetConvergenceTest()`, `KSPConvergedDefault()`, `KSPSetTolerances()`, `KSPConvergedReasonView()`, `KSPGetConvergedReasonString()`

## Level

intermediate

## Location

src/ksp/ksp/interface/iterativ.c

## Examples

src/ksp/ksp/tutorials/ex59.c
src/dm/impls/stag/tutorials/ex4.c
src/ksp/ksp/tutorials/ex72.c
src/ksp/ksp/tutorials/ex77.c
src/ksp/ksp/tutorials/ex87.c
src/ksp/ksp/tutorials/ex76.c
src/ksp/pc/tutorials/ex2.c
src/snes/tutorials/ex6.c
src/ksp/pc/tutorials/ex1.c
src/dm/impls/stag/tutorials/ex8.c

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