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

Aron Ahmadia aron.ahmadia at kaust.edu.sa
Fri Aug 27 08:38:34 CDT 2010


Barry,

I was being snippy, DAGetMatrix is the only one I know of that acts
unexpectedly.

Still, when working with Vec, you expect Get/Restore to modify data in the
Vec itself, which breaks for DAs since a DA has no internal Vec storage.
 Unless you are willing to append 'Work' somewhere into the names of the
work vector routines, I don't see an obvious solution.

A

On Fri, Aug 27, 2010 at 4:27 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
> On Aug 27, 2010, at 8:13 AM, Aron Ahmadia wrote:
>
> Not to mention the various Get routines that are actually used to create
> things, such as DAGetMatrix.  Still, the idea of a pool of work vectors
> makes sense, I was just trying to wrap my head around the actual use for
> those routines.
>
>
>    Aron,
>
>     DAGetMatrix() is actually a bug and should be DACreateMatrix()   (or
> maybe better DACreateMat() while the DACreateGlobalVector() and friends
> should really be DACreateGlobalVec()).
>
>     Are there others beside DAGetMatrix() that are incorrect with gets that
> should be creates?
>
>      Thanks
>
>        Barry
>
>      It would actually be nice if we made DACreateGlobal/LocalVector() so
> light-weight that it could be used for work vectors (instead of needing a
> different set of light weight get routines)  but then we would need
> DADestroyGlobal/Vector() to handle putting back in the free list or need to
> modify VecDestroy() to handle not actually destroying but managing a free
> list). And there is also the issue of zeroing or not zeroing the Vec
> initially.
> This is why we still have the Create and Get versions.
>
>
>
> A
>
> On Fri, Aug 27, 2010 at 4:06 PM, Dmitry Karpeev <karpeev at mcs.anl.gov>wrote:
>
>> Except VecGetArray, etc, which operate a "pool" of one object.
>> I think this may be the root cause of confusion.
>>
>> Dmitry.
>>
>> On Fri, Aug 27, 2010 at 6:42 AM, Matthew Knepley <knepley at gmail.com>
>> wrote:
>> > Simply, in PETSc, getFoo() and restoreFoo() operate an object pool.
>> >    Matt
>> >
>> > On Fri, Aug 27, 2010 at 11:23 AM, Jed Brown <jed at 59a2.org> wrote:
>> >>
>> >> 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
>> >
>> >
>> >
>> > --
>> > 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
>> >
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20100827/69ed0811/attachment.html>


More information about the petsc-dev mailing list