[petsc-users] A matrix-free Jacobian for SNES using MatShell

Jeremy Roberts j.alyn.roberts at gmail.com
Tue Aug 31 10:12:46 CDT 2010


Hi folks,

I am trying to implement a sample problem for SNES using a shell matrix
construct for the Jacobian (*not* finite differences).

However, I haven't yet found a straightforward example for this.  I've seen
one for a shell-based PC but not for a shell-based Jacobian.

I thought a sequence like this would work, but I'm not sure how to set the
Jacobian.

          call MatCreateShell( PETSC_COMM_SELF, m, n, m, n,
PETSC_NULL_OBJECT, Jshell, ierr )
          call MatShellSetOperation( Jshell, MATOP_MULT, jac_shell, ierr )
          call MatCreateSNESMF( snes, Jshell, ierr )
          call SNESSetJacobian( snes, Jshell, Jshell, ???,
PETSC_NULL_OBJECT, ierr )

I need no PC right now, jac_shell computes the result J*v, and Jshell is an
empty Mat.

How do I finish this calling sequence?  Am I way off base here?

Thanks,
Jeremy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100831/a9d3c495/attachment.htm>


More information about the petsc-users mailing list