#include "petscsnes.h" PetscErrorCode SNESGetIterationNumber(SNES snes,PetscInt *iter)Not Collective
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 ComputeJacobian() function to cause the Jacobian to be
recomputed every second SNES iteration.
After the SNES solve is complete this will return the number of nonlinear iterations used.