#include "petscsnes.h" PetscErrorCode SNESSetJacobian(SNES snes,Mat Amat,Mat Pmat,PetscErrorCode (*SNESJacobianFunction)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *ctx)Logically Collective on SNES and Mat
snes | - the SNES context | |
Amat | - the matrix that defines the (approximate) Jacobian | |
Pmat | - the matrix to be used in constructing the preconditioner, usually the same as Amat. | |
SNESJacobianFunction | - Jacobian evaluation routine (if NULL then SNES retains any previously set value) | |
ctx | - [optional] user-defined context for private data for the Jacobian evaluation routine (may be NULL) (if NULL then SNES retains any previously set value) |
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.
If the Amat matrix and Pmat matrix are different you must call MatAssemblyBegin/End() on each matrix.
If using SNESComputeJacobianDefaultColor() to assemble a Jacobian, the ctx argument must be a MatFDColoring.
Other defect-correction schemes can be used by computing a different matrix in place of the Jacobian. One common example is to use the "Picard linearization" which only differentiates through the highest order parts of each term.
Level:beginner
Location:src/snes/interface/snes.c
Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages