Geoff, just add -pc_type lu to the options below, it will use a (sparse) direct solver as a preconditioner. Sundials is still using matrix-free finite differencing for Jacobian-free Newton-Krylov, and we can't control how often the Jacobian is recomputed, but we can choose whatever we want as a preconditioner.<div>
<br></div><div>The Rosenbrock methods are pretty slick in that they only need a linear solve per stage and that the Jacobian is only recomputed once per step. If you have a problem where Jacobian evaluation is very expensive, we can make methods with many stages (to further amortize setup cost; good unless it causes more step rejections).<br>
<div><div><br></div><div>[...]</div><div> PC Object: 1 MPI processes</div><div> type: lu</div><div> LU: out-of-place factorization</div><div> tolerance for zero pivot 2.22045e-14</div><div> matrix ordering: nd</div>
<div> factor fill ratio given 5, needed 1</div><div> Factored matrix follows:</div><div> Matrix Object: 1 MPI processes</div><div> type: seqaij</div><div> rows=3, cols=3</div>
<div> package used to perform factorization: petsc</div><div> total: nonzeros=9, allocated nonzeros=9</div><div> total number of mallocs used during MatSetValues calls =0</div><div> using I-node routines: found 1 nodes, limit used is 5</div>
<div> linear system matrix = precond matrix:</div><div> Matrix Object: 1 MPI processes</div><div> type: seqaij</div><div> rows=3, cols=3</div><div> total: nonzeros=9, allocated nonzeros=15</div><div>
total number of mallocs used during MatSetValues calls =0</div><div> using I-node routines: found 1 nodes, limit used is 5</div><div> Sundials no. of preconditioner evaluations 330</div><div> Sundials no. of preconditioner solves 3497</div>
<div> Sundials no. of Jacobian-vector product evaluations 1719</div><div> Sundials no. of rhs calls for finite diff. Jacobian-vector evals 1719</div><div>steps 1000 (0 rejected, 0 SNES fails), ftime 1.97026e+10, nonlinits 1719, linits 1719</div>
<div><br></div><div class="gmail_quote">On Thu, Jun 21, 2012 at 11:46 AM, Geoff Oxberry <span dir="ltr"><<a href="mailto:goxberry@gmail.com" target="_blank">goxberry@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 style="word-wrap:break-word">Peter,<div><br></div><div>You are correct. Here is the output (now with petsc-dev changeset: 23668:a876ee8e66fd):</div><div><br></div><div><div>goxberry$ ./ex8 -problem_type rober -ts_type sundials -ts_view</div>
<div>TS Object: 1 MPI processes</div><div> type: sundials</div><div> maximum steps=1000</div><div> maximum time=1e+11</div><div> total number of nonlinear solver iterations=3739</div><div> total number of nonlinear solve failures=0</div>
<div> total number of linear solver iterations=3739</div><div> total number of rejected steps=0</div><div> Sundials integrater does not use SNES!</div><div> Sundials integrater type BDF: backward differentiation formula</div>
<div> Sundials abs tol 1e-06 rel tol 1e-06</div><div> Sundials linear solver tolerance factor 0.05</div><div> Sundials max dimension of Krylov subspace 5</div><div> Sundials using unmodified (classical) Gram-Schmidt for orthogonalization in GMRES</div>
<div> Sundials suggested factor for tolerance scaling 1</div><div> Sundials cumulative number of internal steps 1000</div><div> Sundials no. of calls to rhs function 1931</div><div> Sundials no. of calls to linear solver setup function 0</div>
<div> Sundials no. of error test failures 16</div><div> Sundials no. of nonlinear solver iterations 1930</div><div> Sundials no. of nonlinear convergence failure 204</div><div> Sundials no. of linear iterations 3739</div>
<div> Sundials no. of linear convergence failures 0</div><div> PC Object: 1 MPI processes</div><div> type: none</div><div> Sundials no. of preconditioner evaluations 0</div><div> Sundials no. of preconditioner solves 0</div>
<div> Sundials no. of Jacobian-vector product evaluations 3739</div><div> Sundials no. of rhs calls for finite diff. Jacobian-vector evals 3739</div><div class="im"><div>steps 1000 (0 rejected, 0 SNES fails), ftime 744.845, nonlinits 3739, linits 3739</div>
</div></div><div><br></div><div>I use Sundials mostly with finite difference Jacobians, but I also provide Jacobian matrices where I can (which would be another helpful feature).</div><div><br></div><div>Cheers,</div><div>
<br></div><div>Geoff</div><div><div class="h5"><div><br><div><div>On Jun 21, 2012, at 10:52 AM, Peter Brune wrote:</div><br><blockquote type="cite">I asked my question because it might be happening automatically. His output looked like the equation was solved. A brief google search on this makes it look like they do this anyways. In addition: <br>
<br><a href="http://www.mcs.anl.gov/petsc/petsc-dev/src/ts/impls/implicit/sundials/sundials.c.html#TSView_Sundials" target="_blank">http://www.mcs.anl.gov/petsc/petsc-dev/src/ts/impls/implicit/sundials/sundials.c.html#TSView_Sundials</a><br>
<br>directly refers to "Sundials no. of rhs calls for finite diff. Jacobian-vector evals."<br><br>- Peter<br><br><div class="gmail_quote">On Thu, Jun 21, 2012 at 9:48 AM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@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>On Thu, Jun 21, 2012 at 8:45 AM, Peter Brune <span dir="ltr"><<a href="mailto:prbrune@gmail.com" target="_blank">prbrune@gmail.com</a>></span> wrote:<br>
</div><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What do you see when you run with -ts_view?<span><font color="#888888"><br><br>- Peter</font></span><div><div><br><br><div class="gmail_quote">On Thu, Jun 21, 2012 at 9:40 AM, Geoff Oxberry <span dir="ltr"><<a href="mailto:goxberry@gmail.com" target="_blank">goxberry@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 style="word-wrap:break-word"><div>Peter,</div><div><br></div><div>Just wanted to make sure there wasn't some Sundials-specific option for finite difference Jacobians that I was missing; despite reading the manual, it's a large package, and it's easy to miss things. If that's the case, I'd like to make a feature request for such an option.</div>
</div></blockquote></div></div></div></blockquote><div><br></div></div><div>If I understand correctly, you want a MF Jacobian with Sundials. We can't do that because Sundials is completely</div><div>closed package, which we cannot pry apart to insert something like this. The alternative is to use the stuff solvers</div>
<div>we currently have in TS. I thought that you had used the Rosenbrock-W stuff. Is this sufficient?</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span><font color="#888888"><div>
Geoff</div></font></span><div><div><br><div><div>On Jun 21, 2012, at 9:53 AM, Peter Brune wrote:</div><br><blockquote type="cite"><p>Note that in the code in ts/impls/implicit/sundials it says:</p><p>This uses its own nonlinear solver and krylov method so PETSc SNES and KSP options do not apply...</p>
<p>- Peter</p>
<div class="gmail_quote">On Jun 21, 2012 7:59 AM, "Geoff Oxberry" <<a href="mailto:goxberry@gmail.com" target="_blank">goxberry@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Running the following example from PETSC 3.3.0-dev (changeset: 23631:0e86ac5e4170)<br>
<br>
/path/to/petsc-dev/src/ts/examples/tutorials/ex8 -problem_type rober -snes_fd -ts_type sundials<br>
<br>
gives the following output<br>
<br>
steps 1000 (0 rejected, 0 SNES fails), ftime 744.845, nonlinits 3739, linits 3739<br>
WARNING! There are options you set that were not used!<br>
WARNING! could be spelling mistake, etc!<br>
Option left: name:-snes_fd no value<br>
<br>
Just to confirm, is it currently impossible to use a finite difference Jacobian matrix in concert with CVODE? If so, could this feature be implemented in a future release? I currently rely on Sundials to integrate stiff systems of ODEs, and for my application, it is impractical to derive an analytical Jacobian matrix. (It is an issue I've discussed both with Jed and Matt on another forum.)<br>
<br>
Cheers,<br>
<br>
Geoff</blockquote></div>
</blockquote></div><br></div></div></div></blockquote></div><br>
</div></div></blockquote></div></div><br><br clear="all"><div><div><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>
</div></div></blockquote></div><br>
</blockquote></div><br></div></div></div></div></blockquote></div><br></div></div>