Delaunay Refinement Grid Generation Motivation: Meshing for the Finite Element Method (FEM) Good triangulations for surface modelling with constraints A general means to compensate for “ill-conditioned” behaviour of CDTs Also called meshing or gridding We still operate in R 2 (Delaunay) 1 FEM Triangulations as a basis for solving partial differential equations numerically. Differential equations, for example representing heat distribution or airflow, are approximated with piecewise polynomial functions over a finite element mesh and solved numerically to achieve an approximate solution of the original problem. FEM meshes have typically complicated exterior and interior boundaries (holes) and linear features: That is: CDTs (Constrained Delaunay Triangulations)! 2 The Refinement Process (very brief) Input: A PSLG G (Planar straight line graph) 1. Make the initial CDT of G Loop (refinement): 2. Split long edges (constraints) 3. Split skinny triangles The triangulation is always maintained as a CDT The basic operation is insertNode (into the CDT) 3 Preview of algorithm Algorithm (Delaunay refinement) 1. Make the initial CDT of the PSLG. Remove triangles outside the triangulation domain. 2. while skinny triangles remain 3. while any segment s is encroached upon 4. SplitSegment(s) 5. Let t be a skinny triangle and v its circumcenter. 6. If v encroaches upon any segments s 1 , s 2 , , s k 7. for i 1, , k 8. SplitSegment(s k ) 9. goto 3 10. else 11. KillTriangle(t) 12. goto 5 4 Illustration from Shewchuk. 5 Illustration from Shewchuk. 6 Requirements for FEM Meshes Triangle size: Not too small: size of equation system (and CPU-time) is linear in the number of triangles Sufficiently dense: Accuracy of the solution increases with increasing density of triangles Solution: Adaptive mesh with good grading Triangle shape: Skinny triangles gives numerical unstability, ill-conditioned equation systems in FEM problems numerical unstability in interpolation with polynomials (splines) defined over triangles Recall the Delaunay property Delaunay Refinement 7 Node Insertion Node insertions should “kill” triangles with poor quality. Fundamental questions: 1. What exactly is a well-shaped triangle or a triangle with poor quality? 2. Where should the next node be inserted during the refinement process? 3. Will the refinement procedure terminate? 4. Can we control/guarantee good spatial grading? 8 Circumradius-to-shortest-edge ratio r/l 10 9 8 αmin αmin r 7 6 5 r/l 4 3 2 1 0 5 10 15 20 l 25 30 αmin 35 40 45 50 55 60 Relationship between min and r/l DEFINITION (Circumradius-to-shortest-edge ratio r/l). Ratio between radius r of the circumcircle of a triangle, and the length of its shortest edge l. The smallest angle is always opposite to the shortest edge; see Figure. Equivalent with smallest angle measure: 1 r . 2 sin min l Maximizing min corresponds to minimizing r/l. 9 Example: The equilateral triangle with angles 60 obtains the largest possible min and the smallest r/l. r 1 1 0. 58. l 2 sin 60 3 Also used in the literature is aspect ratio of a triangle: Ratio between length of the longest edge and the shortest altitude. Bounds the minimum angle min of a the triangle as, 1 2 Aspect ratio , sin min sin min 10 Upper bound B on the circumradius-to-shortest-edge ratio r/l. Delaunay refinement algorithms operate with upper bound B for the circumradius-to-shortest-edge ratio r/l. min arcsin 1 2B max 180 2 arcsin 1/2B Any triangle with r/l ratio greater than a required upper bound B will be called skinny. Example with B 2 and B 1: B max r/l min arcsin 1 2B max 180 2 min 1 30 120 2 20. 7 138. 6 Note: Not possible to obtain if the input PSLG has angles smaller than min between incident segments. 11 Where should the next node p be inserted in a CDT ? Assumption (temporary): No constraints in . Let t be a skinny triangle (with r/l B) and Ct its circumcircle. Insertion of a new node inside Ct kills t ! If p is inserted too close to any existing nodes we get dissatisfactory r/l ratio. Insert p “as far from existing nodes as possible” ! At the center of Ct (equidistant from the three nodes of t.) DEFINITION Circumcenter center of Ct. 12 Recall the definition of Voronoi diagram, and Delaunay triangulation as its dual construction: The circumcenter of t is at the Voronoi point where the Voronoi edges corresponding to t intersect. The circumcenter of t is more distant from other nodes in than it is from the three nodes of t. Assumption (temporary): Circumcenters of skinny triangles are inside . 13 Node insertion at circumcenters of skinny triangles: (b) (a) p t t (d) (c) p t p Kill skinny triangle t with r/l 2. 14 B 14 Recall node insertion of p: Connect p to all boundary nodes of the influence region R p : Three of the new edges have length equal to the circumradius r of t, and the other new edges are longer than r. t was chosen because, r/l B new edges has length at least Bl. If B 1 ( min 30 ), no new edges are shorter than the edges of t. (This will be used later when examining termination) Also obtains nice spatial grading from small to large triangles. 15 Suppose (temporary) that a skinny triangle is one with: “circumradius greater than the shortest edge in the entire mesh”. An upper bound r/l 1 would be achieved corresponding to min 30 ; and The mesh will be uniform with all triangles approximately the same size (and more triangles); see figure. 16 Splitting Encroached Segments Assumptions above: 1. No constraints 2. circumcenters inside DEFINITION. Segment constrained edge. Edges of exterior and interior boundaries are segments. The input PSLG and are segment-bounded. DEFINITION. Subsegments a segment that has been split. Let s be a segment or subsegment of a CDT. DEFINITION. Diametral circle of s is the circle with s “as diameter”. DEFINITION. s is encroached upon if a node different from the endpoints of s lies on or inside the diametral circle of s and the node is visible from the interior of s. 17 (a) (b) (c) Splitting of encroached segment. Rule for splitting: Eliminate all encroached segments in the CDT . 1. Insert a new node at the midpoint of an encroached segment (or subsegment) s. 2. s is replaced by two new segments s 1 and s 2 . 3. Update to be Delaunay (see figure with recursive splitting). 18 Termination is not guaranteed: p s2' s1' × α s1 × q s2 45 Assumption (temporary): 45 between incident segments in the input PSLG; and no other configuration gives endless loop. Observation:If a CDT has no encroached segments and the only boundary of is the convex hull of its nodes, then is a conventional Delaunay triangulation. Why: Theorem: e is a Delaunay edge a point-free circle interpolating the endpoints of e. 19 C (t ) C (s' ) t v s' s 20 C (t ) C (s' ) t v s' s LEMMA. A triangle t in a segment-bounded Delaunay triangulation is never separated from its circumcenter v by a segment s if the segment is not encroached upon. Proof. Contradiction: Suppose that v is separated from t by a segment s that is not encroached upon; see figure. Let s be the ’closest’ segment to t that is not encroached upon. Let s be the part of s inside Ct Because t is (constrained) Delaunay, both endpoints of s are outside Ct. Since v and t lie on opposite sides of s , the portion of Ct on the same side of s as t lies inside Cs . At least one node of t must be strictly inside Cs . But Cs is inside Cs, so then at least one of the nodes of t encroaches upon s Contradiction 21 Consequences. When all encroached segments have been split: 1. The visibility between v and t is never obscured by a segment. t will always disappear when a node is inserted at v. 2. Recall: edges of the exterior boundary and interior boundaries enclosing holes are also segments v never falls outside the triangulatation or inside holes where there are no triangles. 22 The Delaunay Refinement Algorithm Input: a segment-bounded PSLG. Two basic operations: SplitSegment(s): Insert a node at the midpoint of a segment s. KillTriangle(t): Insert a node at the circumcenter of a (skinny) triangle t. KillTriangle: Only applied when there are no encroached segments present in . Both: Updates to be constrained Delaunay. 23 Algorithm (Delaunay refinement) 1. Make the initial CDT of the PSLG. Remove triangles outside the triangulation domain. 2. while skinny triangles remain 3. while any segment s is encroached upon 4. SplitSegment(s) 5. Let t be a skinny triangle and v its circumcenter. 6. If v encroaches upon any segments s 1 , s 2 , , s k 7. for i 1, , k 8. SplitSegment(s k ) 9. goto 3 10. else 11. KillTriangle(t) 12. goto 5 The skinny triangle t may disappear during segment splitting in Step 8 if one of its edges is swapped. New nodes used for segment splitting may encroach upon other segments Step 9 goes to segment splitting again. The result depends on the specific order in which encroached segments and skinny triangles are chosen. 24 Termination The algorithm terminates when there are no encroached segments and no skinny triangles left. Is termination guaranteed? Why shouldn’t it terminate? Because both KillTriangle and SplitSegment may create new skinny triangles. The algorithm may run forever creating more and more (and smaller and smaller) triangles and never get rid of skinny triangles. Under what conditions will the algorithm terminate? 25 DEFINITION (Local feature size). Given a PSLG G. The local feature size at an arbitrary point p R 2 relative to G, denoted lfs G p (or only lfsp) is the radius of the smallest disk centered at p that intersects two non-incident nodes or segments of G. Local feature size lfs at Local feature size lfs: lfs is relative to G and never changed during refinement lfs continuous lfsp 0 for all points p Steepness in the range 1, 1 in any direction: 26 LEMMA. Given a PSLG and two points p and q in the plane. Then lfsq lfsp dp, q, where dp, q is the Euclidean distance between p and q. DEFINITION (Insertion radius). The insertion radius r v of an insertion node v is the length of the shortest Delaunay edge connected to v immediately after KillTriangle or SplitSegment has executed. Other cases: 1. If v is an input node of the PSLG: r v length of shortest edge connected to v after the initial CDT has been constructed and before the refinement process starts. 2. If v is a rejected node (encroaches upon a segment): r v shortest Delaunay edge connected to v as if v had been inserted. 27 Recall the Delaunay property: 1. New edges created when inserting v have v as a common endpoint. 2. The closest node visible from v defines the shortest edge connected to v. 28 (b) (a) p t t (d) (c) p t p Example: Insertion radius is the shortest edge of t. 29 Termination, continued... First goal: Find lower bound on insertion radius r v in all possible cases of KillTriangle and SplitSegment. (That is such that r v “something” ) DEFINITION (Parent node). The parent node of an insertion node v is the node “responsible” for the insertion of v. (Explained under “cases” below.) 30 (a) (b) Input PSLG t p p rv l ≥ rg g rp v rv v s s (c) (d) s’ s’ p p l a α rv l β a v α rv β s v s Encroachment cases 31 Cases for KillTriangle and SplitSegment: Different roles of the parent node p. Case 1. (KillTriangle(t)): p is the last inserted node of the two endpoints of the shortest edge of t. Case 2. (SplitSegment(s)): p is the nearest node that encroaches upon s. Facts: p lies inside Cs. The shortest edge connected to v, which define the insertion radius r v , has p as the other endpoint if p is in (and not rejected in Step 6). Three possible roles of p: 2a. p is an input node, or p is a node inserted in a segment not incident with s. (Figure (a)) 2b. p is at the circumcenter of a skinny triangle and thus rejected since it encroaches upon s. (Figure (b), and Step 6–8 of Algorithm .) 2c. p is a node on a segment s incident with s that makes an angle 45 90 with s. (Figure (c)). 2d. p is a node on a segment s incident with s that makes an angle 45 with s. (Figure (d)) 32 (a) (b) Input PSLG t p p rv l ≥ rg g rp v rv v s (c) s (d) s’ s’ p p l a α rv l β a v α rv β v s s Encroachment cases LEMMA. The insertion radius r v has the following lower bounds. Case 1. r v Br p , Case 2a. r v lfsv, Case 2b. r v r p / 2 , Case 2c. r v r p /2 cos , Case 2d. r v r p sin . 33 Proof. rp p t l Case 1. KillTriangle(t) - case. Recall: t was chosen because r/l B. new edges has length at least Bl. Facts: - shortest new edge has length r v (by definition) - l rp r v Br p . 34 (a) Input PSLG p rv v s Case 2a. Consult Figure (a). Follows directly from definition of local feature size: r v lfsv. 35 (b) (e) t p l ≥ rg g g p rp rp rv l ≥ rg t rv v s v s Case 2b. Consult Figure (b). p is rejected, so r v |s |/2. r p circumradius of t. Lower bound on r v is achieved when r v /r p is minimized under the constraint that p lies on or inside Cs. Delaunay property ensures that Ct cannot contain endpoints s. Figure (e) illustrates the position of p and Ct for min r v /r p 1/ 2 . r v r p / 2 . 36 s’ (c) p l a α rv β v s Case 2c. Consult Figure (c). l rp. r v equals length of vp. Law of sines gives, r v sin . l sin Let be fixed. Since l r p , a lower bound on r v is achieved by minimizing r v /l under the constraint that p lies on or inside Cs. 45 90 sin 1. min r v /l when is maximum under the given constraint. When p lies on Cs, which gives r v l/2 cos . r v r p /2 cos . 37 (d) s’ p l a α rv β v s Case 2d. Consult Figure (d). Use the same analysis as in Case 2c; law of sines, r v sin . l sin But now is not bounded by 90 . r v /l is minimized when sin 1, i.e., 90 . r v l sin , and since l r p r v r p sin . 38 Goal: Each node insertion generates edges that are either longer than an existing edge, or longer than a fixed feature in the PSLG. (avoid chains of shorter and shorter edges and thus endless loops) Recall LEMMA: Case 1. r v Br p , Case 2a. r v lfsv, Case 2b. r v r p / 2 , Case 2c. r v r p /2 cos , Case 2d. r v r p sin . (where r v is the shortest edge created when inserting v) Case 2d: r v r p sin for 45 Recall 45 generates endless loop with SplitSegment in Step 3 and 4 of the Algorithm. Impossible to get r v r p . Case 2c: r v r p /2 cos for 45 90 r v r p if 60 . 39 (e) l ≥ rg t g p rp rv v s Case 2b: r v r p / 2 . Note that node p was not inserted (rejected). Case 1 defines a lower bound for p as r p Br g ; see figure. Combines to r v r p / 2 Br g / 2 . r v r g when B 2. ... and this also holds for Case 1: r v Br p . B 2 from Case 2b sufficient for r v r p . 40 p (a) Input PSLG rv v s Case 2a: r v lfsv. . . that is, the input PSLG bounds (determines) the the shortest edge connected to v! But, since v and p are non-incident, there is a stronger bound on r v : Let d min be the shortest distance between two non-incident entities of the input PSLG. Then for any node v inserted by Algorithm, and d min r v d min , min lfs (and therefore it is a better bound)! The same bound is (of course) valid for edges of the input PSLG. No edge in the final mesh can be shorter than d min ! (why? see next slide) 41 Because: Case 2a, with r v d min , is the only case that bounds r v (the shortest edge) in terms of the input PSLG, and: all the other cases has bounds at least r v r p , where p is either a previous inserted node, or. a node of the input PSLG. “Track the history back in time” from an insertion node v to its parent, grandparent, etc. and you will find that r v d min represents a “last barricade” that bounds the shortest edge in the final mesh. No edge in the final mesh can be shorter than d min ! 42 Summary so far: 1. Ever-decreasing edges cannot occur if: 60 between incident segments of the input PSLG, and B 2. 2. Lower bound d min on the shortest edge in the final mesh. Is this sufficient for termination of Algorithm? YES, because: Every edge is Delaunay (in a CDT): The shortest edge connected to v has the closest node visible from v as its other endpoint. A new node can never be inserted closer to an existing node than d min , unless the visibility is obscured by a segment. Draw circles with radius d min around each new node. Each such circle is node-free. Sooner or later there is no space left to draw circles. TERMINATION. 43 THEOREM. Let d min be the shortest distance between two nonincident entities (nodes or segments) in the input PSLG. Let a triangle be considered skinny if its circum-radius-to-shortest-edge ratio r/l B, where B 2 ; and suppose that the angle between two incidents segments in the input PSLG is at least 60 . Then the Algorithm terminates with no edge shorter than d min . arcsin 1 180 2 arcsin 1 2B 2B 20. 7 138. 6 But with the constraint that the angle between incident segments is at least 60 ! We can handle this restriction with “corner-lopping”: 44 Corner-Lopping for Handling Small Input Angles Illustration from Shewchuk. 1. Lop off corners with sharp angles in the input PSLG G and obtain G with angles 60 . Lopping-circles with radius, e.g., r lfs G a/3. 2. Run Algorithm on G 3. Fill in lopped off corners again. (see lecture notes for details) 45 Examples Illustration from Ruppert 46 Illustration from Ruppert 47