<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:12pt"><div><div>Hi, I am trying to use the DMMG solver in&nbsp;/ksp/ksp/examples/tutorials/ex22.c</div><div>where I have to use the PETSC defined function&nbsp;ComputeRHS.</div><div><div>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.&nbsp;</div></div><div><br></div><div>ComputeRHS(DMMG,Vec)</div><div>{</div><div>&nbsp;&nbsp;PetscFunctionBegin;</div><div>&nbsp;&nbsp;h &nbsp; &nbsp;=
 1.0/((mx-1)*(my-1)*(mz-1));</div><div>&nbsp;</div><div>opt 1) PETSC_Provided: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ierr = VecSet(b,h);CHKERRQ(ierr);</div><div><div>opt 2) Value from my Vector: &nbsp; &nbsp; &nbsp;ierr= &nbsp;VecCopy(globalVec,b);</div><div><br></div><div>VecView(b); &nbsp; //I can see that the value has been copied to b</div><div><br></div></div><div>&nbsp;&nbsp;PetscFunctionReturn(0);</div><div>}</div><div><br></div><div>I have also tried copying element by element using&nbsp;</div><div><div><br></div><div>row=0;</div><div>for (k=zs; k&lt;zs+zm; k++) {</div><div>&nbsp;&nbsp;for (j=ys; j&lt;ys+ym; j++) {</div><div>&nbsp;&nbsp;for (i=xs; i&lt;xs+xm; i++) {</div><div>temp=vec_globalptr[k][j][i];</div><div>VecSetValue(b,row,temp,INSERT_VALUES);</div></div><div>row=row+1;</div><div>}</div><div>ierr = VecAssemblyBegin(b);CHKERRQ(ierr);</div><div>ierr = VecAssemblyEnd(b);CHKERRQ(ierr);</div><div><br></div><div>&nbsp;In this case as well I
 can see that the&nbsp;values have been added into vector b, but the DMMG solve produces all zeros for DMMGGetx(); Any suggestions ?</div><div><br></div><div>Thanks in advance.</div><div><br></div><div>Khalid &nbsp;</div><div><br></div></div><div style="position:fixed"></div>


</div><br>

      </body></html>