KSPMonitorSet#

Sets an ADDITIONAL function to be called at every iteration to monitor the residual/error etc.

Synopsis#

#include "petscksp.h" 
#include "petscmat.h" 
PetscErrorCode KSPMonitorSet(KSP ksp, PetscErrorCode (*monitor)(KSP ksp, PetscInt it, PetscReal rnorm, void *ctx), void *ctx, PetscCtxDestroyFn *monitordestroy)

Logically Collective

Input Parameters#

  • ksp - iterative context obtained from KSPCreate()

  • monitor - pointer to function (if this is NULL, it turns off monitoring

  • ctx - [optional] context for private data for the monitor routine (use NULL if no context is needed)

  • monitordestroy - [optional] routine that frees monitor context (may be NULL), see PetscCtxDestroyFn for the calling sequence

Calling sequence of monitor#

  • ksp - iterative context obtained from KSPCreate()

  • it - iteration number

  • rnorm - (estimated) 2-norm of (preconditioned) residual

  • ctx - optional monitoring context, as set by KSPMonitorSet()

Options Database Keys#

Notes#

The default is to do nothing. To print the residual, or preconditioned residual if KSPSetNormType(ksp,KSP_NORM_PRECONDITIONED) was called, use KSPMonitorResidual() as the monitoring routine, with a PETSCVIEWERASCII as the context.

Several different monitoring routines may be set by calling KSPMonitorSet() multiple times; all will be called in the order in which they were set.

Fortran Note#

Only a single monitor function can be set for each KSP object

See Also#

KSP: Linear System Solvers, KSPMonitorResidual(), KSPMonitorCancel(), KSP, PetscCtxDestroyFn

Level#

beginner

Location#

src/ksp/ksp/interface/itfunc.c

Examples#

src/ksp/ksp/tutorials/ex2f.F90
src/ts/tutorials/ex47.c
src/snes/tutorials/ex30.c
src/ksp/ksp/tutorials/ex9.c
src/ksp/ksp/tutorials/ex42.c


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