[petsc-users] valgrind errors.
Jed Brown
jed at 59A2.org
Tue Jan 19 12:05:34 CST 2010
On Tue, 19 Jan 2010 12:56:30 -0500, "(Rebecca) Xuefei YUAN" <xy2102 at columbia.edu> wrote:
> Dear Jed,
>
> I have one more question, what is the difference or how could I know
> whether I need DAGetArray() or DAGetLocalVector()+DAVecGetArray() to
> get my array?
You can use the former unless you need to use it when packed up in a
vector.
In a mulitlevel scheme, I would probably put something like this in my
FormFunction:
DA da = (DA)dmmg->dm,eda;
PetscObjectQuery((PetscObject)da,"ExtraDA",(PetscObject*)&eda);
if (!eda) {
// create eda based on the layout of da
PetscObjectCompose((PetscObject)da,"ExtraDA",eda);
DADestroy(eda); // give away ownership
}
DAGetArray(eda,PETSC_TRUE,&extrafield); // or FALSE if you don't need ghost values
...
DARestoreArray(eda,PETSC_TRUE,&extrafield);
This way the memory is only allocated once, it will work with multiple
levels, and get cleaned up when you are done.
Jed
More information about the petsc-users
mailing list