VecCreateGhost — PETSc 3.25.2 documentation

Skip to main content
`Ctrl`+`K`

# VecCreateGhost

Creates a parallel vector with ghost padding on each processor.

## Synopsis

    #include "petscvec.h"
    PetscErrorCode VecCreateGhost(MPI_Comm comm, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[], Vec *vv)

Collective

## Input Parameters

- comm - the MPI communicator to use

- n - local vector length

- N - global vector length (or `PETSC_DETERMINE` to have calculated if `n` is given)

- nghost - number of local ghost points

- ghosts - global indices of ghost points, these do not need to be in increasing order (sorted)

## Output Parameter

- vv - the global vector representation (without ghost points as part of vector)

## Notes

Use `VecGhostGetLocalForm()` to access the local, ghosted representation of the vector.

This also automatically sets the `ISLocalToGlobalMapping()` for this vector.

## See Also

Vectors and Parallel Data, `Vec`, `VecType`, `VecCreateSeq()`, `VecCreate()`, `VecDuplicate()`, `VecDuplicateVecs()`, `VecCreateMPI()`, `VecGhostGetLocalForm()`, `VecGhostRestoreLocalForm()`, `VecGhostUpdateBegin()`, `VecCreateGhostWithArray()`, `VecCreateMPIWithArray()`, `VecGhostUpdateEnd()`, `VecCreateGhostBlock()`, `VecCreateGhostBlockWithArray()`, `VecMPISetGhost()`

## Level

advanced

## Location

src/vec/vec/impls/mpi/pbvec.c

## Examples

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

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