# Boundary Conditions

`JuAFEM.ConstraintHandler`

— Type`ConstraintHandler`

Collection of constraints.

`JuAFEM.Dirichlet`

— Type```
Dirichlet(u, ∂Ω, f)
Dirichlet(u, ∂Ω, f, component)
```

Create a Dirichlet boundary condition on `u`

on the `∂Ω`

part of the boundary. `f`

is a function that takes two arguments, `x`

and `t`

where `x`

is the spatial coordinate and `t`

is the current time, and returns the prescribed value. For example, here we create a Dirichlet condition for the `:u`

field, on the faceset called `∂Ω`

and the value given by the `sin`

function:

`dbc = Dirichlet(:u, ∂Ω, (x, t) -> sin(t))`

If `:u`

is a vector field we can specify which component the condition should be applied to by specifying `component`

. `component`

can be given either as an integer, or as a vector, for example:

```
dbc = Dirichlet(:u, ∂Ω, (x, t) -> sin(t), 1) # applied to component 1
dbc = Dirichlet(:u, ∂Ω, (x, t) -> sin(t), [1, 3]) # applied to component 1 and 3
```

`Dirichlet`

boundary conditions are added to a `ConstraintHandler`

which applies the condition via `apply!`

.

`JuAFEM.add!`

— Function`add!(ch::ConstraintHandler, dbc::Dirichlet)`

Add a `Dirichlet boundary`

condition to the `ConstraintHandler`

.

`JuAFEM.close!`

— Function`close!(dh::MixedDofHandler)`

Closes the dofhandler and creates degrees of freedom for each cell. Dofs are created in the following order: Go through each FieldHandler in the order they were added. For each field in the FieldHandler, create dofs for the cell. This means that dofs on a particular cell will be numbered according to the fields; first dofs for field 1, then field 2, etc.

`close!(ch::ConstraintHandler)`

Close and finalize the `ConstraintHandler`

.