Question about DAVecGetArray and DAVecRestoreArray
Matthew Knepley
knepley at gmail.com
Mon Jul 21 18:52:54 CDT 2008
On Mon, Jul 21, 2008 at 6:31 PM, Milad Fatenejad <icksa1 at gmail.com> wrote:
> Hello:
> The documentation states that to access elements of a vector created
> with a DA you should use the DAVecGetArray function and you should
> return the pointer when you are finished with the DAVecRestoreArray
> function.
>
> For my code, I would really like to call DAVecGetArray as soon as the
> vector is created, and call DAVecRestoreArray right before the vector
> is destroyed. In other words, I would like to be able to access the
> elements during the vector's entire life and not have to call these
> two functions every time I need to access individual elements.
>
> I would like to know if having access to the elements of the vector
> prevents me from using it in some way? I am concerned that there might
> be some operation that won't work while the array is being accessed,
> i.e. that DAVecGetArray somehow locks the vector so some other
> function cannot use it until DAVecRestoreArray is called. Is this the
> case?
Yes, there are some operations which need to know that you are not changing
the vector while they are operating. There is no overhead for calling
DAVecGetArray(). Why not call it only when you need access to the internals?
Matt
> Thanks for your help.
> Milad
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which
their experiments lead.
-- Norbert Wiener
More information about the petsc-users
mailing list