[petsc-users] Simultaneously compute Residual+Jacobian in SNES
Derek Gaston
friedmud at gmail.com
Fri Dec 9 13:50:02 CST 2016
Oh man! Sorry Barry! I swear I looked around before I sent the email. I
should have checked the FAQ a little more closely!
I can understand the reasoning in the FAQ... but I still wonder if it might
not be useful to provide all three options (Function, Jacobian,
FunctionJacobian). In my case I could fill in each one to do the right
thing. That way PETSc could call the "FunctionJacobian" one when it knew
it needed both (by default that could just farm out to the individual
calls). But you guys have definitely thought a lot more about this than I
have.
So, do you still recommend what's suggested in the FAQ? Save off the
Jacobian computation during the residual computation and then use that when
SNES asks for a Jacobian? In the case of automatic differentiation this
could make a pretty huge difference in time...
Derek
On Fri, Dec 9, 2016 at 1:49 PM Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> Sorry the title in the FAQ is a bit tongue-in-check.
>
> http://www.mcs.anl.gov/petsc/documentation/faq.html#functionjacobian
>
>
> > On Dec 9, 2016, at 12:45 PM, Derek Gaston <friedmud at gmail.com> wrote:
> >
> > Is there a way to tell SNES to simultaneously compute both the residual
> and the Jacobian in one callback?
> >
> > My code can compute both simultaneously and it will be more efficient
> (think FE where you can reuse the shape-functions, variables, material
> properties, etc. for both residual and Jacobian computation). In addition,
> I also have automatic differentiation as an option which _definitely_
> computes both efficiently (and actually computes residuals, by themselves,
> much slower).
> >
> > I was thinking that I may just save off the Jacobian whenever the
> initial residual computation is asked for by SNES... and then just return
> that Jacobian when SNES asks for it. This may be a bit dicey though as
> SNES can ask for residual computations at many different points during the
> solve.
> >
> > Thanks for any help!
> >
> > Derek
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20161209/3cc7a012/attachment.html>
More information about the petsc-users
mailing list