Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox Chapter IntroductionD06 — Mesh Generation

## Scope of the Chapter

This chapter is concerned with automatic mesh generation
• with line segments, over the boundary of a closed two-dimensional connected polygonal domain;
• with triangles, over a given two-dimensional region using only its boundary mesh.

## Background to the Problems

An important area of scientific computing in engineering is the solution of partial differential equations of various type (for solid mechanics, fluid mechanics, thermal modelling, $\dots$) by means of the finite element method. In essence, the finite element method is a numerical technique which solves the governing equations of a complicated system through a discretization process. You may wish to consult Cheung et al. (1996) to see an application of the finite element method to solid mechanics and field problems.
A key requirement of the Finite Element method is a mesh, which subdivides the region on which the partial differential equations are defined. Note that such meshes are also essential to other discretization processes, such as the Finite Volume method. However, for the purpose this description we focus (without loss of generality) on the Finite Element method. Thus, meshing algorithms are of crucial importance in every numerical simulation based on the finite element method. In particular, the accuracy and even the validity of a solution is strongly tied to the properties of the underlying mesh of the domain under consideration.
In this chapter, the Delaunay constrained 2D$2D$ triangulation (see George and Borouchaki (1998) or Chapter 7 of Cheung et al. (1996)) is considered and functions are provided to triangulate a closed polygonal domain of 2${ℝ}^{2}$, given a mesh of its boundary (in a later Mark of the Library, software for the 3D$3D$ case will be available). A domain in 2${ℝ}^{2}$ is given via a discretization of its boundary. The boundary is described as a list of segments, with given end point coordinates. Then an incremental method is used to generate the set of interior vertices.
Let Ω$\Omega$ be a closed bounded domain in 2${ℝ}^{2}$ or 3${ℝ}^{3}$. The question is how to construct a triangulation (mesh) of this domain suitable for a finite element framework. Following the definition in George and Borouchaki (1998):
• T$\mathcal{T}$ is a mesh of Ω$\Omega$ if
• Ω = KTK.$\Omega ={\bigcup }_{K\in \mathcal{T}}K\text{.}$
• Every element K$K$ in T$\mathcal{T}$ is non-empty.
• The intersection of the interior of any two elements is empty.
• The intersection of any two elements in T$\mathcal{T}$ is either,
• the empty set,
• a vertex,
• an edge,
• a face (in 3${ℝ}^{3}$).
In the finite element method, the meshes are in general denoted T$\mathcal{T}$ or Th${\mathcal{T}}_{h}$, where the index h$h$ refers to a measure of the diameter (length of the longest edge) of the elements in the mesh. A triangulation is a set of entities described in a suitable manner by picking an adequate data structure. The algorithm for triangulation construction creates a table of elements in the triangulation as well as the neighbourhood relationships between the elements. Those elements are meant to satisfy the so-called ‘empty sphere criterion’ which means that the open ball associated with the element (the circumcircle of the triangle in 2D$2D$, and the circumsphere of the tetrahedron in 3D$3D$) does not contain any vertices (while the closed ball contains the vertices of the element in consideration only). This criterion is a characterisation of the Delaunay triangulation.
Given Ti${\mathcal{T}}_{i}$ the Delaunay triangulation of the convex hull of the first i$i$ points, the purpose of the incremental method (which is the main method to generate nodes and elements inside the domain) is to obtain Ti + 1${\mathcal{T}}_{i+1}$ the Delaunay triangulation which includes an (i + 1)$\left(i+1\right)$th point P$P$ as an element vertex. To this end, one can introduce a procedure referred to as the ‘Delaunay kernel’ construction. This kernel is
 Ti + 1 = Ti − CP + BP, $Ti+1=Ti-CP+BP,$
