[petsc-users] Reusing the preconditioner when using KSPSetComputeOperators
Åsmund Ervik
asmund.ervik at ntnu.no
Fri Aug 29 09:35:20 CDT 2014
> On 28. aug. 2014 20:52, Barry Smith wrote:
> >
> > On Aug 28, 2014, at 4:34 AM, Åsmund Ervik <asmund.ervik at ntnu.no> wrote:
> >
> >> Hello,
> >>
> >> I am solving a pressure Poisson equation with KSP, where the initial
> >> guess, RHS and matrix are computed by functions that I've hooked into
> >> KSPSetComputeXXX. (I'm also using DMDA for my domain decomposition.)
> >>
> >> For (single-phase|two-phase) I would like to (reuse|not reuse) the
> >> preconditioner. How do I specify that when using this way of setting the
> >> operator? Is it toggled by whether or not I call KSPSetOperators before
> >> each KSPSolve? (The manual does not mention KSPSetComputeXXX.)
> >
> > You should call KSPSetOperators() before each KSPSolve() (otherwise the function you provide to compute the matrix won’t be triggered).
> >
> > With PETSc 3.5 after the call to KSPSetOperators() call KSPSetReusePreconditioner() to tell KSP wether to reuse the preconditioner or build a new one.
> > With PETSc 3.4 and earlier, the final argument to KSPSetOperators() would be MAT_SAME_PRECONDITIONER to reuse the preconditioner or MAT_SAME_NONZERO_PATTERN to construct a new preconditioner
> >
Thanks Barry for the clarification. Is there an example somewhere that
does this? All the ones I can find which use KSPSetComputeOperators()
have no calls to KSPSetOperators(). I guess this is because they are
only doing one linear solve?
Furthermore, what should I pass in for Amat and Pmat to the KSPSetOperators() call? PetscNullObject, or do I get the Amat from the KSP somehow?
Åsmund
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140829/af9aa7bd/attachment.html>
More information about the petsc-users
mailing list