Skip to main content
`Ctrl`+`K`

# DMSetField

Set the discretization object for a given `DM` field. Usually one would call `DMAddField()` which automatically handles the field numbering.

## Synopsis

    #include "petscdm.h"
    #include "petscdmlabel.h"
    #include "petscds.h"
    PetscErrorCode DMSetField(DM dm, PetscInt f, DMLabel label, PetscObject disc)

Logically Collective

## Input Parameters

- dm - The `DM`

- f - The field number

- label - The label indicating the support of the field, or `NULL` for the entire mesh

- disc - The discretization object

## See Also

DM Basics, `DM`, `DMAddField()`, `DMGetField()`

## Level

intermediate

## Location

src/dm/interface/dm.c

## Examples

src/snes/tutorials/ex13.c
src/snes/tutorials/ex64.c
src/dm/impls/plex/tutorials/ex4f90.F90
src/snes/tutorials/ex11.c
src/snes/tutorials/ex12.c
src/dm/field/tutorials/ex1.c
src/dm/dt/dualspace/impls/lagrange/tutorials/ex2.c
src/dm/impls/swarm/tutorials/ex1f90.F90
src/dm/impls/swarm/tutorials/ex1.c
src/snes/tutorials/ex17.c

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