[petsc-users] Can a MatShell that operates on ghosted vectors work in place?

Jed Brown jedbrown at mcs.anl.gov
Mon Aug 20 09:53:39 CDT 2012


On Mon, Aug 20, 2012 at 9:49 AM, Toby Isaac <tisaac at ices.utexas.edu> wrote:

>
> I have finite element code, developed outside of PETSc thus far, with
> matrix-free operators.  I've written the operators so that they expect
> ghosted input vectors and return ghosted output vectors.
>
> I know that I can write a MatShell that creates a temporary ghosted
> versions of the input Vec and output Vec and calls my operators on these.
>  What I want to know is if there is any way to work in place, i.e. write a
> MatShell that expects ghosted inputs/outputs.  This would also require KSP
> methods to work with ghosted vectors and only use the locally-owned
> variables in the dot products.
>

You can write one that expects VecGhost (or your own vector type). To do
that, you usually want to implement MatGetVecs() and make sure solvers get
passed ghosted initial vectors. Then MatMult_YourShell() uses
VecGhostUpdateBegin()/End, VecGhostGetLocalForm(), your local evaluation
into the residual vector, VecGhostRestoreLocalForm(), and
VecGhostUpdateBegin() to finish assembling the residual vector.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120820/b61fdfa9/attachment.html>


More information about the petsc-users mailing list