[petsc-users] valgrind errors.
(Rebecca) Xuefei YUAN
xy2102 at columbia.edu
Tue Jan 19 12:57:06 CST 2010
Quoting Jed Brown <jed at 59A2.org>:
> On Tue, 19 Jan 2010 13:27:14 -0500, "(Rebecca) Xuefei YUAN"
> <xy2102 at columbia.edu> wrote:
>> Dear Jed,
>>
>> I switched the code as below and it is working now without valgrind errors.
>
> Great!
>
>> I am using multilevel, will the following approach be fine? I will
>> modify the code a little more to get sth like yours.
>
> It looks fine, but it does a bit of allocation/setup on each function
> evaluation. The snippet I gave would only do the setup once and do no
> allocations afterwards.
>
If I want to do it like your way, how could I handle the different dof
in the call
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);
Why eda is destroyed before I can use it in DAGetArray?
> Also note that you can VecZeroEntries() instead of your explicit zeroing
> loop.
>
>> What if the dof of da is 4 and the dof of eda is 6?
>
> No problem, just change 4 to 6 in:
>
>> ierr = DACreate2d(PETSC_COMM_WORLD,DA_NONPERIODIC,DA_STENCIL_BOX,
>> info.mx, info.my, PETSC_DECIDE, PETSC_DECIDE, 4, 2, 0, 0,
>> &dafieldother);CHKERRQ(ierr);
>
> I would use
>
> dof = sizeof(FieldOther)/sizeof(PetscScalar);
>
> so that it's always the correct size if I go change FieldOther. (And
> the entries in FieldOther should by PetscScalar if you want them to work
> correctly on a PETSc build with complex support.)
Is that mean PetscReal and PetscScalar are the same if it is not
complex, however, for a better compatible reason, should I change all
my PetscReal to PetscScalar?
>
> 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