[petsc-users] valgrind errors.

(Rebecca) Xuefei YUAN xy2102 at columbia.edu
Tue Jan 19 12:33:02 CST 2010


What if the dof of da is 4 and the dof of eda is 6?


Quoting Jed Brown <jed at 59A2.org>:

> 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
>
>



-- 
(Rebecca) Xuefei YUAN
Department of Applied Physics and Applied Mathematics
Columbia University
Tel:917-399-8032
www.columbia.edu/~xy2102



More information about the petsc-users mailing list