<div class="gmail_quote">On Mon, Aug 20, 2012 at 9:49 AM, Toby Isaac <span dir="ltr"><<a href="mailto:tisaac@ices.utexas.edu" target="_blank">tisaac@ices.utexas.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
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.<br>
<br>
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.<br>
</blockquote><div><br></div><div>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.</div>
</div>