# Discretisation

For the discretisation of an equation, one has basically to define a Finite Element space - or more precisely, a tensor product of finite element spaces. These mathematical structures are realised in FEAT2 by two "discretisation" structures:

`t_scalarDiscretisation`

(spatialdiscretisation.f90)- Encapsules a finite element space $V_h$ over a mesh, e.g., the $Q_1$ space.
- Is connected to a mesh, (possibly) a domain description and transformation rules from reference to real elements.

`t_blockDiscretisation`

(spatialdiscretisation.f90)- Encapsules tensor product spaces of finite element spaces, e.g., $X_h = V_h \times V_h$.
- Is realised as a list of
`t_scalarDiscretisation`

structures, each describing a finite element subspace in $X_h$. - Is connected to a mesh and (possibly) a domain description.

Routines in the FEAT library are usually based on `t_blockDiscretisation`

as this structure resembles the finite element space of the complete equation.

Special case:Also simple equations like the Poisson equation are realised by`t_blockDiscretisation`

although they contain only one finite element space. Such an equation is realised using a 1-block tensor product space $X_h$ = $V_h$ and results in the end in a 1x1 block matrix with 1 block in the corresponding block vectors.

## Uniform and conformal discretisations

Currently, FEAT2 supports *uniform* and *conformal* discretisations:

**Uniform discretisations**contain only one type of finite element for all cells. The transformation rule is the same for all cells. All cells have the same shape, i.e., "mixed" triangulations (like triangles and quads in the same mesh) are not allowed. Hanging nodes are not allowed.**Conformal discretisations**extend uniform discretisations. It is popssible to mix different type of cells (e.g. triangles and quads) in one mesh. However, hanging nodes are not allowed. All types of finite elements that are used must be "compatible" in terms of degrees of freedom. So it is possible to use a mixed triangle/quad mesh with P1/Q1. However, mixing P1 with Q2 is not possible as the degrees of freedom are not compatible.

Example for a uniform discretisation.All cells are quads and discretised with the same finite element space $Q_1$.

Example for a conformal discretisation.Mixed triangle/quad mesh, discretised with $P_1$ and $Q_1$. The finite element spaces are chosen in such a way that the degrees of freedom match, here, in the vertices.

## Working with finite element spaces

For the creation of finite element spaces, at least a triangulation is needed - this is called `rtriangulation`

in the following. The module `spatialdiscretisation.f90`

contains a couple of methods to create discretisation structures.

A finite element space is always identified by an "element-ID". All element constants are defined in the module `element.f90`

. The following tables contain an extract of finite element spaces supported by FEAT2.

### 1D elements

Element-ID | Type of the element |
---|---|

EL_P0_1D | $P_0$, piecewise constant |

EL_P1_1D | $P_1$, piecewise linear |

EL_P2_1D | $P_2$, piecewise quadratic |

### 2D elements

Element-ID | Shape | Conforming | Parametric | Type |
---|---|---|---|---|

EL_P0_2D | triangle | X | X | $P_0$, piecewise constant |

EL_P1_2D | X | X | $P_1$, piecewise linear | |

EL_P2_2D | X | X | $P_2$, piecewise quadratic | |

EL_P3_2D | X | X | $P_3$, piecewise cubic | |

EL_P1T_2D | X | Crouzeix-Raviart | ||

EL_Q0_2D | quad | X | X | $Q_0$, piecewise constant |

EL_Q1_2D | X | X | $Q_1$, piecewise linear | |

EL_Q2_2D | X | X | $Q_2$, piecewise quadratic | |

EL_Q3_2D | X | X | $Q_3$, piecewise cubic | |

EL_QP1_2D | X | $P_1^\text{disc}$, piecewise linear | ||

EL_E030_2D | $\tilde Q_1$, integral mean value based | |||

EL_E031_2D | $\tilde Q_1$, midpoint-based | |||

EL_EM30_2D | $\tilde Q_1$, integral mean value based | |||

EL_EM31_2D | $\tilde Q_1$, midpoint-based |

### 3D elements

Element-ID | Shape | Conforming | Parametric | Type |
---|---|---|---|---|

EL_P0_3D | tetra | X | X | $P_0$, piecewise constant |

EL_P1_3D | X | X | $P_1$, piecewise linear | |

EL_P2_3D | X | X | $P_2$, piecewise quadratic | |

EL_P3_3D | X | X | $P_3$, piecewise cubic | |

