VecCopy() for ghosted vectors

Barry Smith bsmith at mcs.anl.gov
Wed Feb 25 08:23:55 CST 2009


     If you do VecCopy() on the vectors obtained via  
VecGhostGetLocalForm() then
the ghost values are copied (because the ghost values are OWNED by the  
local form,
not the global vector (which does not own ghost values).

    Barry

On Feb 25, 2009, at 5:13 AM, Jed Brown wrote:

> On Wed 2009-02-25 11:19, Tim Kroeger wrote:
>> When using VecCopy(a,b) where both a and b have been created using
>> VecCreateGhost(), it seems as if ghost components are not copied.  
>> Did I
>> do something wrong?
>
> The vector returned by VecCreateGhost will behave exactly like any  
> other
> parallel vector for the usual vector operations.  If you want access  
> to
> the ghosted values, use VecGhostGetLocalForm which will give you a
> serial vector (which knows nothing about the other processes, or even
> that it came from a VecGhost).  VecGhostUpdate{Begin,End} is the way  
> to
> handle the relationship between these conceptually different objects.
> If you only work with one (the local form or the global form) at a  
> time,
> the result should be the same as if they didn't share any memory and  
> you
> used a VecScatter to move values between the two representations (as
> with DALocalToGlobal).
>
> Jed



More information about the petsc-users mailing list