# refine.MESH.2D: Refine a triangular mesh In fdaPDE: Functional Data Analysis and Partial Differential Equations; Statistical Analysis of Functional and Spatial Data, Based on Regression with Partial Differential Regularizations

## Description

This function refines a Constrained Delaunay triangulation into a Conforming Delaunay triangulation. This is a wrapper of the Triangle library (http://www.cs.cmu.edu/~quake/triangle.html). It can be used to refine a mesh created previously with create.MESH.2D. The algorithm can add Steiner points (points through which the `segments` are splitted) in order to meet the imposed refinement conditions.

## Usage

 `1` ```refine.MESH.2D(mesh, minimum_angle, maximum_area, delaunay, verbosity) ```

## Arguments

 `mesh` A MESH2D object representing the triangular mesh, created by create.MESH.2D. `minimum_angle` A scalar specifying a minimun value for the triangles angles. `maximum_area` A scalar specifying a maximum value for the triangles areas. `delaunay` A boolean parameter indicating whether or not the output mesh should satisfy the Delaunay condition. `verbosity` This can be '0', '1' or '2'. It indicates the level of verbosity in the triangulation process.

## Value

A MESH2D object representing the refined triangular mesh, with the following output:

 `nodes` A #nodes-by-2 matrix containing the x and y coordinates of the mesh nodes. `nodesmarkers` A vector of length #nodes, with entries either '1' or '0'. An entry '1' indicates that the corresponding node is a boundary node; an entry '0' indicates that the corresponding node is not a boundary node. `nodesattributes` nodesattributes A matrix with #nodes rows containing nodes' attributes. These are passed unchanged to the output. If a node is added during the triangulation process or mesh refinement, its attributes are computed by linear interpolation using the attributes of neighboring nodes. This functionality is for instance used to compute the value of a Dirichlet boundary condition at boundary nodes added during the triangulation process. `triangles` A #triangles-by-3 (when `order` = 1) or #triangles-by-6 (when `order` = 2) matrix. This option is used when a triangulation is already available. It specifies the triangles giving the row's indices in `nodes` of the triangles' vertices and (when `nodes` = 2) also if the triangles' edges midpoints. The triangles' vertices and midpoints are ordered as described at https://www.cs.cmu.edu/~quake/triangle.highorder.html. `edges` A #edges-by-2 matrix. Each row contains the row's indices of the nodes where the edge starts from and ends to. `edgesmarkers` A vector of lenght #edges with entries either '1' or '0'. An entry '1' indicates that the corresponding element in `edge` is a boundary edge; an entry '0' indicates that the corresponding edge is not a boundary edge. `neighbors` A #triangles-by-3 matrix. Each row contains the indices of the three neighbouring triangles. An entry '-1' indicates that one edge of the triangle is a boundary edge. `holes` A #holes-by-2 matrix containing the x and y coordinates of a point internal to each hole of the mesh. These points are used to carve holes in the triangulation, when the domain has holes. `order` Either '1' or '2'. It specifies wether each mesh triangle should be represented by 3 nodes (the triangle' vertices) or by 6 nodes (the triangle's vertices and midpoints). These are respectively used for linear (order = 1) and quadratic (order = 2) Finite Elements. Default is `order` = 1.

`create.MESH.2D`, `create.FEM.basis`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10``` ```## Upload the Meuse data and a domain boundary for these data data(MeuseData) data(MeuseBorder) ## Create a Constrained Delaunay triangulation mesh <- create.MESH.2D(nodes = MeuseData[,c(2,3)], segments = MeuseBorder, order = 1) ## Plot the mesh plot(mesh) ## Refine the triangulation mesh_refine <- refine.MESH.2D(mesh, minimum_angle = 30, maximum_area = 10000) plot(mesh_refine) ```

### Example output

```Loading required package: rgl
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE