[petsc-users] Adding vectors of different dimension
    Barry Smith 
    bsmith at mcs.anl.gov
       
    Tue Jul 17 13:31:06 CDT 2012
    
    
  
On Jul 17, 2012, at 4:31 AM, TAY wee-beng wrote:
> Hi,
> 
> I have 3 vectors of different dimension, create using 2 DM (da_dof1,da_dof2), with dof = 1 and 2.
> 
> They are declared as:
> 
> Vec u,v,duv
> 
> call DMCreateLocalVector(da_dof1,u,ierr)
> 
> call DMCreateLocalVector(da_dof1,v,ierr)
> 
> call DMCreateLocalVector(da_dof2,duv,ierr)
> 
> How can I add duv to u and v to get new values for u,v?
> 
> I'm currently using DMDAVecGetArrayF90 and DMDAVecRestoreArrayF90 to access the arrays.
   Then you just need to write the FORTARAN code to do this. Loop over the local indices  and do something like
        uarray(i,j) =  uarray(i,j)  + duvarray(0,i,j)
       varray(i,j) =  varray(i,j)  + duvarray(1,i,j)
       
> 
> Thanks
> 
> -- 
> Yours sincerely,
> 
> TAY wee-beng
> 
    
    
More information about the petsc-users
mailing list