Skip to main content
`Ctrl`+`K`

# SNESSetErrorIfNotConverged

Causes `SNESSolve()` to generate an error immediately if the solver has not converged.

## Synopsis

    #include "petscsnes.h"
    #include "petscsnes.h"
    PetscErrorCode SNESSetErrorIfNotConverged(SNES snes, PetscBool flg)

Logically Collective

## Input Parameters

- snes - iterative context obtained from `SNESCreate()`

- flg - `PETSC_TRUE` indicates you want the error generated

## Options Database Key

- -snes_error_if_not_converged (true|false) - cause an immediate error condition and stop the program if the solver does not converge

## Note

Normally PETSc continues if a solver fails to converge, you can call `SNESGetConvergedReason()` after a `SNESSolve()` to determine if it has converged. Otherwise the solution may be inaccurate or wrong

## See Also

SNES: Nonlinear Solvers, `SNES`, `SNESGetErrorIfNotConverged()`, `KSPGetErrorIfNotConverged()`, `KSPSetErrorIfNotConverged()`

## Level

intermediate

## Location

src/snes/interface/snes.c

## Examples

src/ts/tutorials/ex30.c

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