[petsc-users] Vec entries altered incorrectly

Juha Jäykkä juhaj at iki.fi
Sat Dec 17 08:55:48 CST 2011

Hi all!

I am at a loss: my vector entries get zeroed when I am not even using the 

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


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


		| Juha Jäykkä, juhaj at iki.fi			|
		| http://www.maths.leeds.ac.uk/~juhaj		|
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111217/8c620da4/attachment.pgp>

More information about the petsc-users mailing list