Frontal-Delaunay Sampling via gmsh

Implemented class: DelaunaySampler2D  |  Method key: "delaunay"

1. Theoretical Background

1.1 Delaunay Triangulation

A Delaunay triangulation of a point set P in the plane is a triangulation such that no point in P lies inside the circumcircle of any triangle. This maximizes the minimum angle of all triangles, avoiding badly-shaped "sliver" triangles and producing the most regular partition of the domain achievable for a given set of nodes.

The Delaunay condition can be stated as: for every triangle T in the triangulation, and for every fourth point p in P, p lies outside or on the circumcircle of T.

det([ xi-xd   yi-yd   (xi-xd)2+(yi-yd)2 ]) > 0  ∀ d,   i=a,b,c

The Delaunay triangulation of N points can be computed in O(N log N) time (e.g., using the Bowyer-Watson algorithm).

1.2 Ruppert's Algorithm (Delaunay Refinement)

A Delaunay triangulation of a fixed point set does not control the size of the triangles. Ruppert's algorithm (1995) is a refinement algorithm that progressively inserts new points (Steiner points) to eliminate triangles whose circumradius-to-shortest-edge ratio exceeds a quality threshold B. The algorithm:

  1. Start with an initial Constrained Delaunay Triangulation (CDT) of the boundary polygon.
  2. Find any triangle T with circumradius R such that R > B ċ h.
  3. Insert the circumcentre of T as a new Steiner point (after checking it does not violate any constrained boundary edge).
  4. Repeat until all triangles satisfy the quality criterion.

Ruppert proved that for B ≥ √2 (i.e., minimum angle ≥ 20.7°), the algorithm terminates with a near-uniform, high-quality triangulation. In practice, B = 1.0 (minimum angle ≈ 30°) is the standard choice.

1.3 Frontal-Delaunay (gmsh Algorithm 6)

The Frontal-Delaunay algorithm (Rebay 1993, improved by Remacle et al. 2010) combines a frontal strategy (advancing front from the boundary inward) with Delaunay refinement. It generates triangulations with excellent element quality, often superior to pure Ruppert refinement, especially near boundaries. gmsh implements this as Mesh.Algorithm = 6.

The key idea is:

The result is a triangulation where all elements have circumradius close to h and angles well above the minimum quality bound.

2. Application in GearMaster

In GearMaster, the DelaunaySampler2D uses gmsh as a black-box Frontal-Delaunay mesher to produce a high-quality node set for each planar face. The workflow is:

Step 1: Boundary resampling

The face boundary polygon is resampled at uniform arc-length spacing h (using the same arc-length algorithm as SurfaceSampler2D) to ensure that boundary nodes in the gmsh mesh match the characteristic spacing of the interior.

Step 2: gmsh session

A temporary gmsh model is created in-memory:

  1. Boundary points are added as gmsh geometry points at spacing h_{\text{mesh}} = \text{quality} \cdot h.
  2. Boundary line segments connect consecutive boundary points.
  3. A planar surface is defined from the closed boundary loop.
  4. The Frontal-Delaunay algorithm (Algorithm 6) is invoked with:
    • CharacteristicLengthMin = 0.2 · h_mesh
    • CharacteristicLengthMax = h_mesh

Step 3: Node extraction and classification

After meshing, all node coordinates are extracted from the gmsh model. Nodes that belong to curve entities (dimension 1) are classified as boundary nodes; all others as interior nodes. Boundary node positions are snapped to the original polygon edges (nearest-point projection) to correct any sub-pixel deviation introduced by gmsh's internal representation.

Step 4: Lift to 3D

All 2D node coordinates are lifted to 3D using the face plane coordinate system (same as other samplers): x3D = O + u · x̂ + v · ŷ.

Thread safety: gmsh is not thread-safe. All gmsh calls are serialized via a module-level lock (_GMSH_LOCK). When parallel generation is requested (n_jobs > 1), gmsh sessions are queued and executed sequentially. Additionally, gmsh.initialize() internally calls signal.signal(), which requires the main thread — a workaround is applied when gmsh is invoked from worker threads.

3. Quality Parameter

The quality parameter (default 1.0) controls the target element size as a multiple of h:

4. When to Use

Use "delaunay" when the highest-quality node distribution is required, regardless of computational cost. It is particularly recommended for:

5. References