Skip to main content
`Ctrl`+`K`

# VecGhostUpdateEnd

End the vector scatter to update the vector from local representation to global or global representation to local.

## Synopsis

    #include "petscvec.h"
    PetscErrorCode VecGhostUpdateEnd(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` (update ghosts) or `SCATTER_REVERSE` (update local values from ghosts)

## Notes

Use the following to update the ghost regions with correct values from the owning process

           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

           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 later followed by the former, i.e.,

           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

Vectors and Parallel Data, `Vec`, `VecType`, `VecCreateGhost()`, `VecGhostUpdateBegin()`, `VecGhostGetLocalForm()`, `VecGhostRestoreLocalForm()`, `VecCreateGhostWithArray()`

## Level

advanced

## Location

src/vec/vec/impls/mpi/commonmpvec.c

## Examples

src/vec/vec/tutorials/ex9f.F90
src/vec/vec/tutorials/ex9.c
src/snes/tutorials/ex42.c
src/vec/vec/tutorials/ex14f.F90

Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages