<!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 an imposible misson,</FONT></DIV>
<DIV><FONT color=#0000ff size=3>however,I don't konw how to use
"Finite Difference Jacobian 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>
call FormJacobian(snes,x,J,J,flag,dummy,ierr)</DIV>
<DIV>
call MatGetColoring(J,MATCOLORING_SL,iscoloring,ierr)</DIV>
<DIV> call MatFDColoringCreate(J,iscoloring,fdcoloring,ierr)</DIV>
<DIV> call ISColoringDestroy(iscoloring,ierr)</DIV>
<DIV> call MatFDColoringSetFromOptions(fdcoloring,ierr)</DIV>
<DIV> call SNESSetJacobian(snes,J,J,SNESDefaultComputeJacobianColor, fdcoloring,ierr)</DIV></DIV>
<DIV><FONT color=#0000ff size=3>but,</FONT></DIV>
<DIV>
<DIV>[0]PETSC ERROR: --------------------- Error Message ------------------------------------</DIV>
<DIV>[0]PETSC ERROR: Object is in wrong state!</DIV>
<DIV>[0]PETSC ERROR: Must call MatFDColoringSetFunction()!</DIV>
<DIV>[0]PETSC ERROR: ------------------------------------------------------------------------</DIV>
<DIV>[0]PETSC ERROR: Petsc Release Version 3.0.0, Patch 4, Fri Mar 6 14:46:08 CST 2009</DIV>
<DIV>[0]PETSC ERROR: See docs/changes/index.html for recent updates.</DIV>
<DIV>[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</DIV>
<DIV>[0]PETSC ERROR: See docs/index.html for manual pages.</DIV>
<DIV>[0]PETSC ERROR: ------------------------------------------------------------------------</DIV>
<DIV>[0]PETSC ERROR: /public/user/chenleping/femxr-2dof-nonlinear/ex1f on a linux-gnu named node1 by chenleping Sat May 1 14:30:19 2010</DIV>
<DIV>[0]PETSC ERROR: Libraries linked from /public/user/chenleping/soft/petsc-3.0.0-p4/linux-gnu-c-debug/lib</DIV>
<DIV>[0]PETSC ERROR: Configure run at Fri Mar 27 13:09:33 2009</DIV>
<DIV>[0]PETSC ERROR: Configure options --with-mpi-dir=/public/user/chenleping/soft/mpich-install --with-x=0 --download-hypre=/public/user/chenleping/soft/petsc-3.0.0-p4/hypre-2.0.0.tar.gz --with-shared=0</DIV>
<DIV>[0]PETSC ERROR: ------------------------------------------------------------------------</DIV>
<DIV>[0]PETSC ERROR: MatFDColoringApply() line 522 in src/mat/matfd/fdmatrix.c</DIV>
<DIV>[0]PETSC ERROR: SNESDefaultComputeJacobianColor() line 49 in src/snes/interface/snesj2.c</DIV>
<DIV>[0]PETSC ERROR: SNESComputeJacobian() line 1111 in src/snes/interface/snes.c</DIV>
<DIV>[0]PETSC ERROR: SNESSolve_LS() line 189 in src/snes/impls/ls/ls.c</DIV>
<DIV>[0]PETSC ERROR: SNESSolve() line 2221 in src/snes/interface/snes.c</DIV>
<DIV>Number of Newton iterations = 0<FONT
color=#0000ff size=3 face=Verdana> </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 initializes the nonzero structure of the Jacobian. This is artificial</FONT></DIV>
<DIV><FONT
color=#000000>because clearly if we had a routine to compute the Jacobian we wouldn’t</FONT></DIV>
<DIV><FONT
color=#000000>need to use finite 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> </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> 2010-04-30</FONT></DIV>
<DIV>
<DIV> </DIV></DIV></FONT></FONT></DIV></FONT></BODY></HTML>