[petsc-users] Supplying the RHS Vector to the DMMG solver from outside

khalid ashraf khalid_eee at yahoo.com
Sat Nov 27 21:33:51 CST 2010


Hi, I am trying to use the DMMG solver in /ksp/ksp/examples/tutorials/ex22.c
where I have to use the PETSC defined function ComputeRHS.
Here instead of setting the constant value h, I want to copy the values from 
another Vector (associated with another DA, but same size). Hence I added the 
line opt 2) as shown below. I can see that the value has been copied into b, but 
the DMMG solve produces 0. Whereas opt 1) works fine. It seems like the problem 
could be due to copying from a vector associated with another DA. Could you 
please suggest what can be done to make it work. 

ComputeRHS(DMMG,Vec)
{
  PetscFunctionBegin;
  h    = 1.0/((mx-1)*(my-1)*(mz-1));
 
opt 1) PETSC_Provided:            ierr = VecSet(b,h);CHKERRQ(ierr);
opt 2) Value from my Vector:      ierr=  VecCopy(globalVec,b);

VecView(b);   //I can see that the value has been copied to b

  PetscFunctionReturn(0);
}

I have also tried copying element by element using 


row=0;
for (k=zs; k<zs+zm; k++) {
  for (j=ys; j<ys+ym; j++) {
  for (i=xs; i<xs+xm; i++) {
temp=vec_globalptr[k][j][i];
VecSetValue(b,row,temp,INSERT_VALUES);
row=row+1;
}
ierr = VecAssemblyBegin(b);CHKERRQ(ierr);
ierr = VecAssemblyEnd(b);CHKERRQ(ierr);

 In this case as well I can see that the values have been added into vector b, 
but the DMMG solve produces all zeros for DMMGGetx(); Any suggestions ?

Thanks in advance.

Khalid  



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101127/60ac24ab/attachment.htm>


More information about the petsc-users mailing list