[petsc-dev] What's the point of D(A/M)GetGlobalVector?

Jed Brown jed at 59A2.org
Fri Aug 27 06:23:02 CDT 2010


On Fri, 27 Aug 2010 14:13:01 +0300, Aron Ahmadia <aron.ahmadia at kaust.edu.sa> wrote:
> What exactly is the purpose of these routines then?  Is there a global
> Vector associated with a DA?  If so, why are the values uninitialized? 

It's common to need work vectors in places like residual evaluation and
Jacobian assembly.  There is a little bit of setup cost to allocate a
new vector each time, so usually we'd prefer that they be persistent and
just reuse them.  One option would be to make the user manage this
themselves, but that's error prone because it's easy to accidentally
alias the work vectors, so instead the DA keeps a cache of vectors.  It
starts out empty, and each time you call DAGetGlobalVector(), the cache
is searched for an available vector.  If none are found, a new one is
allocated and the cache grows by one.  DARestoreGlobalVector() checks a
vector back in so it may be used elsewhere.  These vectors are destroyed
in DADestroy().

Jed



More information about the petsc-dev mailing list