where BP${\mathcal{B}}_{P}$ is the ball associated with P$P$ and CP${\mathcal{C}}_{P}$ is the associated cavity. The ball associated with a given point P$P$ is the set of elements in the triangulation including P$P$ as a vertex, while the cavity is the set of elements whose circumcircles or circumballs enclose the point P$P$. One can prove that, given Ti${\mathcal{T}}_{i}$ a Delaunay triangulation of a convex hull of the first i$i$ points, then Ti + 1${\mathcal{T}}_{i+1}$ is a Delaunay triangulation of the hull that includes P$P$ as the (i + 1)$\left(i+1\right)$th vertex. The completion of a Delaunay triangulation relies on applying the Delaunay kernel procedure to every point.
The problems here are
• to choose the input data T0${\mathcal{T}}_{0}$ of the incremental method, and
• to generate at each iteration this (i + 1)$\left(i+1\right)$th point, such that Ti + 1${\mathcal{T}}_{i+1}$ is still a Delaunay triangulation of the convex hull of the (i + 1)$\left(i+1\right)$ points.
For a finite element application, it is required to construct a mesh of the domain Ω$\Omega$ whose elements are as close to equilateral as possible.
The mesh generation methods include an initial creation stage resulting in a mesh T0${\mathcal{T}}_{0}$, without internal points, except for any specified interior points (see George and Borouchaki (1998) for more details). Such a mesh is referred to as the ‘empty mesh’. This mesh consists of a box which includes the whole geometry plus some vertices on the edge of that box. From here the methods differ in how the required internal points are created.
The general principle of interior mesh generation is to either create a point and insert it immediately by means of the Delaunay method (the so-called Delaunay kernel), repeating the process as long as points can be created, or to generate a series of points, insert this series and iterate the process as long as a non-empty series is created. At this stage it is quite useful to define the notion of a control space to govern the internal point creation. The ‘ideal’ control is the input of a function defined analytically at any point of 2${ℝ}^{2}$ and which specifies the size and the direction features that must be conformed to anywhere in the space.
To construct such a function, one can consider several approaches. For our purpose in this chapter, this control function computes, from data, the local step sizes (the desired distance between two points) related to the given points. A generalized interpolation then enables us to obtain the function everywhere. This process is purely geometric in the sense that it relies only on the geometric data properties: boundary edge lengths, and so on. You are advised to consult George and Borouchaki (1998) for more details about this strategy, especially about the other approaches which can be considered to construct the control function.

## Recommendations on Choice and Use of Available Functions

### Boundary Mesh Generation

The first step to mesh any domain of 2${ℝ}^{2}$ or 3${ℝ}^{3}$ is to generate a mesh of the domain boundary. In this chapter, since only the 2D$2D$ case is considered, the relevant function is nag_mesh_2d_gen_boundary (d06ba). This function meshes with segments a boundary of a closed connected polygonal domain of 2${ℝ}^{2}$, given a set of characteristic points and characteristic lines which define the shape of the frontier. The boundary has to be partitioned into geometrically simple lines. Each line segment may be a straight line, a curve defined by an equation of the type f(x,y) = 0$f\left(x,y\right)=0$, or simply a polygonal curve, delimited by characteristic points (end points of the lines). Then, you can assemble those lines into connected components of the domain boundary.

### Interior Mesh Generation

