# DMDAGetElements
Gets an array containing the indices (in local coordinates) of all the local elements 
## Synopsis
```
#include "petscdmda.h"   
PetscErrorCode DMDAGetElements(DM dm, PetscInt *nel, PetscInt *nen, const PetscInt *e[])
```
Not Collective


## Input Parameter

- ***dm -*** the `DMDA` object



## Output Parameters

- ***nel -*** number of local elements
- ***nen -*** number of element nodes
- ***e -*** the local indices of the elements' vertices





## Notes
Call `DMDARestoreElements()` once you have finished accessing the elements.

Each process uniquely owns a subset of the elements. That is no element is owned by two or more processes.

If on each process you integrate over its owned elements and use `ADD_VALUES` in `Vec`/`MatSetValuesLocal()` then you'll obtain the correct result.


## Fortran Note
Not supported in Fortran


## See Also
 `DM`, `DMDA`, `DMDAElementType`, `DMDASetElementType()`, `VecSetValuesLocal()`, `MatSetValuesLocal()`, `DMGlobalToLocalBegin()`, `DMLocalToGlobalBegin()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/da/dagetelem.c.html#DMDAGetElements">src/dm/impls/da/dagetelem.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex5.c.html">src/dm/tutorials/ex5.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex70.c.html">src/ksp/ksp/tutorials/ex70.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex71.c.html">src/ksp/ksp/tutorials/ex71.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/da/dagetelem.c.html#DMDAGetElements_1D">DMDAGetElements_1D in src/dm/impls/da/dagetelem.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/da/dagetelem.c.html#DMDAGetElements_2D">DMDAGetElements_2D in src/dm/impls/da/dagetelem.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/da/dagetelem.c.html#DMDAGetElements_3D">DMDAGetElements_3D in src/dm/impls/da/dagetelem.c</A><BR>


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


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