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 73 74 75 76
|
<!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.4.2 2013-07-02</b></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 (*SNESJacobianFunction)(SNES,Vec,Mat*,Mat*,MatStructure*,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><A HREF="../SNES/SNESJacobianFunction.html#SNESJacobianFunction">SNESJacobianFunction</A> </B></TD><TD>- Jacobian evaluation routine (if NULL then <A HREF="../SNES/SNES.html#SNES">SNES</A> retains any previously set value)
</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>
See <A HREF="../KSP/KSPSetOperators.html#KSPSetOperators">KSPSetOperators</A>() for important information about setting the flag
output parameter in the routine func(). Be sure to read this information!
<P>
The routine func() takes <A HREF="../Mat/Mat.html#Mat">Mat</A> * as the matrix arguments rather than <A HREF="../Mat/Mat.html#Mat">Mat</A>.
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.
<P>
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 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>, <A HREF="../SNES/SNESJacobianFunction.html#SNESJacobianFunction">SNESJacobianFunction</A>, <A HREF="../SNES/SNESSetPicard.html#SNESSetPicard">SNESSetPicard</A>()
<BR><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/ex10.c.html">src/snes/examples/tutorials/ex10.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>
</BODY></HTML>
|