[petsc-dev] Integrating PFLOTRAN, PETSC & SAMRAI
Boyce Griffith
griffith at cims.nyu.edu
Mon Jun 6 16:01:21 CDT 2011
On 6/6/11 4:45 PM, Jed Brown wrote:
> On Mon, Jun 6, 2011 at 22:41, Boyce Griffith <griffith at cims.nyu.edu
> <mailto:griffith at cims.nyu.edu>> wrote:
>
> At least in my code, and I expect in Bobby's too, all Mat and PC
> objects are just shells. So the only non-PETSc objects are Vec
> wrapper objects.
>
>
> You are still supposed to call MatAssemblyEnd() which does this.
Yes, I understand.
I don't have any problems with Mat state --- I was just indicating that
it would be nice not to have to worry about screwing up the state stuff.
> How do the SAMRAI wrappers get access to Vec's internals to modify it?
> That is, how do they turn a Vec into some mutable structure?
Each PETSc Vec just holds a pointer to the SAMRAI vector.
I do something like this:
Vec petsc_vector;
ierr = VecCreate(comm, &petsc_vector); IBTK_CHKERRQ(ierr);
petsc_vector->petscnative= PETSC_FALSE;
petsc_vector->map->n = 0;
petsc_vector->map->N = 0;
petsc_vector->map->bs = 1;
d_petsc_vector->ops->duplicate =
PETScSAMRAIVectorReal::VecDuplicate_SAMRAI;
d_petsc_vector->ops->duplicatevecs = VecDuplicateVecs_Default;
d_petsc_vector->ops->destroyvecs = VecDestroyVecs_Default;
d_petsc_vector->ops->dot = VecDot_SAMRAI;
d_petsc_vector->ops->mdot = VecMDot_SAMRAI;
....
d_petsc_vector->data = /* pointer to SAMRAI vector object */;
where the various function pointers set in vec->ops are static functions
that call the appropriate SAMRAI methods.
If there is a better way to do this, I'm happy to change this code,
which I have never liked much to begin with. :-)
-- Boyce
More information about the petsc-dev
mailing list