petsc-3.12.5 2020-03-29
Report Typos and Errors

KSPSetConvergenceTest

Sets the function to be used to determine convergence.

Synopsis

#include "petscksp.h" 
PetscErrorCode  KSPSetConvergenceTest(KSP ksp,PetscErrorCode (*converge)(KSP,PetscInt,PetscReal,KSPConvergedReason*,void*),void *cctx,PetscErrorCode (*destroy)(void*))
Logically Collective on ksp

Input Parameters

ksp - iterative context obtained from KSPCreate()
converge - pointer to the function
cctx - context for private data for the convergence routine (may be null)
destroy - a routine for destroying the context (may be null)

Calling sequence of converge

    converge (KSP ksp, PetscInt it, PetscReal rnorm, KSPConvergedReason *reason,void *mctx)

ksp - iterative context obtained from KSPCreate()
it - iteration number
rnorm - (estimated) 2-norm of (preconditioned) residual
reason - the reason why it has converged or diverged
cctx - optional convergence context, as set by KSPSetConvergenceTest()

Notes

Must be called after the KSP type has been set so put this after a call to KSPSetType(), or KSPSetFromOptions().

The default convergence test, KSPConvergedDefault(), aborts if the residual grows to more than 10000 times the initial residual.

The default is a combination of relative and absolute tolerances. The residual value that is tested may be an approximation; routines that need exact values should compute them.

In the default PETSc convergence test, the precise values of reason are macros such as KSP_CONVERGED_RTOL, which are defined in petscksp.h.

See Also

KSPConvergedDefault(), KSPGetConvergenceContext(), KSPSetTolerances(), KSP, KSPGetConvergenceTest(), KSPGetAndClearConvergenceTest()

Level

advanced

Location

src/ksp/ksp/interface/itfunc.c

Examples

src/ksp/ksp/examples/tutorials/ex71.c.html
src/ksp/ksp/examples/tutorials/ex2f.F90.html

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