[petsc-dev] Copy *SNES-struct deeply

Jed Brown jedbrown at mcs.anl.gov
Tue Mar 5 06:49:51 CST 2013


On Tue, Mar 5, 2013 at 2:33 AM, Johannes Lotz <lotz at stce.rwth-aachen.de>wrote:

> We are working on a general tool for adjoining PETSc-Code.
> 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.
>
> As a case study we have a code calling the snes-solve(). -- And no time
> stepping at all.
>
> 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.
> 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.
>

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

SNESComputeJacobian(snes,X_converged_saved,&A,&B,&matstructure);
KSPSetOperators(ksp,A,B,matstructure);
KSPSolveTranspose(ksp,Y_adjoint,Y_adjoint_prev);

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130305/4f2866b9/attachment.html>


More information about the petsc-dev mailing list