[petsc-users] Matrix-free functions for SNES
DU Yongle
yongle.du at gmail.com
Wed Dec 2 17:09:13 CST 2015
Dear Sir/Madam:
Sorry to bother, but I didn't find any information I need to implement
matrix-free functions for SNES after a long time search of the manual and
sample codes.
Suppose I am solving nonlinear equation systems F(x) = 0, I have two
choices:
(1) MatCreateMFFD(snes, matJ):
This calculate matJ * x with a finite difference scheme. I can create a
function to calculate matJ * x, and link it to SNES by SNESSetJacobian.
However, I do not prefer this feature because I am calculating the mat-vec
product in another way.
(2) MatCreateMF(snes, matJ):
Here, matJ is not defined explicitly. It is some operations (like mat-vec
product). must be linked to SNES, and must be linked to SNES through
SNESSetJacobian.
For KSP solvers, I know that a matshell type can be created and a mat-vec
product can be assigned to matJ in this way:
MatCreateShell( ....)
MatShellSetOperation(....)
KSPSetOperators(ksp, matJ, matJ)
How to do the similar operations for SNES if matJ is already created via
MatCreateMF? How to define the mat size and mat-vec product? What other
operations are required in a customized function in order to link it to
SNES via SNESSetJacobian?
Thanks a for your help.
Yongle Du
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20151202/65d8bffa/attachment.html>
More information about the petsc-users
mailing list