SNESGetIterationNumber#
Gets the number of nonlinear iterations completed in the current or most recent SNESSolve()
Synopsis#
#include "petscsnes.h"
PetscErrorCode SNESGetIterationNumber(SNES snes, PetscInt *iter)
Not Collective
Input Parameter#
snes -
SNES
context
Output Parameter#
iter - iteration number
Notes#
For example, during the computation of iteration 2 this would return 1.
This is useful for using lagged Jacobians (where one does not recompute the
Jacobian at each SNES
iteration). For example, the code
ierr = SNESGetIterationNumber(snes,&it);
if (!(it % 2)) {
[compute Jacobian here]
}
can be used in your function that computes the Jacobian to cause the Jacobian to be
recomputed every second SNES
iteration. See also SNESSetLagJacobian()
After the SNES
solve is complete this will return the number of nonlinear iterations used.
See Also#
SNES: Nonlinear Solvers, SNES
, SNESSolve()
, SNESSetLagJacobian()
, SNESGetLinearSolveIterations()
, SNESSetMonitor()
Level#
intermediate
Location#
Examples#
src/snes/tutorials/ex48.c
src/snes/tutorials/ex59.c
src/snes/tutorials/ex35.c
src/snes/tutorials/ex55.c
src/ts/tutorials/ex30.c
src/snes/tutorials/ex77.c
src/snes/tutorials/ex5.c
src/ts/tutorials/ex24.c
src/ts/tutorials/ex14.c
src/snes/tutorials/ex2.c
Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages