# DMStagVecGetArray
get access to local array 
## Synopsis
```
PetscErrorCode DMStagVecGetArray(DM dm, Vec vec, void *array)
```
Logically Collective

This function returns a (dim+1)-dimensional array for a dim-dimensional
DMStag.

The first 1-3 dimensions indicate an element in the global
numbering, using the standard C ordering.

The final dimension in this array corresponds to a degree
of freedom with respect to this element, for example corresponding to
the element or one of its neighboring faces, edges, or vertices.

For example, for a 3D DMStag, indexing is `array[k][j][i][idx]`, where `k` is the
index in the z-direction, `j` is the index in the y-direction, and `i` is the
index in the x-direction.

`idx` is obtained with `DMStagGetLocationSlot()`, since the correct offset
into the $(d+1)$-dimensional C array for a $d$-dimensional DMStag depends on the grid size and the number
of DOF stored at each location.


## Input Parameters

- ***dm -*** the DMStag object
- ***vec -*** the `Vec` object



## Output Parameters

- ***array -*** the array



## Notes
`DMStagVecRestoreArray()` must be called, once finished with the array




## See Also
 `DMSTAG`, `DMStagVecGetArrayRead()`, `DMStagGetLocationSlot()`, `DMGetLocalVector()`, `DMCreateLocalVector()`, `DMGetGlobalVector()`, `DMCreateGlobalVector()`, `DMDAVecGetArray()`, `DMDAVecGetArrayDOF()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/stagutils.c.html#DMStagVecGetArray">src/dm/impls/stag/stagutils.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex1.c.html">src/dm/impls/stag/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex2.c.html">src/dm/impls/stag/tutorials/ex2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex3.c.html">src/dm/impls/stag/tutorials/ex3.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex4.c.html">src/dm/impls/stag/tutorials/ex4.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex6.c.html">src/dm/impls/stag/tutorials/ex6.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/impls/stag/stagutils.c)


[Index of all DMStag routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
