<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=GB2312" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16535"><LINK rel=stylesheet 
href="BLOCKQUOTE{margin-Top: 0px; margin-Bottom: 0px; margin-Left: 2em}">
<META name=GENERATOR content="MSHTML 8.00.7600.16535">
<STYLE>@font-face {
        font-family: 宋体;
}
@font-face {
        font-family: Verdana;
}
@font-face {
        font-family: @宋体;
}
@page Section1 {size: 595.3pt 841.9pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; layout-grid: 15.6pt; }
P.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
LI.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
DIV.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
        FONT-STYLE: normal; FONT-FAMILY: Verdana; COLOR: windowtext; FONT-WEIGHT: normal; TEXT-DECORATION: none; mso-style-type: personal-compose
}
DIV.Section1 {
        page: Section1
}
UNKNOWN {
        FONT-SIZE: 10pt
}
BLOCKQUOTE {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</STYLE>
</HEAD>
<BODY style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><FONT 
color=#000000 size=2 face=Verdana>
<DIV><FONT size=2 face=Verdana><FONT color=#0000ff size=3 face=Verdana>Dear 
petsc teams,</FONT></DIV>
<DIV>
<DIV><FONT color=#0000ff size=3>When I use snes, I find the Jacobian matrix 
computation is&nbsp;an imposible misson,</FONT></DIV>
<DIV><FONT color=#0000ff size=3>however,I don't konw how to use 
"Finite&nbsp;Difference&nbsp;Jacobian&nbsp;Approximations", for 
example,</FONT></DIV>
<DIV><FONT color=#0000ff size=3>I modified the example "ex1f.F" and the function 
<FONT color=#000000>FormJacobian()</FONT> remain unchanged,as 
follows,</FONT></DIV>
<DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
call&nbsp;FormJacobian(snes,x,J,J,flag,dummy,ierr)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
call&nbsp;MatGetColoring(J,MATCOLORING_SL,iscoloring,ierr)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call&nbsp;MatFDColoringCreate(J,iscoloring,fdcoloring,ierr)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call&nbsp;ISColoringDestroy(iscoloring,ierr)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call&nbsp;MatFDColoringSetFromOptions(fdcoloring,ierr)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call&nbsp;SNESSetJacobian(snes,J,J,SNESDefaultComputeJacobianColor,&nbsp;fdcoloring,ierr)</DIV></DIV>
<DIV><FONT color=#0000ff size=3>but,</FONT></DIV>
<DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;---------------------&nbsp;Error&nbsp;Message&nbsp;------------------------------------</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;Object&nbsp;is&nbsp;in&nbsp;wrong&nbsp;state!</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;Must&nbsp;call&nbsp;MatFDColoringSetFunction()!</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;------------------------------------------------------------------------</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;Petsc&nbsp;Release&nbsp;Version&nbsp;3.0.0,&nbsp;Patch&nbsp;4,&nbsp;Fri&nbsp;Mar&nbsp;&nbsp;6&nbsp;14:46:08&nbsp;CST&nbsp;2009</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;See&nbsp;docs/changes/index.html&nbsp;for&nbsp;recent&nbsp;updates.</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;See&nbsp;docs/faq.html&nbsp;for&nbsp;hints&nbsp;about&nbsp;trouble&nbsp;shooting.</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;See&nbsp;docs/index.html&nbsp;for&nbsp;manual&nbsp;pages.</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;------------------------------------------------------------------------</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;/public/user/chenleping/femxr-2dof-nonlinear/ex1f&nbsp;on&nbsp;a&nbsp;linux-gnu&nbsp;named&nbsp;node1&nbsp;by&nbsp;chenleping&nbsp;Sat&nbsp;May&nbsp;&nbsp;1&nbsp;14:30:19&nbsp;2010</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;Libraries&nbsp;linked&nbsp;from&nbsp;/public/user/chenleping/soft/petsc-3.0.0-p4/linux-gnu-c-debug/lib</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;Configure&nbsp;run&nbsp;at&nbsp;Fri&nbsp;Mar&nbsp;27&nbsp;13:09:33&nbsp;2009</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;Configure&nbsp;options&nbsp;--with-mpi-dir=/public/user/chenleping/soft/mpich-install&nbsp;--with-x=0&nbsp;--download-hypre=/public/user/chenleping/soft/petsc-3.0.0-p4/hypre-2.0.0.tar.gz&nbsp;--with-shared=0</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;------------------------------------------------------------------------</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;MatFDColoringApply()&nbsp;line&nbsp;522&nbsp;in&nbsp;src/mat/matfd/fdmatrix.c</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;SNESDefaultComputeJacobianColor()&nbsp;line&nbsp;49&nbsp;in&nbsp;src/snes/interface/snesj2.c</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;SNESComputeJacobian()&nbsp;line&nbsp;1111&nbsp;in&nbsp;src/snes/interface/snes.c</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;SNESSolve_LS()&nbsp;line&nbsp;189&nbsp;in&nbsp;src/snes/impls/ls/ls.c</DIV>
<DIV>[0]PETSC&nbsp;ERROR:&nbsp;SNESSolve()&nbsp;line&nbsp;2221&nbsp;in&nbsp;src/snes/interface/snes.c</DIV>
<DIV>Number&nbsp;of&nbsp;Newton&nbsp;iterations&nbsp;=&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0<FONT 
color=#0000ff size=3 face=Verdana>&nbsp;</FONT></DIV></DIV>
<DIV align=left><FONT color=#0000ff size=3 face=Verdana>and I don't understand 
</FONT></DIV>
<DIV align=left><FONT color=#0000ff size=3 face=Verdana><SPAN>
<DIV><FONT color=#000000>/*</FONT></DIV>
<DIV><FONT 
color=#000000>This&nbsp;initializes&nbsp;the&nbsp;nonzero&nbsp;structure&nbsp;of&nbsp;the&nbsp;Jacobian.&nbsp;This&nbsp;is&nbsp;artificial</FONT></DIV>
<DIV><FONT 
color=#000000>because&nbsp;clearly&nbsp;if&nbsp;we&nbsp;had&nbsp;a&nbsp;routine&nbsp;to&nbsp;compute&nbsp;the&nbsp;Jacobian&nbsp;we&nbsp;wouldn’t</FONT></DIV>
<DIV><FONT 
color=#000000>need&nbsp;to&nbsp;use&nbsp;finite&nbsp;differences.</FONT></DIV>
<DIV><FONT color=#000000>*/</FONT></DIV></SPAN></FONT></DIV>
<DIV align=left><FONT color=#0000ff size=3 face=Verdana><SPAN>so I don't how to 
define the function <FONT 
color=#000000>FormJacobian().</FONT></SPAN></FONT></DIV>
<DIV align=left><FONT color=#0000ff size=3 face=Verdana><SPAN><FONT 
color=#0000ff>thanks,</FONT></DIV>
<DIV align=left>
<DIV><FONT face=华文行楷>leping</FONT>&nbsp;</DIV></DIV></SPAN></FONT><FONT size=2 
face=Verdana><FONT color=#0000ff size=3>
<HR style="WIDTH: 122px; HEIGHT: 2px" align=left SIZE=2>
</FONT>
<DIV><FONT color=#0000ff size=3 face=Verdana>&nbsp;2010-04-30</FONT></DIV>
<DIV>
<DIV>&nbsp;</DIV></DIV></FONT></FONT></DIV></FONT></BODY></HTML>