petsc-3.7.1 2016-05-15
Report Typos and Errors

# SNESGetIterationNumber

Gets the number of nonlinear iterations completed at this time.

### Synopsis

    #include "petscsnes.h"
    PetscErrorCode  SNESGetIterationNumber(SNES snes,PetscInt *iter)

Not Collective Many br

### Input Parameter

snes -SNES context Many br

### Output Parameter

iter -iteration number Many br

### Notes

For example, during the computation of iteration 2 this would return 1. Many br

This is useful for using lagged Jacobians (where one does not recompute the Many brJacobian at each SNES iteration). For example, the code Many br

          ierr = SNESGetIterationNumber(snes,&it);
          if (!(it % 2)) {
            [compute Jacobian here]
          }

Many brcan be used in your ComputeJacobian() function to cause the Jacobian to be Many brrecomputed every second SNES iteration. Many br

Many br

### Keywords

SNES, nonlinear, get, iteration, number,

### See Also

SNESGetLinearSolveIterations()

Level:intermediate
Location:src/snes/interface/snes.c
Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/snes/examples/tutorials/ex1.c.html
src/snes/examples/tutorials/ex2.c.html
src/snes/examples/tutorials/ex3.c.html
src/snes/examples/tutorials/ex5.c.html
src/snes/examples/tutorials/ex5s.c.html
src/snes/examples/tutorials/ex7.c.html
src/snes/examples/tutorials/ex12.c.html
src/snes/examples/tutorials/ex14.c.html
src/snes/examples/tutorials/ex15.c.html
src/snes/examples/tutorials/ex18.c.html
src/snes/examples/tutorials/ex19.c.html