Skip to main content
`Ctrl`+`K`

# SNESSetConvergenceTest

Sets the function that is to be used to test for convergence of the nonlinear iterative solution.

## Synopsis

    #include "petscsnes.h"
    #include "petscsnes.h"
    PetscErrorCode SNESSetConvergenceTest(SNES snes, PetscErrorCode (*func)(SNES snes, PetscInt it, PetscReal xnorm, PetscReal snorm, PetscReal fnorm, SNESConvergedReason *reason, PetscCtx ctx), PetscCtx ctx, PetscCtxDestroyFn *destroy)

Logically Collective

## Input Parameters

- snes - the `SNES` context

- func - routine to test for convergence

- ctx - [optional] context for private data for the convergence routine (may be `NULL`)

- destroy - [optional] destructor for the context (may be `NULL`; `PETSC_NULL_FUNCTION` in Fortran)

## Calling sequence of func

- snes - the `SNES` context

- it - the current iteration number

- xnorm - the norm of the new solution

- snorm - the norm of the step

- fnorm - the norm of the function value

- reason - output, the reason convergence or divergence as declared

- ctx - the optional convergence test context

## See Also

SNES: Nonlinear Solvers, `SNES`, `SNESConvergedDefault()`, `SNESConvergedSkip()`

## Level

advanced

## Location

src/snes/interface/snes.c

## Examples

src/snes/tutorials/ex30.c
src/snes/tutorials/ex69.c

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