[petsc-users] valgrind errors.

Jed Brown jed at 59A2.org
Tue Jan 19 12:44:46 CST 2010

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.


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

Also note that you can VecZeroEntries() instead of your explicit zeroing

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

No problem, just change 4 to 6 in:

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


More information about the petsc-users mailing list