[petsc-users] about snes and finite difference jacobian approximations

陈乐平(Leping Chen) chenleping at yahoo.cn
Fri Apr 30 09:17:09 CDT 2010


Dear petsc teams,
When I use snes, I find the Jacobian matrix computation is an imposible misson,
however,I don't konw how to use "Finite Difference Jacobian Approximations", for example,
I modified the example "ex1f.F" and the function FormJacobian() remain unchanged,as follows,
      call FormJacobian(snes,x,J,J,flag,dummy,ierr)
      call MatGetColoring(J,MATCOLORING_SL,iscoloring,ierr)
      call MatFDColoringCreate(J,iscoloring,fdcoloring,ierr)
      call ISColoringDestroy(iscoloring,ierr)
      call MatFDColoringSetFromOptions(fdcoloring,ierr)
      call SNESSetJacobian(snes,J,J,SNESDefaultComputeJacobianColor, fdcoloring,ierr)
but,
[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Object is in wrong state!
[0]PETSC ERROR: Must call MatFDColoringSetFunction()!
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 3.0.0, Patch 4, Fri Mar  6 14:46:08 CST 2009
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR: ------------------------------------------------------------------------
[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
[0]PETSC ERROR: Libraries linked from /public/user/chenleping/soft/petsc-3.0.0-p4/linux-gnu-c-debug/lib
[0]PETSC ERROR: Configure run at Fri Mar 27 13:09:33 2009
[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
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: MatFDColoringApply() line 522 in src/mat/matfd/fdmatrix.c
[0]PETSC ERROR: SNESDefaultComputeJacobianColor() line 49 in src/snes/interface/snesj2.c
[0]PETSC ERROR: SNESComputeJacobian() line 1111 in src/snes/interface/snes.c
[0]PETSC ERROR: SNESSolve_LS() line 189 in src/snes/impls/ls/ls.c
[0]PETSC ERROR: SNESSolve() line 2221 in src/snes/interface/snes.c
Number of Newton iterations =     0 
and I don't understand 
/*
This initializes the nonzero structure of the Jacobian. This is artificial
because clearly if we had a routine to compute the Jacobian we wouldn’t
need to use finite differences.
*/
so I don't how to define the function FormJacobian().
thanks,
leping 



 2010-04-30
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100430/ab21bfe3/attachment.htm>


More information about the petsc-users mailing list