Skip to main content
`Ctrl`+`K`

# SNESGetConvergedReason

Gets the reason the `SNES` iteration was stopped, which may be due to convergence, divergence, or stagnation

## Synopsis

    #include "petscsnes.h"
    PetscErrorCode SNESGetConvergedReason(SNES snes, SNESConvergedReason *reason)

Not Collective

## Input Parameter

- snes - the `SNES` context

## Output Parameter

- reason - negative value indicates diverged, positive value converged, see `SNESConvergedReason` for the individual convergence tests for complete lists

## Options Database Key

- -snes_converged_reason - prints the reason to standard out

## Note

Should only be called after the call the `SNESSolve()` is complete, if it is called earlier it returns the value `SNES__CONVERGED_ITERATING`.

## See Also

SNES: Nonlinear Solvers, `SNESSolve()`, `SNESSetConvergenceTest()`, `SNESSetConvergedReason()`, `SNESConvergedReason`, `SNESGetConvergedReasonString()`

## Level

intermediate

## Location

src/snes/interface/snes.c

## Examples

src/snes/tutorials/ex6.c
src/snes/tutorials/ex15.c
src/snes/tutorials/ex42.c
src/ts/tutorials/ex14.c
src/ts/tutorials/ex48.c
src/snes/tutorials/ex2.c
src/snes/tutorials/ex48.c
src/snes/tutorials/ex30.c

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