<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 5, 2013 at 2:33 AM, Johannes Lotz <span dir="ltr"><<a href="mailto:lotz@stce.rwth-aachen.de" target="_blank">lotz@stce.rwth-aachen.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":4il">We are working on a general tool for adjoining PETSc-Code.<br>
Thats right -- the problem here is, that we can not store the complete history ( -- not necessarily a time stepping history, but rather the history of all computations) due to memory bounds.<br>
<br>
As a case study we have a code calling the snes-solve(). -- And no time stepping at all.<br>
<br>
We want to skip storing all iteration steps etc. inside snes-solve() by exploiting exactly the fact that the solution is unique and satisfies f(x)=b.<br>
For doing so, we need to solve a linear system with the transposed Jacobian matrix of that corresponding snes-solve() later on. So in fact we only need to be able to solve this linear system with the jacobian at some point X_new with the same solution method used in the original snes-solve(). I thought the handiest approach was to store the SNES-struct.</div>
</blockquote></div><br>Thanks for the context. Very few users change SNES to solve different systems (e.g., change SNESSetFunction mid-run). Some users take active control of the method (e.g., switching from Newton to preconditioned NGMRES), but even that is pretty rare. If we're working with assembled methods or the user has provided an analytic matrix-free Jacobian that implements MatMultTranspose(), we can just</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">SNESComputeJacobian(snes,X_converged_saved,&A,&B,&matstructure);</div><div class="gmail_extra" style>KSPSetOperators(ksp,A,B,matstructure);</div><div class="gmail_extra" style>
KSPSolveTranspose(ksp,Y_adjoint,Y_adjoint_prev);</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>If you find anything particularly cumbersome about this process, please let us know so that we can try to make it easier from within PETSc.</div>
</div>