<div dir="ltr">Great, thanks Barry.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 23, 2017 at 3:12 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On Sep 23, 2017, at 12:48 PM, Mark W. Lohry <<a href="mailto:mlohry@princeton.edu">mlohry@princeton.edu</a>> wrote:<br>
><br>
> I'm currently using JFNK in an application where I don't have a hand-coded jacobian, and it's working well enough but as expected the scaling isn't great.<br>
><br>
> What is the general process for using PC with MatMFFDComputeJacobian? Does it make sense to occasionally have petsc re-compute the jacobian via finite differences, and then recompute the preconditioner? Any that just need the sparsity structure?<br>
<br>
 Mark<br>
<br>
   Yes, this is a common approach. SNESSetLagJacobian -snes_lag_jacobian<br>
<br>
    The normal approach in SNES to use matrix-free for the operator and use finite differences to compute an approximate Jacobian used to construct preconditioners is to to create a sparse matrix with the sparsity of the approximate Jacobian (yes you need a way to figure out the sparsity, if you use DMDA it will figure out the sparsity for you). Then you use<br>
<br>
   SNESSetJacobian(snes,J,J, SNESComputeJacobianDefaultColo<wbr>r, NULL);<br>
<br>
and use the options database option -snes_mf_operator<br>
<br>
<br>
> Are there any PCs that don't work in the matrix-free context?<br>
<br>
  If you do the above you can use almost all the PC since you are providing an explicit matrix from which to build the preconditioner<br>
<br>
> Are there any example codes I overlooked?<br>
><br>
> Last but not least... can the Boomer-AMG preconditioner work with JFNK? To really show my ignorance of AMG, can it actually be written as a matrix P^-1(Ax-b)=0, , or is it just a linear operator?<br>
<br>
  Again, if you provide an approximate Jacobian like above you can use it with BoomerAMG, if you provide NO explicit matrix you cannot use BoomerAMG or almost any other preconditioner.<br>
<br>
   Barry<br>
<br>
><br>
> Thanks,<br>
> Mark<br>
<br>
</blockquote></div><br></div>