[petsc-dev] Integrating PFLOTRAN, PETSC & SAMRAI

Jed Brown jed at 59A2.org
Mon Jun 6 15:59:03 CDT 2011


On Mon, Jun 6, 2011 at 22:49, Boyce Griffith <griffith at cims.nyu.edu> wrote:

> I stash a pointer to the SAMRAI vector object in the PETSc Vec as
> vec->data.
>

Great, somewhere in your FormResidual(), you access this data. Otherwise
there would be no way for you to change the output data (unless you did some
sort of hidden sharing which would be super fragile). So why not have that
API increment the state? For example, VecRestoreArray() increments state for
PETSc vectors. Since everyone accesses the vector through this API, they
never have to call PetscObjectStateIncrease() themselves.

Why not have your accessor manage the state? This would be the logically
consistent way to do it.


> At least when this stuff was first written, the only way to interface the
> SAMRAI vector class with PETSc was to make a new "subclass" of Vec.
>

This is still a good way as long as SAMRAI is storing the Vec data
non-contiguously. If it's stored contiguously, then a normal Vec could use
it. You could use PetscObjectCompose() to attach your SAMRAI structure for
when you need the "extra" information. Either SAMRAI or PETSc could "own"
the pointer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110606/961f8a6a/attachment.html>


More information about the petsc-dev mailing list