<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 9, 2016 at 11:45 AM, Derek Gaston <span dir="ltr"><<a href="mailto:friedmud@gmail.com" target="_blank">friedmud@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Is there a way to tell SNES to simultaneously compute both the residual and the Jacobian in one callback?<div><br></div><div>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).</div><div><br></div><div>I was thinking that I may just save off the Jacobian whenever the initial residual computation is asked for by </div></div></blockquote><div><br></div><div>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.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>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.</div><div><br></div><div>Thanks for any help!</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Derek</div></font></span></div>
</blockquote></div><br></div></div>