:orphan:
# DMAddField
Add a field to a `DM` object. A field is a function space defined by of a set of discretization points (geometric entities) and a discretization object that defines the function space associated with those points.
## Synopsis
```
#include "petscdm.h"
#include "petscdmlabel.h"
#include "petscds.h"
PetscErrorCode DMAddField(DM dm, DMLabel label, PetscObject disc)
```
Logically Collective
## Input Parameters
- ***dm -*** The `DM`
- ***label -*** The label indicating the support of the field, or `NULL` for the entire mesh
- ***disc -*** The discretization object
## Notes
The label already exists or will be added to the `DM` with `DMSetLabel()`.
For example, a piecewise continuous pressure field can be defined by coefficients at the cell centers of a mesh and piecewise constant functions
within each cell. Thus a specific function in the space is defined by the combination of a `Vec` containing the coefficients, a `DM` defining the
geometry entities, a `DMLabel` indicating a subset of those geometric entities, and a discretization object, such as a `PetscFE`.
## See Also
[](ch_dmbase), `DM`, `DMSetLabel()`, `DMSetField()`, `DMGetField()`, `PetscFE`
## Level
intermediate
## Location
src/dm/interface/dm.c
## Examples
src/dm/impls/plex/tutorials/ex8.c
src/ts/tutorials/ex11.c
src/ts/tutorials/ex52.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)