<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 /ksp/ksp/examples/tutorials/ex22.c</div><div>where I have to use the PETSC defined function 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. </div></div><div><br></div><div>ComputeRHS(DMMG,Vec)</div><div>{</div><div> PetscFunctionBegin;</div><div> h =
1.0/((mx-1)*(my-1)*(mz-1));</div><div> </div><div>opt 1) PETSC_Provided: ierr = VecSet(b,h);CHKERRQ(ierr);</div><div><div>opt 2) Value from my Vector: ierr= VecCopy(globalVec,b);</div><div><br></div><div>VecView(b); //I can see that the value has been copied to b</div><div><br></div></div><div> PetscFunctionReturn(0);</div><div>}</div><div><br></div><div>I have also tried copying element by element using </div><div><div><br></div><div>row=0;</div><div>for (k=zs; k<zs+zm; k++) {</div><div> for (j=ys; j<ys+ym; j++) {</div><div> for (i=xs; i<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> 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 ?</div><div><br></div><div>Thanks in advance.</div><div><br></div><div>Khalid </div><div><br></div></div><div style="position:fixed"></div>
</div><br>
</body></html>