Then just use MatShell. I see the docs need some work to clarify this, but MatCreateSNESMF is to specify matrix-free finite differencing from code (perhaps where one wants to customize parameters).
Yi Hu <y...@mpie.de> writes: > Dear Jed, > > Thanks for your reply. I have an analytical one to implement. > > Best, Yi > > -----Original Message----- > From: Jed Brown <j...@jedbrown.org> > Sent: Wednesday, December 20, 2023 5:40 PM > To: Yi Hu <y...@mpie.de>; petsc-users@mcs.anl.gov > Subject: Re: [petsc-users] fortran interface to snes matrix-free jacobian > > Are you wanting an analytic matrix-free operator or one created for you based > on finite differencing? If the latter, just use -snes_mf or -snes_mf_operator. > > https://petsc.org/release/manual/snes/#jacobian-evaluation > > Yi Hu <y...@mpie.de> writes: > >> Dear PETSc team, >> >> My solution scheme relies on a matrix-free jacobian in the SNES solver. I >> saw the useful C interface like MatCreateSNESMF(), DMSNESCreateJacobianMF(). >> I am wondering if you have the fortran equivalence? >> >> I think for my problem in the main program I need to do >> DMDASNESsetJacobianLocal(DM, INSERT_VALUES, myJacobian, ctx, err_petsc). >> Then in myJacobian() subroutine I have to create the operator from >> DMSNESCreateJacobianMF(), and register my own MATOP_MULT from >> MatShellSetOperation(). Am I correct? >> >> Are these fortran subroutines available? I saw an example in ts module >> as ex22f_mf.F90 which behaves similar as what I would like to do. Because I >> would like to use ngmres, I then need to stay in the SNES. >> >> Thanks for your help. >> >> Best wishes, >> Yi >> >> ------------------------------------------------- >> Stay up to date and follow us on LinkedIn, Twitter and YouTube. >> >> Max-Planck-Institut für Eisenforschung GmbH Max-Planck-Straße 1 >> D-40237 Düsseldorf >> >> Handelsregister B 2533 >> Amtsgericht Düsseldorf >> >> Geschäftsführung >> Prof. Dr. Gerhard Dehm >> Prof. Dr. Jörg Neugebauer >> Prof. Dr. Dierk Raabe >> Dr. Kai de Weldige >> >> Ust.-Id.-Nr.: DE 11 93 58 514 >> Steuernummer: 105 5891 1000 >> >> >> Please consider that invitations and e-mails of our institute are only >> valid if they end with …@mpie.de. >> If you are not sure of the validity please contact r...@mpie.de >> >> Bitte beachten Sie, dass Einladungen zu Veranstaltungen und E-Mails >> aus unserem Haus nur mit der Endung …@mpie.de gültig sind. >> In Zweifelsfällen wenden Sie sich bitte an r...@mpie.de >> ------------------------------------------------- > > > ------------------------------------------------- > Stay up to date and follow us on LinkedIn, Twitter and YouTube. > > Max-Planck-Institut für Eisenforschung GmbH > Max-Planck-Straße 1 > D-40237 Düsseldorf > > Handelsregister B 2533 > Amtsgericht Düsseldorf > > Geschäftsführung > Prof. Dr. Gerhard Dehm > Prof. Dr. Jörg Neugebauer > Prof. Dr. Dierk Raabe > Dr. Kai de Weldige > > Ust.-Id.-Nr.: DE 11 93 58 514 > Steuernummer: 105 5891 1000 > > > Please consider that invitations and e-mails of our institute are > only valid if they end with …@mpie.de. > If you are not sure of the validity please contact r...@mpie.de > > Bitte beachten Sie, dass Einladungen zu Veranstaltungen und E-Mails > aus unserem Haus nur mit der Endung …@mpie.de gültig sind. > In Zweifelsfällen wenden Sie sich bitte an r...@mpie.de > -------------------------------------------------