[petsc-users] VecCopy on ghosted vectors
Barry Smith
bsmith at mcs.anl.gov
Sun Apr 22 11:07:32 CDT 2012
Think of a ghosted vector and its local form as two completely different vectors.
Barry
They just happen to have some common memory area for efficiency, but that is only for efficiency.
On Apr 22, 2012, at 11:03 AM, Barry Smith wrote:
>
> Dominik,
>
> If you want to copy the ghost point values, which DO NO exist in the x1 and x2 vectors, you need to use VecCopy(xlocal1,xlocal2) where xlocal1 and xlocal2 are obtained with VecGetLocalForm() on x1 and x2.
>
> The rational is that x1 and x2 are just regular parallel vectors, copying their entries is just copying their entries, not the "extra" slots that are ONLY available via the local form.
>
> You are mis-thinking about how "ghosted" vectors work.
>
>
> Barry
>
>
> On Apr 22, 2012, at 10:35 AM, Dominik Szczerba wrote:
>
>> I do
>>
>> VecGhostUpdateBegin(x1, INSERT_VALUES, SCATTER_FORWARD);
>> VecGhostUpdateEnd(x1, INSERT_VALUES, SCATTER_FORWARD);
>>
>> then
>>
>> VecCopy(x1,x2)
>>
>> to find that x2 does not have correct ghost values and I need to explicitly call
>>
>> VecGhostUpdateBegin(x2, INSERT_VALUES, SCATTER_FORWARD);
>> VecGhostUpdateEnd(x2, INSERT_VALUES, SCATTER_FORWARD);
>>
>> Is there a rationale for this behavior? I would suggest to add a note
>> to the VecCopy man page about it.
>>
>> Thanks
>> Dominik
>
More information about the petsc-users
mailing list