# PetscGhostExchange

This functions transfers data between local and ghost storage without a predefined mapping.

### Synopsis

    int PetscGhostExchange(MPI_Comm comm, int numGhosts, int *ghostProcs, int *ghostIndices, PetscDataType dataType,
                          int *firstVar, InsertMode addv, ScatterMode mode, void *locVars, void *ghostVars)

Collective on MPI_Comm

### Input Parameters

| comm | - The communicator
| numGhosts | - The number of ghosts in this domain
| ghostProcs | - The processor from which to obtain each ghost
| ghostIndices | - The global index for each ghost
| dataType | - The type of the variables
| firstVar | - The first variable on each processor
| addv | - The insert mode, INSERT_VALUES or ADD_VALUES
| mode | - The direction of the transfer, SCATTER_FORWARD or SCATTER_REVERSE

### Output Parameters

| locVars | - The local variable array
| ghostVars | - The ghost variables

### Note

The data in ghostVars is assumed contiguous and implicitly indexed by the order of ghostProcs and ghostIndices. The SCATTER_FORWARD mode will take the requested data from locVars and copy it to ghostVars in the order specified by ghostIndices. The SCATTER_REVERSE mode will take data from ghostVars and copy it to locVars.

### Keywords

ghost, exchange

### See Also

GridGlobalToLocal(), GridLocalToGlobal()

Level:advanced
Location: src/sys/src/utils/ghost.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages