KSPSetMonitor

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

Synopsis

int KSPSetMonitor(KSP ksp, int (*monitor)(KSP,int,double,void*), void *mctx)
Collective on KSP

Input Parameters

ksp - iterative context obtained from KSPCreate()
monitor - pointer to function (if this is PETSC_NULL, it turns off monitoring
mctx - [optional] context for private data for the monitor routine (use PETSC_NULL if no context is desired)

Calling Sequence of monitor

    monitor (KSP ksp, int it, double rnorm, void *mctx)

ksp - iterative context obtained from KSPCreate()
it - iteration number
rnorm - (estimated) 2-norm of (preconditioned) residual
mctx - optional monitoring context, as set by KSPSetMonitor()

Options Database Keys

-ksp_monitor - sets KSPDefaultMonitor()
-ksp_truemonitor - sets KSPTrueMonitor()
-ksp_xmonitor - sets line graph monitor, uses KSPLGMonitorCreate()
-ksp_xtruemonitor - sets line graph monitor, uses KSPLGMonitorCreate()
-ksp_singmonitor - sets KSPSingularValueMonitor()
-ksp_bsmonitor - sets BlockSolve95 monitor that prints both scaled and unscaled residual norms
-ksp_cancelmonitors - cancels all monitors that have been hardwired into a code by calls to KSPSetMonitor(), but does not cancel those set via the options database.

Notes

The default is to do nothing. To print the residual, or preconditionedresidual if KSPSetUsePreconditionedResidual() was called, useKSPDefaultMonitor() as the monitoring routine, with a null monitoringcontext.

Several different monitoring routines may be set by callingKSPSetMonitor() multiple times; all will be called in theorder in which they were set.

Keywords

KSP, set, monitor

See Also

KSPDefaultMonitor(), KSPLGMonitorCreate(), KSPClearMonitor()

Examples

src/sles/examples/tutorials/ex6f.F
src/sles/examples/tutorials/ex2f.F
src/sles/examples/tutorials/ex9.c

Location: src/ksp/interface/itfunc.c
KSP Index
Table of Contents