[petsc-users] Vec entries altered incorrectly

Matthew Knepley knepley at gmail.com
Sat Dec 17 09:50:07 CST 2011


On Sat, Dec 17, 2011 at 8:55 AM, Juha Jäykkä <juhaj at iki.fi> wrote:

> Hi all!
>
> I am at a loss: my vector entries get zeroed when I am not even using the
> vector.
>

This is memory overwriting. Use valgrind to find it.

   Matt


> I have the vectors:
>
>  ierr = DACreateGlobalVector(lattice.da, &Fields); CHKERRQ(ierr);
>  ierr = VecDuplicate(Fields, &lattice.prev_state); CHKERRQ(ierr);
> ...
>  TSSolve(lattice.ts, Fields);
>
> Later on, in a my RHS function PETSc has kindly provided me with my
> "lattice.da" as part of my context (it is now called simply "da"), it has
> also
> given me Fields, so I can do:
>
>  DALocalInfo l_da;
>  ahcs_field    ***fields, ***rhs, ***pfields;
>  Vec           lfields, lpfields;
>  begin_using_petsc_DA_step_1(da, &l_da, Fields, &lfields, &fields);
>
> where
>
> PetscErrorCode begin_using_petsc_DA_step_1(DA da, DALocalInfo *l_da, Vec
> Fields, Vec *lfields, void *fields) {
>
>  PetscErrorCode ierr;
>  ierr = DAGetLocalInfo(da, l_da); CHKERRQ(ierr);
>  ierr = DAGetLocalVector(da, lfields); CHKERRQ(ierr);
>  ierr = DAGlobalToLocalBegin(da, Fields, INSERT_VALUES, *lfields);
>
> At this point, the other vector in lattice.prev_state gets (some of) its
> entries zeroed!
>
> What am I doing wrong? Obviously, DAGlobalToLocalBegin working on Fields
> should not alter anything in a duplicated vector, let alone INTERNAL
> values of
> that vector (i.e. non-ghost points, which is what happens here).
>
> Cheers,
> Juha
>
> --
>                 -----------------------------------------------
>                | Juha Jäykkä, juhaj at iki.fi                     |
>                | http://www.maths.leeds.ac.uk/~juhaj           |
>                 -----------------------------------------------
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111217/ce79b81a/attachment.htm>


More information about the petsc-users mailing list