SNESSetJacobian
Sets the function to compute Jacobian as well as the location to store the matrix.
Synopsis
#include "snes.h"
int SNESSetJacobian(SNES snes,Mat A,Mat B,int (*func)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *ctx)
Collective on SNES and Mat
Input Parameters
| snes | - the SNES context
|
| A | - Jacobian matrix
|
| B | - preconditioner matrix (usually same as the Jacobian)
|
| func | - Jacobian evaluation routine
|
| ctx | - [optional] user-defined context for private data for the
Jacobian evaluation routine (may be PETSC_NULL)
|
Calling sequence of func
func (SNES snes,Vec x,Mat *A,Mat *B,int *flag,void *ctx);
| x | - input vector
|
| A | - Jacobian matrix
|
| B | - preconditioner matrix, usually the same as A
|
| flag | - flag indicating information about the preconditioner matrix
structure (same as flag in SLESSetOperators())
|
| ctx | - [optional] user-defined Jacobian context
|
Notes
See SLESSetOperators() for important information about setting the flag
output parameter in the routine func(). Be sure to read this information!
The routine func() takes Mat * as the matrix arguments rather than Mat.
This allows the Jacobian evaluation routine to replace A and/or B with a
completely new new matrix structure (not just different matrix elements)
when appropriate, for instance, if the nonzero structure is changing
throughout the global iterations.
Keywords
SNES, nonlinear, set, Jacobian, matrix
See Also
SLESSetOperators(), SNESSetFunction()
Examples
src/snes/examples/tutorials/ex1f.F
src/snes/examples/tutorials/ex4f.F
src/snes/examples/tutorials/ex5f.F
src/snes/examples/tutorials/ex5f90.F
src/snes/examples/tutorials/ex4.c
src/snes/examples/tutorials/ex1.c
src/snes/examples/tutorials/ex2.c
src/snes/examples/tutorials/ex5.c
src/snes/examples/tutorials/ex3.c
src/snes/examples/tutorials/ex6.c
src/snes/examples/tutorials/ex12.c
src/snes/examples/tutorials/ex5s.c
src/snes/examples/tutorials/ex7.c
src/snes/examples/tutorials/ex8.c
src/snes/examples/tutorials/ex13.c
src/snes/examples/tutorials/ex9.c
src/snes/examples/tutorials/ex14.c
src/snes/examples/tutorials/ex15.c
src/snes/examples/tutorials/ex5c.c
src/snes/examples/tutorials/ex16.c
src/snes/examples/tutorials/ex5d.c
Level:beginner
Location:src/snes/interface/snes.c
SNES Index
Table of Contents