On Nov 27, 2010, at 9:33 PM, khalid ashraf wrote:

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

   This should work fine. What are the results when you run with 
-ksp_monitor_true_residual -ksp_converged_reason 

   No error messages are generated when you run it?

   Barry


   


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

Reply via email to