EL_Q0_3D | hex | X | X | $Q_0$, piecewise constant |

EL_Q1_3D | X | X | $Q_1$, piecewise linear | |

EL_Q2_3D | X | X | $Q_2$, piecewise quadratic | |

EL_Q3_3D | X | X | $Q_3$, piecewise cubic | |

EL_QP1_2D | X | $P_1^\text{disc}$, piecewise linear | ||

EL_E030_3D | X | $\tilde Q_1$, integral mean value based | ||

EL_E031_3D | X | $\tilde Q_1$, midpoint-based | ||

EL_EM30_3D | $\tilde Q_1$, integral mean value based | |||

EL_EM31_3D | $\tilde Q_1$, midpoint-based |

Using the element-ID, a finite element space can be initialised. The module `spatialdiscretisation.f90`

contains a set of routines to create an appropriate `t_scalarDiscretisation`

structure:

The following command creates a uniform discretisation with $Q_1$ in 2D based on a mesh

`rtriangulation`

. THe mesh is expected to contain only quads. The discretisation structure`rspatialDiscr`

identifies the finite element space:`type(t_spatialDiscretisation) :: rspatialDiscr ... call spdiscr_initDiscr_simple (rspatialDiscr,EL_Q1_2D,rtriangulation)`

If the triangulation is releated to an analytical description of the boundary

`rboundary`

, this description has to be specified as well:`type(t_spatialDiscretisation) :: rspatialDiscr ... call spdiscr_initDiscr_simple (rspatialDiscr,EL_Q1_2D,rtriangulation,rboundary)`

If the mesh contains triangles and quads, a mixed discretisation has to be created. This is done by the following command, where two finite element identifiers are specified. The example creates a mixed 2D finite element space with $P_1$ to be used for triangles and $Q_1$ for quads:

`type(t_spatialDiscretisation) :: rspatialDiscr ... call spdiscr_initDiscr_simple (rspatialDiscr,& EL_P1_2D,EL_Q1_2D,rtriangulation)`

If the triangulation is releated to an analytical description of the boundary

`rboundary`

, this description has to be specified as well:`type(t_spatialDiscretisation) :: rspatialDiscr ... call spdiscr_initDiscr_simple (rspatialDiscr,& EL_P1_2D,EL_Q1_2D,rtriangulation,rboundary)`

To release a finite element space the routine `spdiscr_releaseDiscr`

has to be used:

```
call spdiscr_releaseDiscr (rspatialDiscr)
```

## Working with tensor product spaces

Having defined a set of finite element spaces, a tensor product space (identified by a `t_blockDiscretisation`

structure) can be initialised. This procedure requires three steps: Creation of an empty tensor product space, adding all subspaces and finishing the creation.

The following example demonstrates the creation of a tensor product space $X_h = V_h \times W_h$, where $V_h$ and $W_h$ are identified by `rspatialDiscrVh`

and `rspatialDiscrWh`

, respectively. Similar to the creation of a finite element space above, a triangulation and (possibly) a domain definition has to be specified for the creation of the tensor product space:

```
type(t_spatialDiscretisation) :: rspatialDiscrVh, rspatialDiscrWh
type(t_blockDiscretisation) :: rblockDiscr
...
call spdiscr_initBlockDiscr (rblockDiscr, rtriangulation, rboundary)
call spdiscr_appendBlockComponent (rblockDiscr, rspatialDiscrVh)
call spdiscr_appendBlockComponent (rblockDiscr, rspatialDiscrWh)
call spdiscr_commitBlockDiscr (rblockDiscr)
```

The tensor product space can be released using `spdiscr_releaseBlockDiscr`

:

```
call spdiscr_releaseBlockDiscr (rblockDiscr)
```

Remark:If the tensor product space contains a finite element space multiple times, the creation can be simplified. The following example creates a tensor product space $X_h = V_h \times V_h \times V_h \times W_h$:

```
type(t_spatialDiscretisation) :: rspatialDiscrVh, rspatialDiscrWh
type(t_blockDiscretisation) :: rblockDiscr
...
call spdiscr_initBlockDiscr (rblockDiscr, rtriangulation, rboundary)
call spdiscr_appendBlockComponent (rblockDiscr, rspatialDiscrVh, 3)
call spdiscr_appendBlockComponent (rblockDiscr, rspatialDiscrWh)
call spdiscr_commitBlockDiscr (rblockDiscr)
```