[petsc-users] Simultaneously compute Residual+Jacobian in SNES

Fande Kong fdkong.jd at gmail.com
Fri Dec 9 13:42:09 CST 2016


On Fri, Dec 9, 2016 at 11:45 AM, 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
>

It is a reasonable way. But there is no a straight way to determine when
you should evaluate Jacobian especially when you use a matrix-free matter.



> 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/74d7af24/attachment.html>


More information about the petsc-users mailing list