[petsc-users] Reusing the preconditioner when using KSPSetComputeOperators
Barry Smith
bsmith at mcs.anl.gov
Thu Aug 28 13:52:08 CDT 2014
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
Barry
>
> Regards,
> Åsmund
>
More information about the petsc-users
mailing list