In this chapter three functions are provided to mesh a domain given a discretization of its boundary with optionally specified interior points.
• nag_mesh_2d_gen_delaunay (d06ab) uses an internal point construction method along the internal edges. Using the control function, a small number of points are generated along each edge.
• nag_mesh_2d_gen_front (d06ac) uses a point creation method based on an advancing front point placement strategy, starting from the ‘empty mesh’.
• nag_mesh_2d_gen_inc (d06aa) uses a simple incremental method based on a control function given analytically via the argument power.
Any point construction method results in a set of points. These points are then inserted by means of the Delaunay kernel.
The point insertion process is completed by successive waves. The first wave results from the empty mesh edge analysis (edge method) or from the empty mesh front analysis (advancing front method). Subsequent waves correspond to the analysis of the edges of the previous mesh. For the advancing front strategy, the waves follow the analysis of the front associated with the current mesh.
One can propose a general scheme for a mesh generation method. Seven steps can be identified as follows.
• Preparation step.
• Data input: point coordinates, boundary edges and internal edges (if any),
• construction of the bounding box,
• meshing of this box by means of a few triangles.
• Construction of the box mesh.
• Insertion of the given points in the box mesh using the Delaunay kernel.
• Construction of the empty mesh.
• Search for the missing specified edges,
• enforcement of these edges,
• definition of the connected components of the domain.
• Internal point creation and point insertion.
• Control space definition,
• (1)$\left(1\right)$ internal edge analysis, point creation along these edges,
• point insertion via the Delaunay kernel and return to (1)$\left(1\right)$.
• Domain definition.
• Removal of the elements exterior to the domain,
• classification of the elements with respect to the connected components.
• Optimization.
• edge swapping,
• point relocation, $\dots$
• File output.
When using the advancing front approach described earlier, one has to replace the step denoted by (1)$\left(1\right)$ of the general scheme. The analysis of the edges of the current mesh is then replaced by the front analysis.
Due to the fact that the particular mesh generated by nag_mesh_2d_gen_inc (d06aa), nag_mesh_2d_gen_delaunay (d06ab) and nag_mesh_2d_gen_front (d06ac) may be sensitive to the platform being used; there may be differences between generated nodal coordinates and connectivities. However all meshes generated should be expected to satisfy the ‘empty sphere criterion’.

### Mesh Management and Utility Routines

In addition to meshing functions, management and utility functions are also available in this chapter.
A mesh smoother function nag_mesh_2d_smooth_bary (d06ca), is provided to improve mesh triangle quality.
Since the Finite Element framework includes a requirement to solve matrices based on meshes, the function nag_mesh_2d_sparsity (d06cb) generates the sparsity pattern of such a matrix. Due to the fact that the numbering of unknowns in a linear system could be crucial in term of storage and performance issues, a vertex renumbering function nag_mesh_2d_renumber (d06cc) is provided. This function also returns the new sparsity pattern based on the renumbered mesh.
To mesh a complicated geometry, it is sometimes better to partition the whole geometry into a set of geometrically simpler ones. Some geometry could also be deducted from another geometry by an affine transformation and nag_mesh_2d_transform_affine (d06da) could be used for that purpose. nag_mesh_2d_join (d06db) is provided to join all the simple geometry meshes. This function can also handle the joining of two adjacent as well as overlapping meshes, which may be useful in a domain decomposition framework.

## Example of Use in the Solution of a Partial Differential Equation

The use of Chapter D06 mesh generation functions, together with sparse solver functions from Chapter F11 to solve partial differential equations with the finite element method is described in a NAG Technical Report (see Bouhamou (2001)). This report, and accompanying source code, is available from the NAG web site, or by contacting one of the NAG Response Centres.

## Functionality Index

 Boundary mesh generation,
 2D boundary mesh generation nag_mesh_2d_gen_boundary (d06ba)
 Interior mesh generation,
 2D mesh generation using advancing front method nag_mesh_2d_gen_front (d06ac)
 2D mesh generation using a simple incremental method nag_mesh_2d_gen_inc (d06aa)
 2D mesh generation using Delaunay–Voronoi method nag_mesh_2d_gen_delaunay (d06ab)
 Mesh Management and Utility function,
 2D mesh smoother using a barycentering technique nag_mesh_2d_smooth_bary (d06ca)
 2D mesh transformer by an affine transformation nag_mesh_2d_transform_affine (d06da)
 2D mesh vertex renumbering nag_mesh_2d_renumber (d06cc)
 finite Element matrix sparsity pattern generation nag_mesh_2d_sparsity (d06cb)
 joins together two given adjacent (possibly overlapping) meshes nag_mesh_2d_join (d06db)

## References

Bouhamou N (2001) The use of NAG mesh generation and sparse solver routines for solving partial differential equations NAG Technical Report TR 1/01 NAG Ltd, Oxford
Cheung Y K, Lo S H and Leung A Y T (1996) Finite Element Implementation Blackwell Science
George P L and Borouchaki H (1998) Delaunay Triangulation and Meshing: Application to Finite Elements Editions HERMES, Paris
Quarteroni A and Valli A (1997) Numerical approximation of partial differential equations Comp. Maths. 23