KSPMonitorSet#
Sets an ADDITIONAL function to be called at every iteration to monitor, i.e. display in some way, perhaps by printing in the terminal, the residual norm computed in a KSPSolve()
Synopsis#
#include "petscksp.h"
#include "petscmat.h"
PetscErrorCode KSPMonitorSet(KSP ksp, KSPMonitorFn *monitor, void *ctx, PetscCtxDestroyFn *monitordestroy)
Logically Collective
Input Parameters#
ksp - iterative solver obtained from
KSPCreate()
monitor - pointer to function (if this is
NULL
, it turns off monitoring, seeKSPMonitorFn
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
), seePetscCtxDestroyFn
for the calling sequence
Options Database Keys#
-ksp_monitor - sets
KSPMonitorResidual()
-ksp_monitor draw - sets
KSPMonitorResidualDraw()
and plots residual-ksp_monitor draw::draw_lg - sets
KSPMonitorResidualDrawLG()
and plots residual-ksp_monitor_pause_final - Pauses any graphics when the solve finishes (only works for internal monitors)
-ksp_monitor_true_residual - sets
KSPMonitorTrueResidual()
-ksp_monitor_true_residual draw::draw_lg - sets
KSPMonitorTrueResidualDrawLG()
and plots residual-ksp_monitor_max - sets
KSPMonitorTrueResidualMax()
-ksp_monitor_singular_value - sets
KSPMonitorSingularValue()
-ksp_monitor_cancel - cancels all monitors that have been hardwired into a code by calls to
KSPMonitorSet()
, but does not cancel those set via the options database.
Notes#
The options database option -ksp_monitor
and related options are the easiest way to turn on KSP
iteration monitoring
KSPMonitorRegister()
provides a way to associate an options database key with KSP
monitor function.
The default is to do no monitoring. 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; they 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()
, KSPMonitorRegister()
, KSPMonitorCancel()
, KSP
, PetscCtxDestroyFn
Level#
beginner
Location#
Examples#
src/ts/tutorials/ex47.c
src/snes/tutorials/ex30.c
src/ksp/ksp/tutorials/ex42.c
src/ksp/ksp/tutorials/ex2f.F90
src/ksp/ksp/tutorials/ex9.c
Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages