On Sat, Dec 17, 2011 at 8:55 AM, Juha Jäykkä <span dir="ltr"><<a href="mailto:juhaj@iki.fi">juhaj@iki.fi</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all!<br>
<br>
I am at a loss: my vector entries get zeroed when I am not even using the<br>
vector.<br></blockquote><div><br></div><div>This is memory overwriting. Use valgrind to find it.</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have the vectors:<br>
<br>
ierr = DACreateGlobalVector(lattice.da, &Fields); CHKERRQ(ierr);<br>
ierr = VecDuplicate(Fields, &lattice.prev_state); CHKERRQ(ierr);<br>
...<br>
TSSolve(lattice.ts, Fields);<br>
<br>
Later on, in a my RHS function PETSc has kindly provided me with my<br>
"lattice.da" as part of my context (it is now called simply "da"), it has also<br>
given me Fields, so I can do:<br>
<br>
DALocalInfo l_da;<br>
ahcs_field ***fields, ***rhs, ***pfields;<br>
Vec lfields, lpfields;<br>
begin_using_petsc_DA_step_1(da, &l_da, Fields, &lfields, &fields);<br>
<br>
where<br>
<br>
PetscErrorCode begin_using_petsc_DA_step_1(DA da, DALocalInfo *l_da, Vec<br>
Fields, Vec *lfields, void *fields) {<br>
<br>
PetscErrorCode ierr;<br>
ierr = DAGetLocalInfo(da, l_da); CHKERRQ(ierr);<br>
ierr = DAGetLocalVector(da, lfields); CHKERRQ(ierr);<br>
ierr = DAGlobalToLocalBegin(da, Fields, INSERT_VALUES, *lfields);<br>
<br>
At this point, the other vector in lattice.prev_state gets (some of) its<br>
entries zeroed!<br>
<br>
What am I doing wrong? Obviously, DAGlobalToLocalBegin working on Fields<br>
should not alter anything in a duplicated vector, let alone INTERNAL values of<br>
that vector (i.e. non-ghost points, which is what happens here).<br>
<br>
Cheers,<br>
Juha<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
-----------------------------------------------<br>
| Juha Jäykkä, <a href="mailto:juhaj@iki.fi">juhaj@iki.fi</a> |<br>
| <a href="http://www.maths.leeds.ac.uk/~juhaj" target="_blank">http://www.maths.leeds.ac.uk/~juhaj</a> |<br>
-----------------------------------------------<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>