A question about VecSet
Barry Smith
bsmith at mcs.anl.gov
Thu Feb 12 12:06:50 CST 2009
On Feb 12, 2009, at 11:57 AM, Fredrik Bengzon wrote:
> Hi,
> I would like to know if I need to call VecGhostUpdateBegin\End on a
> vector with ghost nodes after a call to VecSet on the same vector,
> i.e.,
>
> // Declare vector v with VecCreateGhost etc.
>
> VecSet(v, 0.0); // Does this set also ghosted entries to zero ?
VecSet() zeros the VECTOR it is passed in. So if v is obtained from
VecCreateGhost() then the "extra" ghost values are NOT zeroed
(since those are not part of the global vector). If v was obtained
with VecGhostGetLocalForm() then it has the "extra" ghost values and
everything is zeroed.
If you want to monkey with the ghost locations then you should use
the local form.
>
>
> VecGhostUpdateBegin(v, INSERT_VALUES, SCATTER_FORWARD); // Is this
> necessary ?
> VecGhostUpdateEnd (v, INSERT_VALUES, SCATTER_FORWARD);
You would not want to to do this (requires extra communication).
You instead would call VecSet() on the local form.
Barry
>
>
> Sincerely,
>
> Fredrik Bengzon
More information about the petsc-users
mailing list