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
