# KSPDefaultConverged

Determines convergence of the iterative solvers (default code).

### Synopsis

    #include "petscksp.h"
    PetscErrorCode PETSCKSP_DLLEXPORT KSPDefaultConverged(KSP ksp,PetscInt n,PetscReal rnorm,KSPConvergedReason *reason,void *dummy)

Collective on KSP

### Input Parameters

| ksp | - iterative context
| n | - iteration number
| rnorm | - 2-norm residual value (may be estimated)
| dummy | - unused convergence context

### Returns

| positive | - if the iteration has converged;
| negative | - if residual norm exceeds divergence threshold;
| 0 | - otherwise.

### Notes

KSPDefaultConverged() reaches convergence when

         rnorm < MAX (rtol * rnorm_0, abstol);

Divergence is detected if

         rnorm > dtol * rnorm_0,

where

| rtol = relative tolerance, | - . abstol = absolute tolerance.
| dtol = divergence tolerance, | - - rnorm_0 is the two norm of the right hand side. When initial guess is non-zero you can call KSPDefaultConvergedSetUIRNorm() to use the norm of (b - A*(initial guess)) as the starting point for relative norm convergence testing.

Use KSPSetTolerances() to alter the defaults for rtol, abstol, dtol.

The precise values of reason are macros such as KSP_CONVERGED_RTOL, which are defined in petscksp.h.

### Keywords

KSP, default, convergence, residual

### See Also

KSPSetConvergenceTest(), KSPSetTolerances(), KSPSkipConverged(), KSPConvergedReason, KSPGetConvergedReason(),
KSPDefaultConvergedSetUIRNorm(), KSPDefaultConvergedSetUMIRNorm().

Level:intermediate
Location: src/ksp/ksp/interface/iterativ.c
Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages