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

Matthew Knepley knepley at gmail.com
Mon Aug 20 10:12:51 CDT 2012


On Mon, Aug 20, 2012 at 9:53 AM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

> 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.
>

Personally, I think this is quite cumbersome compared to the Local/Global
vector strategy we use in DM, and
does not have any real advantages.

   Matt

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120820/585311d6/attachment.html>


More information about the petsc-users mailing list