:orphan:
# DMCreateLocalVector
Creates a local vector from a `DM` object.
## Synopsis
```
#include "petscdm.h"
#include "petscdmlabel.h"
#include "petscds.h"
PetscErrorCode DMCreateLocalVector(DM dm, Vec *vec)
```
Not Collective
## Input Parameter
- ***dm -*** the `DM` object
## Output Parameter
- ***vec -*** the local vector
## Note
A local vector usually has ghost locations that contain values that are owned by different MPI ranks. A global vector has no ghost locations.
## See Also
[](ch_dmbase), `DM`, `Vec`, `DMCreateGlobalVector()`, `DMGetLocalVector()`, `DMDestroy()`, `DMView()`, `DMCreateInterpolation()`, `DMCreateColoring()`, `DMCreateMatrix()`
`DMGlobalToLocalBegin()`, `DMGlobalToLocalEnd()`
## Level
beginner
## Location
src/dm/interface/dm.c
## Examples
src/dm/field/tutorials/ex1.c
src/dm/impls/plex/tutorials/ex14.c
src/dm/tutorials/ex1.c
src/dm/tutorials/ex13f90.F90
src/dm/tutorials/ex2.c
src/dm/tutorials/ex5.c
src/dm/tutorials/ex6.c
src/dm/tutorials/ex7.c
src/dm/tutorials/ex9.c
src/ksp/ksp/tutorials/ex14f.F90
src/ksp/ksp/tutorials/ex42.c
## Implementations
DMCreateLocalVector_Composite in src/dm/impls/composite/pack.c
DMCreateLocalVector_DA in src/dm/impls/da/dalocal.c
DMCreateLocalVector_pforest in src/dm/impls/forest/p4est/pforest.h
DMCreateLocalVector_Moab in src/dm/impls/moab/dmmbvec.cxx
DMCreateLocalVector_Network in src/dm/impls/network/networkcreate.c
DMCreateLocalVector_Patch in src/dm/impls/patch/patch.c
DMCreateLocalVector_Plex in src/dm/impls/plex/plexcreate.c
DMCreateLocalVector_Redundant in src/dm/impls/redundant/dmredundant.c
DMCreateLocalVector_Shell in src/dm/impls/shell/dmshell.c
DMCreateLocalVector_Stag in src/dm/impls/stag/stag.c
DMCreateLocalVector_Swarm in src/dm/impls/swarm/swarm.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/interface/dm.c)
[Index of all DM routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)