Skip to main content
`Ctrl`+`K`

# 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

## Notes

A local vector usually has ghost locations that contain values that are owned by different MPI ranks. A global vector has no ghost locations.

PETSc `Vec` always have all zero entries when created with `DMCreateLocalVector()` until routines such as `VecSet()` or `VecSetValues()` are used to change the values. There is no reason to call `VecZeroEntries()` after creation.

## See Also

DM Basics, `DM`, `Vec`, `DMCreateGlobalVector()`, `DMGetLocalVector()`, `DMDestroy()`, `DMView()`, `DMCreateInterpolation()`, `DMCreateColoring()`, `DMCreateMatrix()`, `DMGlobalToLocalBegin()`, `DMGlobalToLocalEnd()`

## Level

beginner

## Location

src/dm/interface/dm.c

## Examples

src/dm/tutorials/ex7.c
src/dm/tutorials/ex1.c
src/dm/impls/plex/tutorials/ex14f90.F90
src/dm/tutorials/ex13f90.F90
src/dm/impls/plex/tutorials/ex14.c
src/dm/tutorials/ex5.c
src/dm/tutorials/ex9.c
src/dm/tutorials/ex2.c
src/dm/tutorials/ex6.c
src/dm/field/tutorials/ex1.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

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