[petsc-users] difference between local and global vectors

Barry Smith bsmith at mcs.anl.gov
Tue Aug 18 20:44:11 CDT 2015


  The global vectors are what the "algebraic solvers" TS/SNES/KSP see, while the local vectors are what you use to perform function evaluations and Jacobian evaluations needed by KSP, SNES, and TS, for example with SNESSetFunction(). 

  Barry

> On Aug 18, 2015, at 8:38 PM, TAY wee-beng <zonexo at gmail.com> wrote:
> 
> Hi,
> 
> I am using DA. For e.g.
> 
> DM da_u
> 
> call DMDACreate3d(MPI_COMM_WORLD,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DMDA_STENCIL_STAR,size_x,size_y,&
> 
> size_z,1,PETSC_DECIDE,PETSC_DECIDE,1,stencil_width,lx,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,da_u,ierr)
> 
> call DMCreateGlobalVector(da_u,u_global,ierr)
> 
> call DMCreateLocalVector(da_u,u_local,ierr)
> 
> To update the ghost values, I use:
> 
> call DMLocalToLocalBegin(da_u,u_local,INSERT_VALUES,u_local,ierr)
> 
> call DMLocalToLocalEnd(da_u,u_local,INSERT_VALUES,u_local,ierr)
> 
> It seems that I don't need to use global vector at all.
> 
> So what's the difference between local and global vector?
> 
> When will I need to use?:
> 
> call DMGlobalToLocalBegin(da_u,u_global,INSERT_VALUES,u_local,ierr)
> 
> call DMGlobalToLocalEnd(da_u,u_global,INSERT_VALUES,u_local,ierr)
> 
> -- 
> Thank you
> 
> Yours sincerely,
> 
> TAY wee-beng
> 



More information about the petsc-users mailing list