# VecGhostUpdateBegin
Begins the vector scatter to update the vector from local representation to global or global representation to local. 
## Synopsis
```
#include "petscvec.h"   
PetscErrorCode VecGhostUpdateBegin(Vec g, InsertMode insertmode, ScatterMode scattermode)
```
Neighbor-wise Collective


## Input Parameters

- ***g -*** the vector (obtained with `VecCreateGhost()` or `VecDuplicate()`)
- ***insertmode -*** one of ADD_VALUES, MAX_VALUES, MIN_VALUES or INSERT_VALUES
- ***scattermode -*** one of SCATTER_FORWARD or SCATTER_REVERSE



## Notes
Use the following to update the ghost regions with correct values from the owning process
```none
       VecGhostUpdateBegin(v,INSERT_VALUES,SCATTER_FORWARD);
       VecGhostUpdateEnd(v,INSERT_VALUES,SCATTER_FORWARD);
```


Use the following to accumulate the ghost region values onto the owning processors
```none
       VecGhostUpdateBegin(v,ADD_VALUES,SCATTER_REVERSE);
       VecGhostUpdateEnd(v,ADD_VALUES,SCATTER_REVERSE);
```


To accumulate the ghost region values onto the owning processors and then update
the ghost regions correctly, call the latter followed by the former, i.e.,
```none
       VecGhostUpdateBegin(v,ADD_VALUES,SCATTER_REVERSE);
       VecGhostUpdateEnd(v,ADD_VALUES,SCATTER_REVERSE);
       VecGhostUpdateBegin(v,INSERT_VALUES,SCATTER_FORWARD);
       VecGhostUpdateEnd(v,INSERT_VALUES,SCATTER_FORWARD);
```





## See Also
 `VecCreateGhost()`, `VecGhostUpdateEnd()`, `VecGhostGetLocalForm()`,
`VecGhostRestoreLocalForm()`, `VecCreateGhostWithArray()`


## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/mpi/commonmpvec.c.html#VecGhostUpdateBegin">src/vec/vec/impls/mpi/commonmpvec.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex14f.F90.html">src/vec/vec/tutorials/ex14f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex9.c.html">src/vec/vec/tutorials/ex9.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex9f.F90.html">src/vec/vec/tutorials/ex9f.F90.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/impls/mpi/commonmpvec.c)


[Index of all Vec routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
