1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML3.2 EN">
<HTML>
<HEAD> <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetJacobian.html" />
<META NAME="GENERATOR" CONTENT="DOCTEXT">
<TITLE>SNESSetJacobian</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<div id="version" align=right><b>petsc-3.7.5 2017-01-01</b></div>
<div id="bugreport" align=right><a href="mailto:petsc-maint@mcs.anl.gov?subject=Typo or Error in Documentation &body=Please describe the typo or error in the documentation: petsc-3.7.5 v3.7.5 docs/manualpages/SNES/SNESSetJacobian.html "><small>Report Typos and Errors</small></a></div>
<A NAME="SNESSetJacobian"><H1>SNESSetJacobian</H1></A>
Sets the function to compute Jacobian as well as the location to store the matrix.
<H3><FONT COLOR="#CC3333">Synopsis</FONT></H3>
<PRE>
#include "petscsnes.h"
PetscErrorCode SNESSetJacobian(SNES snes,Mat Amat,Mat Pmat,PetscErrorCode (*J)(SNES,Vec,Mat,Mat,void*),void *ctx)
</PRE>
Logically Collective on <A HREF="../SNES/SNES.html#SNES">SNES</A> and <A HREF="../Mat/Mat.html#Mat">Mat</A>
<P>
<H3><FONT COLOR="#CC3333">Input Parameters</FONT></H3>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>snes </B></TD><TD>- the <A HREF="../SNES/SNES.html#SNES">SNES</A> context
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>Amat </B></TD><TD>- the matrix that defines the (approximate) Jacobian
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>Pmat </B></TD><TD>- the matrix to be used in constructing the preconditioner, usually the same as Amat.
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>J </B></TD><TD>- Jacobian evaluation routine (if NULL then <A HREF="../SNES/SNES.html#SNES">SNES</A> retains any previously set value), see <A HREF="../SNES/SNESJacobianFunction.html#SNESJacobianFunction">SNESJacobianFunction</A> for details
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ctx </B></TD><TD>- [optional] user-defined context for private data for the
Jacobian evaluation routine (may be NULL) (if NULL then <A HREF="../SNES/SNES.html#SNES">SNES</A> retains any previously set value)
</TD></TR></TABLE>
<P>
<H3><FONT COLOR="#CC3333">Notes</FONT></H3>
If the Amat matrix and Pmat matrix are different you must call <A HREF="../Mat/MatAssemblyBegin.html#MatAssemblyBegin">MatAssemblyBegin</A>/End() on
each matrix.
<P>
If you know the operator Amat has a null space you can use <A HREF="../Mat/MatSetNullSpace.html#MatSetNullSpace">MatSetNullSpace</A>() and <A HREF="../Mat/MatSetTransposeNullSpace.html#MatSetTransposeNullSpace">MatSetTransposeNullSpace</A>() to supply the null
space to Amat and the <A HREF="../KSP/KSP.html#KSP">KSP</A> solvers will automatically use that null space as needed during the solution process.
<P>
If using <A HREF="../SNES/SNESComputeJacobianDefaultColor.html#SNESComputeJacobianDefaultColor">SNESComputeJacobianDefaultColor</A>() to assemble a Jacobian, the ctx argument
must be a <A HREF="../Mat/MatFDColoring.html#MatFDColoring">MatFDColoring</A>.
<P>
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.
<P>
<P>
<H3><FONT COLOR="#CC3333">Keywords</FONT></H3>
<A HREF="../SNES/SNES.html#SNES">SNES</A>, nonlinear, set, Jacobian, matrix
<BR>
<P>
<H3><FONT COLOR="#CC3333">See Also</FONT></H3>
<A HREF="../KSP/KSPSetOperators.html#KSPSetOperators">KSPSetOperators</A>(), <A HREF="../SNES/SNESSetFunction.html#SNESSetFunction">SNESSetFunction</A>(), <A HREF="../SNES/MatMFFDComputeJacobian.html#MatMFFDComputeJacobian">MatMFFDComputeJacobian</A>(), <A HREF="../SNES/SNESComputeJacobianDefaultColor.html#SNESComputeJacobianDefaultColor">SNESComputeJacobianDefaultColor</A>(), <A HREF="../Mat/MatStructure.html#MatStructure">MatStructure</A>, J,
<BR><A HREF="../SNES/SNESSetPicard.html#SNESSetPicard">SNESSetPicard</A>(), <A HREF="../SNES/SNESJacobianFunction.html#SNESJacobianFunction">SNESJacobianFunction</A>
<P><B><P><B><FONT COLOR="#CC3333">Level:</FONT></B>beginner
<BR><FONT COLOR="#CC3333">Location:</FONT></B><A HREF="../../../src/snes/interface/snes.c.html#SNESSetJacobian">src/snes/interface/snes.c</A>
<BR><A HREF="./index.html">Index of all SNES routines</A>
<BR><A HREF="../../index.html">Table of Contents for all manual pages</A>
<BR><A HREF="../singleindex.html">Index of all manual pages</A>
<P><H3><FONT COLOR="#CC3333">Examples</FONT></H3>
<A HREF="../../../src/snes/examples/tutorials/ex1.c.html">src/snes/examples/tutorials/ex1.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex2.c.html">src/snes/examples/tutorials/ex2.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex3.c.html">src/snes/examples/tutorials/ex3.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex5s.c.html">src/snes/examples/tutorials/ex5s.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex12.c.html">src/snes/examples/tutorials/ex12.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex14.c.html">src/snes/examples/tutorials/ex14.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex15.c.html">src/snes/examples/tutorials/ex15.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex18.c.html">src/snes/examples/tutorials/ex18.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex20.c.html">src/snes/examples/tutorials/ex20.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex22.c.html">src/snes/examples/tutorials/ex22.c.html</A><BR>
<A HREF="../../../src/snes/examples/tutorials/ex28.c.html">src/snes/examples/tutorials/ex28.c.html</A><BR>
</BODY></HTML>
|