[petsc-dev] Integrating PFLOTRAN, PETSC & SAMRAI

Jed Brown jed at 59A2.org
Mon Jun 6 16:43:55 CDT 2011


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

> Destructors don't get called within calls to KSPSolve()/SNESSolve() (unless
> called via PETSc internals).


It must be a different model, but something vaguely along the following
lines could work.

class UserVector : public SAMRAIVector { // SAMRAIVector is whatever was
returned by getVector()

UserVector::UserVector(Vec X) {
  VecSamraiCtx ctx = X->data;
  this->vec = X;
  this->SAMRAIVector(ctx.getVector()); // if there is internal reference
counting
}

UserVector::~UserVector() {
  // any cleanup
  if (this->modified) PetscObjectStateIncrease((PetscObject)this->vec);
}
};


Then you would have something like

PetscErrorCode FormResidual(SNES snes,Vec X,Vec Y,void *ctx) {
  UserVector ux(X),uy(Y);

  // compute the function and put the result in uy
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110606/66021927/attachment.html>


More information about the petsc-dev mailing list