[petsc-users] Scatter context for MatMult

Jed Brown jedbrown at mcs.anl.gov
Fri Aug 17 13:59:51 CDT 2012


On Fri, Aug 17, 2012 at 1:48 PM, John Fettig <john.fettig at gmail.com> wrote:

> On Fri, Aug 17, 2012 at 2:33 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> > Why do you want raw access?
>
> I'm trying to write my own RAP operator for AMG.
>
> > If you really need, you can either use MatMPIAIJGetSeqAIJ() or just
> include
> > the private header.
>
> I presume you mean MatMPIAIJGetLocalMat.  This isn't quite what I
> want.  I don't want the local matrix, I want to scatter a vector
> according to the ghost values defined by the sparsity pattern of the
> parallel matrix.
>

PetscErrorCode  MatMPIAIJGetSeqAIJ(Mat A,Mat *Ad,Mat *Ao,PetscInt **colmap);

But if you are writing an RAP, you should just include
src/mat/impls/aij/mpi/mpiaij.h. You can set your implementation on an
existing matrix using MatShellSetOperation(A, MATOP_PTAP,
(void(*)(void))YourPtAPFunction).


> Could you give me a little more help with using the latter?  I see
>
> VecScatterBegin(a->Mvctx,xx,a->lvec,INSERT_VALUES,SCATTER_FORWARD);
> (*a->A->ops->mult)(a->A,xx,yy);
> VecScatterEnd(a->Mvctx,xx,a->lvec,INSERT_VALUES,SCATTER_FORWARD);
> (*a->B->ops->multadd)(a->B,a->lvec,yy,yy);
>

> So I guess a->Mvctx is what I want.  How do I figure out the mapping
> of indices in a->lvec?
>

a->garray. MatPtAP is not an easy operation to write. You'll have to get
comfortable with diving into the source to understand what's happening.



>
> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120817/9932e6eb/attachment.html>


More information about the petsc-users mailing list