[petsc-users] Ghost communication

Jed Brown jed at 59A2.org
Wed Jun 22 06:01:06 CDT 2011


On Wed, Jun 22, 2011 at 11:45, Milan Mitrovic <milanm at student.ethz.ch>wrote:

> Inside the multiplication routine I do this:
>
>          CALL VecGhostUpdateBegin(from,INSERT_VALUES,SCATTER_FORWARD,info)
>          CALL VecGhostUpdateEnd(from,INSERT_VALUES,SCATTER_FORWARD,info)
>

This does update the ghost entries, right?


>
>          ! get ghosted versions of vectors
>          CALL VecGhostGetLocalForm(from,xl,info)
>          CALL VecSet(to,0.0_MK,info)
>          ! get arrays from petsc vectors
>          CALL VecGetArray(xl,xx,xxi,info)
>          CALL VecGetArray(to,yy,yyi,info)
>

Is "to" a ghosted vector in which the residual should be the sum of
contributions to all ghost copies (as in most finite element
implementations)? If so, then you should

call VecGhostGetLocalForm(to,yl,info)
call VecGetArray(yl,yy,yyi,info)
...


>
> Then I modify the data, and do the following:
>
>          CALL VecRestoreArray(xl,xx,xxi,info)
>          CALL VecRestoreArray(to,yy,yyi,info)
>          ! release local form of vectors
>          CALL VecGhostRestoreLocalForm(from,xl,info)
>
>          CALL VecGhostUpdateBegin(to,ADD_VALUES,SCATTER_REVERSE,info)
>          CALL VecGhostUpdateEnd(to,ADD_VALUES,SCATTER_REVERSE,info)
>

You can always test this by getting the local form, doing VecSet(yl,1.0),
restore the local form, do the scatter above, and view to.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110622/a5ad511f/attachment.htm>


More information about the petsc-users mailing list