KSPConvergedDefault#
Determines convergence of the linear iterative solvers by default
Synopsis#
#include "petscksp.h"
PetscErrorCode KSPConvergedDefault(KSP ksp, PetscInt n, PetscReal rnorm, KSPConvergedReason *reason, void *ctx)
Collective on ksp
Input Parameters#
ksp - iterative context
n - iteration number
rnorm - residual norm (may be estimated, depending on the method may be the preconditioned residual norm)
ctx - convergence context which must be created by KSPConvergedDefaultCreate()
Output Parameter#
reason - the convergence reason; it is positive if the iteration has converged, negative if the iteration has diverged, and KSP_CONVERGED_ITERATING otherwise
Notes#
KSPConvergedDefault() reaches convergence when rnorm < MAX (rtol * rnorm_0, abstol); Divergence is detected if rnorm > dtol * rnorm_0, or when failures are detected throughout the iteration. By default, reaching the maximum number of iterations is considered divergence (i.e. KSP_DIVERGED_ITS). In order to have PETSc declaring convergence in such a case (i.e. KSP_CONVERGED_ITS), users can use KSPConvergedDefaultSetConvergedMaxits()
where#
rtol - relative tolerance,
abstol - absolute tolerance.
dtol - divergence tolerance,
rnorm_0 - the two norm of the right hand side (or the preconditioned norm, depending on what was set with KSPSetNormType(). When initial guess is non-zero you can call KSPConvergedDefaultSetUIRNorm() to use the norm of (b - A*(initial guess)) as the starting point for relative norm convergence testing, that is as rnorm_0
Use KSPSetTolerances() to alter the defaults for rtol, abstol, dtol.
Use KSPSetNormType() (or -ksp_norm_type <none,preconditioned,unpreconditioned,natural>) to change the norm used for computing rnorm
The precise values of reason are macros such as KSP_CONVERGED_RTOL, which are defined in petscksp.h.
This routine is used by KSP by default so the user generally never needs call it directly.
Use KSPSetConvergenceTest() to provide your own test instead of using this one.
See Also#
KSPSetConvergenceTest()
, KSPSetTolerances()
, KSPConvergedSkip()
, KSPConvergedReason
, KSPGetConvergedReason()
,
KSPConvergedDefaultSetUIRNorm()
, KSPConvergedDefaultSetUMIRNorm()
, KSPConvergedDefaultSetConvergedMaxits()
, KSPConvergedDefaultCreate()
, KSPConvergedDefaultDestroy()
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