{'fraction_non_alphanumeric': 0.03509605862547039, 'fraction_numerical': 0.008437314319667261, 'mean_word_length': 4.357135278514589, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Analysis of and workarounds for element reversal for a finite element-based algorithm for warping triangular and tetrahedral meshes

We consider an algorithm called FEMWARP for warping triangular and tetrahedral finite element meshes that computes the warping using the finite element method itself. The algorithm takes as input a two- or three-dimensional domain defined by a boundary mesh (segments in one dimension or triangles in two dimensions) that has a volume mesh (triangles in two dimensions or tetrahedra in three dimensions) in its interior. It also takes as input a prescribed movement of the boundary mesh. It computes as output updated positions of the vertices of the volume mesh. The first step of the algorithm is to determine from the initial mesh a set of local weights for each interior vertex that describes each interior vertex in terms of the positions of its neighbors. These weights are computed using a finite element stiffness matrix. After a boundary transformation is applied, a linear system of equations based upon the weights is solved to determine the final positions of the interior vertices. The FEMWARP algorithm has been considered in the previous literature (e.g., in a 2001 paper by Baker). FEMWARP has been succesful in computing deformed meshes for certain applications. However, sometimes FEMWARP reverses elements; this is our main concern in this paper. We analyze the causes for this undesirable behavior and propose several techniques to make the method more robust against reversals. The most successful of the proposed methods includes combining FEMWARP with an optimization-based untangler.


Introduction.
Moving meshes arise in cardiology, computer graphics, animation, and crash simulation, among other applications in science and engineering. With moving meshes, the mesh is updated at each step in time due to a moving domain boundary, thus resulting in potentially drastically varying mesh quality from step to step. One problem that can occur at each timestep is element reversal. "Reversal" means that the element changes orientation. In two dimensions, this means that the nodes of an element are clockwise when they ought to be counterclockwise, and in three dimensions it means that they violate the right-hand rule. We focus on mesh-warping procedures that avoid reversals as much as possible.
It is well-known that poor quality elements affect the stability, convergence, and accuracy of finite element and other solvers because they result in poorly-conditioned stiffness matrices and poor solution approximation [27]. If well-shaped elements are not the result of updating the mesh boundary, the mesh quality must be improved by topological or geometrical means after each time step.
Research has shown that mesh smoothing (or r-refinement) methods can be applied to improve the quality of a mesh. These methods adjust the positions of the vertices in the mesh while preserving its topology.
Laplacian smoothing is the most popular method for node-based mesh smoothing. In an iterative manner, it repositions the vertices of the mesh by moving each interior node to the geometric center of its neighbors. It is often used because it is computationally inexpensive and is very easy to implement. However, the method has several undesirable properties. One of them is that the method is not guaranteed to work, i.e., sometimes it reverses mesh elements. A second drawback is that if the algorithm is not run to convergence, the resulting mesh depends upon the order in which the nodes are smoothed.
A related type of smoothing, namely Winslow smoothing, is more resistant to mesh folding due to the requirement that the logical variables be harmonic functions. This method was introduced for structured meshes by Winslow in [32]. In [19], Knupp extends this idea to unstructured quadrilateral meshes; he used a finite-difference method for his derivative computations. Others have used the finite element method for the derivative computations on unstructured meshes; for example, Knupp cites a proprietary DOE paper by Tipton to which the authors do not have access. (See the references at the end of [19].) Many others have created extensions to Winslow's method. One type of extension has been to generate the meshes using a variational approach; for example, see Brackbill and Saltzman [4], Russell and co-workers [6] and [17], and Thompson et al. [29]. Dvinsky [8] uses the theory of harmonic functions to generate a harmonic map between the physical domain and the logical domain in order to generate the mesh. Meshes that have been generated according to this method possess regularity and smoothness properties. Li et al. [22] also introduced a moving mesh method based on harmonic maps; their method has two parts: a solution algorithm and a mesh-redistribution algorithm. In doing so, they are able to obtain the desirable properties of both the h-method and r-method for finite elements.
Other, more accurate methods for r-refinement are possible. Most of these methods are based upon optimization. Optimization-based methods are used with the goal of guaranteeing an improvement in the mesh quality by minimizing a particular mesh quality metric. Their main drawback, however, is their computational expense. Examples of optimization-based methods for r-refinement can be found in the following papers: [12], [11], [10], [13], [9], [14], [1], [2], [25], [5], [31], and [33]. For a theory of algebraic mesh quality metrics see [20].
To address the above issues, Baker [3] developed a three-step method for the metamorphosis of tetrahedral meshes. Each cycle of the method involves a combination of r-refinement, mesh coarsening, and mesh enrichment to adapt the mesh. The first step in the cycle is to move the interior nodes as far as possible using r-refinement while avoiding element reversal. The second step is to remove the poorly-shaped elements in the mesh using mesh coarsening. The final step is the addition of elements to improve the mesh quality by mesh refinement. This dynamic procedure was shown to be more cost-effective than just r-refinement. One disadvantage of this technique is that it comes with no theoretical guarantees as it is difficult to analyze because each cycle is a combination of three very different techniques.
We study a different mesh warping problem where the connectivity of the mesh is not allowed to change, which is important for some applications. The problem that we address is as follows: Given a three-dimensional domain, bounded by a triangulated surface mesh, and given an interior volume mesh composed of unstructured tetrahedra, suppose the triangulated surface mesh is displaced. Is there an algorithm to move the nodes of the volume mesh so that it continues to conform to the surface mesh and to be a good quality mesh? In addition, we study the analogous problem in two dimensions. Seeking simplicity, preservation of the mesh's combinatorial structure, theoretical insight, and low computational expense, we propose a technique called FEMWARP and several variants to be described below.
The FEMWARP algorithm has already been considered in the previous literature, e.g., by Baker [3], although he rejected it in favor of a method based on linear elasticity. It is shown, however, in [28] that there appear to be few advantages of linear elasticity over FEMWARP; whereas, a significant disadvantage is that the linear elasticity matrix problem is three times larger (in 3D) than FEMWARP's (although FEMWARP must solve the smaller linear system three times).
FEMWARP is described in Section 2, and a generalization of it called the "linear weighted Laplacian smoothing" (LWLS) framework is considered in Section 3. There are two main advantages to methods within the LWLS framework. First, if a continuous deformation of the boundary is given, then methods within the framework are valid for computing the resulting trajectory that specifies the movement of the interior nodes. In addition, these trajectories will be continuous. This is vital for some applications where continuity of motion is required. A second big advantage is that sparse matrix algorithms may be used to solve (2.2). The sparsity structure is apparent, since, on average, an interior node has six neighbors in 2D, whereas a typical 2D mesh may have thousands of nodes. In Section 4, we explain the relationship between traditional Laplacian smoothing and LWLS methods.
The principal failure mode for FEMWARP is that it can reverse elements. The causes of element reversal are covered in Section 5. Techniques to prevent some reversals, including smallstep FEMWARP and mesh refinement, are also covered in that section. Another technique to avoid reversals based on the Opt-MS mesh untangler is covered in Section 6. In Section 7, we test our algorithms on several types of deformations of three-dimensional meshes. In Section 8, we apply FEMWARP to study the motion of the beating canine heart under normal conditions.
2. The FEMWARP algorithm. The first step of the FEMWARP algorithm is to express the coordinates of each interior node of the initial mesh as a linear combination of its neighbors. Let a triangular or tetrahedral mesh be given for the domain Ω in two or three dimensions. Let b and m represent the numbers of boundary and interior nodes, respectively. Form the (m + b) × (m + b) stiffness matrix A based on piecewise linear finite elements defined on the initial mesh for the boundary value problem △u = 0 on Ω.
It is well-known [18] that this matrix is determined as follows. Let φ i be the continuous piecewise linear function (where the pieces of linearity are given by the triangulation) such that φ i (x i ) = 1, where x i is the i th node of the mesh, and φ i (x j ) = 0, where x j is any other node in the mesh (j = i).

Define for each
This matrix will be sparse and symmetric positive semidefinite. Its nonzero entries correspond to pairs of neighboring nodes in the mesh.
Next, let A I denote the m × m submatrix of A whose rows and columns are indexed by interior nodes, and let A B denote the m × b submatrix of A whose rows are indexed by interior nodes and whose columns are indexed by boundary nodes. Let x be the (m + b) vector consisting of xcoordinates of the nodes of the initial mesh, where we assume that the interior nodes are numbered first. Then it follows from well-known theory that [A I , A B ]x = 0 because any linear function of the coordinates is in the null-space of the discretized Laplacian operator. For the same reason, a similar identity holds for the y-and z-coordinates. An equivalent way to write this equation is (2.1) If we divide each row of [A I , A B ] by the diagonal element in that row, we obtain a linear system whose diagonal entries are 1's and whose row sums are 0's. This means that the [A I , A B ], thus scaled, expresses each interior nodal coordinate as an affine combination of the neighboring nodal coordinates.
The formation of A I and A B is the first step of the FEMWARP method. Consider now the application of a user-supplied transformation to the boundary of the mesh. We denote the new positions of the boundary nodes by [ The final step is to solve a linear system of equations similar to (2.1) for the new coordinates of the interior nodes. We solve (2.2) for [x I ,ŷ I ] : (2. 2) or the analog in three dimensions. This concludes the description of FEMWARP.
3. The LWLS framework. The FEMWARP method can be generalized as follows. One produces, using some method, a family of weights w ij for each ordered pair of nodes (i, j) such that j is a neighbor of i and such that i is interior. Denote by N (i) the set of neighbors of i, and let the coordinates of node i be (x i , y i ) in 2D or (x i , y i , z i ) in 3D. We want these weights to express interior nodes as affine combinations of their neighbors, which imposes the following constraints on the w ij 's: For each i indexing an interior node, and in three dimensions, there is a fourth equation for z-coordinates. Let [A I , A B ] be m × (m + b) matrix with 1's on the diagonal and −w ij in position (i, j) whenever j ∈ N (i). The above three equations may be rewritten in terms of A I and A B as follows: where e I and e B are vectors of all 1's whose length is equal to the number of interior and boundary nodes respectively, x I and x B are the vectors of x-coordinates of mesh nodes in the interior and boundary respectively, and similar for y B and y I .
Once these weights are derived, then, as in FEMWARP, the user-supplied deformation may be applied to the boundary nodes yielding deformed boundary coordinates (x B ,ŷ B ) in two dimensions. Finally, the new position of the interior nodes is computed via We will say that any method following this framework is a linearly weighted Laplacian smoothing (LWLS) method. The precise relationship between these methods and traditional Laplacian smoothing is the subject of Section 4. The FEMWARP method was not written exactly this way since the diagonal elements in [A I , A B ] for FEMWARP are not rescaled to be equal to 1. Usually for FEMWARP it is preferable to preserve the symmetry of A I and therefore omit the scaling step. This omission has no effect on the final answer.
One concern with the weights in FEMWARP is that, in general, they are not always nonnegative. Sometimes it is desirable to have all nonnegative weights. Geometrically, this means that the interior nodes are expressed as convex (rather than merely affine) combinations of neighbors. Nonnegative weights are useful if the weight matrix is used to interpolate properties besides nodal coordinates, and it is mandatory that no extrapolation occur (e.g., because a nodal value that strays outside the range of boundary data would violate some kind of physical constraint).
In [28], the first author experimented with other weighting schemes including a method called LBWARP in which the weights w ij are obtained by solving a log barrier optimization problem for each i: The rationale for this optimization formulation is to ensure that each w ij is positive, and, more strongly, that it is bounded well away from 0 (since the logarithmic term tends to −∞ if any of the w ij 's approaches zero). This problem is convex, and there is an efficient algorithm to find the unique global minimum. It can be proved [28] that the w ij 's that solve this optimization problem have a positive lower bound that depends only on the worst-case aspect ratio of triangles or tetrahedra in the mesh. A further important property that a method in the LWLS family ought to satisfy is that A I should be nonsingular to ensure a unique solution for the new coordinates. For FEMWARP, the nonsingularity of A I follows from well-known theory of finite element analysis. For LBWARP, the nonsingularity follows because A I is an irreducible and diagonally dominant matrix with strict inequality for at least one row.
Because the mesh is connected and a positive weight is associated with each edge, we see that A I is irreducible. Also, A I is digonally dominant, as its diagonal entries are 1, and its off-diagonal entries are nonpositive and sum to a number in [−1, 0] in each row. Since there is at least one interior node adjacent to a boundary node, A I e I = 0, where e I is a vector of all 1's of length m. Therefore, A I satisfies the definition of an irreducibly diagonally dominant matrix by the above argument. Thus, A I is invertible [30,Theorem 1.8].
Experiments in [28] indicate that weights obtained from LBWARP generally do not perform as well as FEMWARP for the mesh warping application in terms of resisting element reversal.
One useful property that holds for any method in the LWLS framework including FEMWARP and LBWARP is that the method is exact for affine transformations. Let us state this as a theorem. The theorem is stated for the two-dimensional case, and it extends in the obvious way to three dimensions.
Theorem 3.1. Let A B and A I be generated using a method from the LWLS framework, and assume A I is nonsingular. Let [x B ,ŷ B ] be the user-specified deformed coordinates of the boundary. Suppose there exists a 2 × 2 nonsingular matrix L and 2-vector v such that for each j ∈ B, Let [x I ,ŷ I ] be the deformed interior coordinates computed by the method. Then for each i ∈ I, Proof. The positions of the interior nodes in the deformed mesh are given by where, as above,x I ,ŷ I are column vectors composed of the x-and y-coordinates of the interior nodes respectively and x B , y B are the corresponding vectors for boundary nodes, and finally e B is vector of all 1's of length b.
In order to show that affine mappings yield exact results with any algorithm within the framework, we want to show that (3.1) is the same as: Observe that the equivalence of (3.1) and (3.2) would follow immediately from: Thus, it remains to check that (3.3) holds.
Because the weights for each interior node sum to 1, A I e I + A B e B = 0 as noted above. Hence Putting these together, we see that Therefore, (3.3) holds, and the lemma is proven.
4. Relationship to Laplacian smoothing. In this section we explain the fairly direct connection between Laplacian smoothing and algorithms from the LWLS framework. We start with the following theorem, which is a consequence of well-known results in the previous literature.
Theorem 4.1. Gauss-Seidel iteration will converge for solving the linear system that is produced by either the LBWARP or FEMWARP algorithm. Proof. In the case of FEMWARP, A I is symmetric and positive definite hence Gauss-Seidel is convergent [16,Theorem 10.1.2]. In the case of LBWARP, A I is irreducibly diagonally dominant hence Gauss-Seidel is convergent [30,Theorem 3.4].
The Gauss-Seidel algorithm applied to these matrices corresponds to iteratively replacing the coordinates of each interior vertex with a weighted average of the coordinates of its neighbors. The weights come from the entries of A I and A B . In the case of FEMWARP, some of the weights may be negative.
Ordinary laplacian smoothing, as mentioned in Section 1, corresponds to the iterative process of replacing each mesh node with the centroid of its neighbors. Thus, it can be regarded as a member of the LWLS framework in which the weight of each neighbor of node i is 1/|N (i)|, where N (i) is the set of neighbors of node i.

5.
Element reversal and small-step FEMWARP. Sometimes FEMWARP fails to yield a valid triangulation because it reverses elements. The purpose of this section is to explore the causes for reversal and propose some workarounds. The discussion of workarounds continues into the next section.
Let Ω be the original polygonal or polyhedral domain, and letΩ be the domain whose boundary is given by the user-specified deformation of the boundary nodes of Ω, i.e., by the nodes at coordinates (x B ,ŷ B ). Assume that this user-specified deformation is not self-intersecting and preserves orientation.
Let φ be the mapping from Ω toΩ computed by FEMWARP. In other words, interpolate the interior nodal deformations linearly over the elements to arrive at a continuous function on the whole domain. (In the case that FEMWARP fails, parts of φ(Ω) may protrude outside ofΩ.) Let φ * be the mapping that is obtained from the exact (continuum) Laplacian. In other words, solve the boundary value problems △x = 0 on Ω, and define φ * (x, y) = (x(x, y),ŷ(x, y)). Let us call this warping algorithm "continuum FEMWARP".
Finally, let φ + be the mapping that is obtained by linear interpolation over the elements of φ * evaluated at nodes. Thus, φ + is intermediate between φ and φ * in the sense that for φ + we use the exact solution to the continuum problem only at nodal points and use interpolation elsewhere.
There are three possible reasons that FEMWARP could fail: 1. Mapping φ * might have reversals. 2. Mapping φ + might have reversals even though φ * has none. 3. Mapping φ might have reversals even though φ + has none. Let us call these Type 1, Type 2, and Type 3 failures. For Type 1 failure, "reversal" means the existence of a point x ∈ Ω such that ∇φ(x) has a nonpositive determinant. For the second and third types, "reversal" means that a triangle is reversed. Type 1 reversals are caused by the boundary deformation alone and are not related to the mesh. Type 2 reversals are due to continuous versus discrete representation of φ * , and Type 3 reversals can be analyzed using traditional error estimates for the finite element method.
Let us start with Type 1 reversals. It is difficult to characterize inputs for which φ * will have reversals. In [28], a sufficient condition is given for two-dimensional domains to ensure that φ * will be an invertible function, but the condition is unrealistically stringent and is nontrivial to check in practice.
Rather than presenting the theorem from [28], we choose to present a series of examples and discussion on how to avoid reversals. The geometry for most of the examples in this section is a two-dimensional annulus with outer radius 1 and inner radius r < 1. Meshes used for tests in this section were generated by Triangle, a two-dimensional quality mesh generation package [26]. A typical mesh that occurs in some of the experiments is depicted in Fig. 5.1; this mesh has 1238 elements, 694 nodes, and a maximum side length of 0.1137. Its inner radius is 0.5.
The boundary transformations applied in this section usually consist of two motions: First, the inner circular boundary is moved radially outward ("compression") to new radius s such that r ≤ s < 1. Second, a rotation of magnitude θ is applied to the outer boundary. The relevant Laplace equations determining φ * can be solved in closed form to yield , and a, b, c, d are constants determined by the boundary conditions. In particular, to match the boundary conditions just described, one must satisfy the equations a + b = cos θ, c + d = sin θ, a + b/r 2 = s/r, c + d/r 2 = 0. These equations are uniquely solved by choosing This function φ * is invertible, i.e., avoid reversals, provided the determinant of its Jacobian is always positive. This determinant may be computed in closed form: det(∇φ * ) = a 2 + c 2 − (b 2 + d 2 )/(x 2 + y 2 ) 2 . This quantity is minimized when x 2 + y 2 = r 2 . Therefore, reversals of Type 1 occur if and only if r 2 (a 2 + c 2 ) ≤ b 2 + d 2 . Substituting the above formulas for a, b, c, d yields the result that reversals occur if and only if 2r cos(θ) − r 2 s − s < 0.
We tested the FEMWARP algorithm on the cases described above with a mesh for the annuluar region as discussed earlier. We used a mesh with inner radius r = 0.5. This particular mesh contained 10,950 triangles with maximum side length of 0.039. For s = 0.5, when we selected θ = 51 • , FEMWARP ran on this mesh without reversals, whereas θ = 52 • caused reversals. As mentioned in the previous paragraph, θ ≈ 51.4 • is the cutoff for Type 1 reversals. When r = 0.5, s = 0.75, FEMWARP succeeded for θ = 22 • but failed for θ = 23 • , again, very close to the cutoff for Type 1 reversals.
The point of the experiments in the last paragraph is that for a reasonably refined and reasonably high-quality mesh, most FEMWARP reversals seem to be Type 1 reversals. In other words, FEMWARP fails when continuum FEMWARP fails or is close to failure. Other experiments not reported here seem to confirm this point. Therefore, in order to extend the range of deformations that can be handled by FEMWARP, the best strategy is to come up with a way to avoid Type 1 reversals.
One simple method to avoid Type 1 reversals is to take several smaller steps instead of one big step.
forx ′ andŷ ′ to determine a mapping φ 1 : Ω → Ω ′ given by (x, y) → (x ′ ,ŷ ′ ) (where Ω ′ is the domain bounded by (x ′ B ,ŷ ′ B )) followed by The idea in the previous paragraph can be extended to more steps with smaller increments. The limiting case of an infinite number of infinitesimal steps yields an algorithm that we call "infinitesimal-step continuum FEMWARP". This algorithm corresponds to solving a time-dependent system of partial differential equations, but it is difficult even to write down the system that describes this limit because it requires notation for inverting systems of Laplacians. We suspect that infinitesimal-step continuum FEMWARP will never suffer from reversals as long as the boundary does not get tangled.
In the case of the annulus, it is possible again to write down infinitesimal-step continuum FEMWARP in closed form. For simplicity, let us assume r = s so that the only deformation is the rotation of the outer boundary. Assume this rotation is broken up into infinitesimally small rotations. (Another choice would be to connect the initial positions to the final positions with line segments, and break up the boundary motion as infinitesimal increments along the line segments. This way to obtain a continuous boundary motion is undesirable, however, because for a sufficiently large rotation, the line segments would cut through the inner boundary of the annulus and hence cause tangling of the boundaries.) With the setup described in the last paragraph, the deformation for an outer rotation of θ computed by infinitesimal-step continuum FEMWARP maps a point at initial position ρ(cos φ, sin φ) (r ≤ ρ ≤ 1) to ρ(cos(φ+α), sin(φ+α)), where α = (1−r 2 /ρ 2 )θ/(1−r 2 ). This map is clearly bijective for any value of θ; it corresponds to rotating each concentric circle of the annulus by an amount that interpolates between 0 (when ρ = r) and θ (when ρ = 1).
Thus, by using small-step FEMWARP with sufficiently small steps, we can essentially eliminate Type 1 failures. Small-step FEMWARP preserves the attractive property of FEMWARP that it is exact for affine maps, as long as all the intermediate steps are also affine. Unfortunately, it loses the attractive property that only one coefficient matrix for solving the linear system needs to be factored. Small-step FEMWARP requires the solution of a different coefficient matrix for each step. This drawback is partly ameliorated by the fact that even though the matrices are different, they have the same nonzero pattern, and hence the symbolic phase of sparse direct solution may be reused. If instead an iterative method is being used to solve the mesh warping equations, then the sparsity pattern may be reused in the preconditioner. In addition, the factored coefficient matrix at step t k can be used as a preconditioner for an iterative method at step t k+1 .
Elimination of Type 1 failures means that the mapping function φ * has no reversals in the sense that the determinant of its Jacobian is positive everywhere; equivalently, it does not reverse any infinitesimally small triangles. A Type 2 failure occurs because the triangles in the mesh have finite (non-infinitesimal) size and hence can still be reversed by φ + . The following theorem characterizes when this can happen.
Theorem 5.1. Suppose that f : Ω → R 2 is bijective, orientation-preserving and C 2 on Ω with ∇f nonsingular. Let T be a triangle in the mesh with vertices {v 1 , v 2 , v 3 }, and let T ′ be the triangle whose vertices are In order to analyze the analogous quantity for {f (v 1 ), f (v 2 ), f (v 3 )}, we start with the following algebra, which invokes the fundamental theorem of calculus twice: where e 1 ≤ M h 2 , where h is the maximum side length of T (an upper bound on v 2 − v 1 ) and M is an upper bound on ∇ 2 f in the triangle. Similarly, where again e 2 ≤ M h 2 . Therefore, where A is as above and E 2 ≤ √ 2M h 2 . Observe that ∇f (v 1 )A has positive determinant by assumption. Therefore, the left-hand side can have negative determinant only if E is a sufficiently large perturbation to change the determinant sign. If E is such a large perturbation, then by the continuity of the determinant, there is a perturbation E ′ no larger than E such that the det(∇f (v 1 )A+E ′ ) = 0, i.e., ∇f (v 1 )A + E ′ is singular. Furthermore, E ′ ≤ √ 2M h 2 . By Theorem 2.5.3 of [16], this means that where σ min (A) and σ max (A) denote the smallest and largest singular values of A, respectively. It follows from the equation AA −1 = I that that the columns of A −1 are parallel to the altitude segments of triangle T perpendicular to v 1 v 3 and v 1 v 2 respectively, but scaled so that their lengths are the reciprocals of those altitude lengths. Therefore, σ max (A −1 ) ≤ √ 2/ minalt(T ), where minalt(T ) means the minimum altitude. Thus, σ min (A) ≥ minalt(T )/ √ 2. Substituting this inequality into (5.3) and rearranging yields where asp(T ), the aspect ratio of T , equals h/ minalt(T ). The aspect ratio is often used as a shapequality metric; lower values mean a better shaped triangle. Thus, reversal cannot happen if the opposite inequality holds: The point of this theorem is that Type 2 reversals cannot occur for a sufficiently refined mesh (i.e., h sufficiently small in (5.4)), assuming that the mesh quality does not decay, and assuming that φ * is a nonsingular function. (Assuming Type 1 reversals are excluded, function φ * is never singular on the interior because Laplace solutions are analytic. It could be singular at the boundary if, for example, Ω ′ has a corner where Ω had none.) We tested this theorem for two examples, each of which diverges a bit from the theoretical prediction. For the first example, we generated a uniform mesh for the rectangle [0, 2] × [0, 1] using Triangle and mapped all the nodes using the function f (x, y) = (x, y + αx(2 − x)). For each mesh, α was incremented by 1 until reversal occurred. (No Laplace solution was involved in this test case.) We tabulated the values of h versus α in Table 5. As predicted by the theorem, the table shows that as h decreases, a larger value of α is tolerated. Contrary to the theorem, however, the table shows that σ min (∇f )/ ∇ 2 f is decreasing faster than h. In other words, reversals are avoided to a greater extent than predicted by the theorem. The reason for this discrepancy is that the perturbation term E in (5.2) is not well aligned with the direction that drives (∇f )A toward singularity in this example. In particular, E affects only the y-components (since the transformation is linear for x-coordinates). On the other hand, transformation φ stretches the triangles substantially in the y-direction, so that the most effective way to perturb (∇f )A toward singularity is a small change to the x-components.
As a second test case, consider the transformation of the annulus with radii (0.5, 1) that results from continuous-warping continuum FEMWARP, that is, the transformation that rotates a point at radius ρ by angle α(1 − r 2 /ρ 2 )/(1 − r 2 ), where r is the inner radius (r = 0.5 for this test). For each mesh, the parameter α was stepped in increments of π/16 until reversals were encountered. We tabulated values of h versus the first of α causing failure in Table 5. As predicted by the theorem, decreasing h corresponded to increasing values of α, i.e., greater distortion of the domain. Again, these results do not initially correspond to the preceding theorem quantitively: in this case, h is decreasing faster than σ min (∇f )/ ∇ 2 f . Only the last three rows of the table show that h and σ min (∇f )/ ∇ 2 f are decreasing proportionally. The reason for this discrepancy is that ∇ 2 f is much  larger on the inner boundary than elsewhere, and the meshes in the initial rows of the table are not sufficiently refined to resolve the variation in the value of the derivative. Thus, we have seen that Type 1 reversals can be avoided by using small-step FEMWARP instead of FEMWARP, and Type 2 reversals can be avoided by using a sufficiently refined mesh. The remaining type of reverals, Type 3, are rare according to our experiments. Type 3 reversals are caused by the difference between the true value of the Laplace solution and the finite element approximation to that solution. Intuitively, this phenomenon should not be commonplace because the perturbation size to a mesh necessary to cause a reversal of a triangle of side-length h is O(h), whereas the difference between the two mappings is O(h 2 ).
Consider the following test. We generated a sequence of small-step rotations for the annulus in two ways. In the first case, we took steps that rotate the outer boundary by π/16 and leave the inner boundary invariant, each time computing the Laplace solution exactly analytically. This corresponds to iteratively applying the transformation φ * (x, y) = (Ax + By, −Bx + Ay) to the mesh, where A, B, C, D are functions of x 2 + y 2 as above, and a, b, c, d are constants determined by (5.1) with r = s = 0.5, θ = π/16. In the second case, we solved Laplace's equation for the above boundary condition using the finite element mesh that results from small-step FEMWARP. In both cases we tried meshes with several different values of h. The results are tabulated in Table 5. As can be seen, discretized small-step FEMWARP outperformed continuum small-step FEMWARP.
In other words, not only did Type 3 reversals not occur, but in fact it seems to be preferable to use the discretized solution for mesh warping rather than the continuum solution. The difference between φ + and φ is the usual discretization error in finite element methods. A possible explanation for the improved resistance to reversals of the finite element solution is as follows. After several steps of small-step FEMWARP, Laplace's equation is solved on a mesh with mostly poorly-shaped elements, some extremely poorly-shaped. A Laplace solution minimizes the functional F (u) = Ω ∇u · ∇u over H 1 functions u on the domain, and the finite element solution minimizes the same functional F (u) over the space of piecewise linear choices for u [18]. A very poorly-shaped element is "stiffer" than others in the following sense. An affine linear function u defined over a triangle that has an angle close to 180 • will have a quite large gradient value (compared to a well-shaped triangle with the equal area and equal nodal values) unless the nodal values lie in a certain restricted range. Therefore, the extra stiffness of these elements will cause them to be deformed less than the better-shaped elements in the optimal solution that minimizes F . Since the poorly-shaped elements are those most in danger of being reversed, this is a desirable effect.
The last topic to consider in this section is how to select a stepsize for small-step FEMWARP. The theory developed above indicates that as long as the step size is well below a step large enough to cause reversals of φ * , the step size should not matter so much. In fact, we propose the following simple strategy, which seems to be effective. Attempt to take a very large step (e.g., a rotation of size π in the case of the annulus). If this fails (causes reversals), then halve the stepsize and try again until success. Update the mesh and try another such step. Note that in the process of searching for a correct stepsize, the coefficient matrix in FEMWARP is the same for each trial. Therefore, the Cholesky factors do not need to be recomputed until the mesh is updated.
Another way to carry out small-step FEMWARP would be to take constant (small) steps on each iteration. We compared these two methods and found that the first was much more efficient, and furthermore, reversals are resisted better by the first strategy. Therefore, the repeated halving strategy is recommended. Table 5 summarizes the result for the annulus again. For the halving strategy, updates were pursued until the stepsize dropped below π/128. For the constant-step strategy, the stepsize was taken to be π/128. 6. Mesh warping and mesh untangling. In the previous section we considered reasons why FEMWARP can fail and also some possible workarounds. The workarounds in the previous section, however, are not available in all circumstances. For example, the workaround for Type 1 reversals, namely, small-step FEMWARP, requires a homotopy from the old to new boundary conditions and also requires solution of many linear systems with distinct coefficient matrices. The workaround for Type 2 reversals requires refined meshes, which may not be available.
Another workaround is to switch to a different algorithm, for example, Opt-MS, a mesh untangling method due to Freitag and Plassmann [14]. Opt-MS takes as input an arbitrary tangled mesh and a specification of which nodes are fixed (i.e., boundary nodes) and which are movable. It then attempts to untangle the mesh with a sequence of individual nodal moves based on linear programming. More details are provided below.
In this section, we consider the use of Opt-MS for mesh warping. We find that the best method is a hybrid of FEMWARP and Opt-MS.
To untangle the mesh, Opt-MS performs repeated sweeps over the interior nodes. For each interior node, it repositions the node at the coordinates that maximize the minimum signed area (volume) of the elements adjacent to that node (called the "local submesh"). The signed area is negative for a reversed element, so maximizing its minimum value is an attempt to fix all reversed elements.
Let x be the location of the free vertex, that is, the current interior vertex being processed in a sweep. Let x 1 , . . . , x n be the positions of its adjacent vertices, and t 1 , . . . , t n be the incident triangles (tetrahedra) that compose the local submesh. Then the function that prescribes the minimum area (volume) of an element in the local submesh is given by q(x) = min 1≤i≤n A i (x), where A i is the area (volume) of simplex t i . In 2D, the area of triangle t i can be stated as a function of the Jacobian of the element as follows: which is a linear function of the free vertex position; the same is true in 3D. Freitag and Plassmann use this fact to formulate the solution to max q(x) = max min 1≤i≤n A i (x) as a linear programming problem which they solve via the simplex method. On each sweep, m linear programs are solved which sequentially reposition each interior node in the mesh. Sweeps are performed until the mesh is untangled or a maximum number of sweeps has occurred.
A shortcoming of Opt-MS, in comparison to FEMWARP, is that it is not intended to handle a very large boundary motion even if that motion is affine. For example, starting from a 2D mesh, if the boundary vertices are all mapped according to the function (x, y) → (−x, −y) while the interior nodes are left unmoved, in many cases Opt-MS is unable to converge. FEMWARP, on the other hand, will clearly succeed according to Theorem 3.1.
Therefore, we propose the following algorithm: one applies first the FEMWARP mesh warping algorithm, and if the mesh is tangled, one uses Opt-MS to untangle the mesh output by FEMWARP (as opposed to the original mesh). The rationale for this algorithm is that FEMWARP is better able to handle the gross motions while Opt-MS handles the detailed motion better.
To test whether this algorithm works, we applied it again to the mesh depicted in Fig. 5.1. The boundary motion is as follows: we rotate the outer circular boundary by θ 1 degrees and the inner boundary by θ 2 degrees and then test three algorithms: FEMWARP alone, Opt-MS alone, and hybrid. (The hybrid was tested only in the case that the two algorithm individually both failed.) The results are tabulated in Table 6.1. The table makes it clear that the hybrid often works when Opt-MS and FEMWARP both fail. Thus, the hybrid method is another technique for situations when FEMWARP alone fails and small-step FEMWARP combined with mesh refinement may be unavailable. The hybrid method has the disadvantage, when compared to FEMWARP, that it does not produce a continuous motion of interior nodes but rather only a final configuration.
7. Three-dimensional tests. In this section we compare the robustness against reversals of FEMWARP, small-step FEMWARP, and the hybrid FEMWARP/Opt-MS method on examples of 3D meshes [21] and [15]. We choose specific nonlinear boundary deformations parameterized by a scalar α in order to determine how much deformation each test mesh could withstand when warped according to each method: Table 7 gives the results obtained from warping various three-dimensional meshes according to this boundary deformation. The data in this table is as follows. The first three columns give the -- name of the mesh, the number of boundary nodes, and the number of total nodes. The next column α max FEMWARP is the maximum value of α encountered for which FEMWARP succeeded. Parameter α was stepped by ∆α, where ∆α is indicated in the last column of the table. The table also shows α max ssFEMWARP , which is the last value of α for which small-step FEMWARP succeeds. The variablestep version of FEMWARP described in Section 5 was used. The minimum allowed stepsize for small-step FEMWARP was also taken to be ∆α.
The table indicates that small-step FEMWARP was about equal in robustness against reversals compared with FEMWARP except for the last mesh. In the case of "tire", small-step FEMWARP was much more robust. This is probably because the reversals in the first three rows are primarily Type 2 reversals since the meshes are very coarse, whereas the "tire" mesh is finer and is therefore more likely to see Type 1 reversals according to the arguments given in the previous section. Smallstep FEMWARP is intended to fix Type 1 reversals but is not effective against Type 2 reversals.
We also compared Opt-MS and the hybrid FEMWARP/Opt-MS method described in the last section. Opt-MS performed poorly because, as mentioned earlier, it is not designed to handle large boundary motions. The performance of the hybrid is comparable, and in some cases superior, to that of small-step FEMWARP. 8. Application to Cardiology. We now use FEMWARP in order to study the movement of the beating canine heart under normal conditions. To do this, we obtained data from the Laboratory of Cardiac Energetics at the National Institutes of Health (NIH) [24]. We were given (x, y, z, t) data for 192 points on the inner surface of the left and right ventricles of the beating canine heart from a physiological pacing experiment. The data frames are 14.6 milliseconds apart with the first frame occurring 12 milliseconds before the pacing spike.
The first step in the simulation of the ventricular movement was to generate a mesh for the initial position of the ventricles. In order to do this, we first noted that the 192 points we were given were arranged in eight slices with 24 points each. Thus, in order to generate the initial mesh, we decided to create a mesh for the top slice and then use FEMWARP to do the mesh warping necessary to create meshes for the remaining slices. Note that this uses FEMWARP in one and two dimensions as we describe in detail below. Once we have the meshes for all of the levels, we connect the triangular meshes into a tetrahedral mesh for the ventricles. The procedure to do this is also described below.
We now give a more detailed description of the method we used to create the initial mesh of the canine ventricles. We first used Triangle to generate an initial mesh of the top slice (after projecting it into the x-y plane). Note that this yielded a good-quality mesh in the x-y plane with several additional nodes. Second, we computed the z-coordinates for the new points on the boundary of the top slice using 1D FEMWARP. Third, we used the weight-finding portion of our FEMWARP algorithm to compute the weights for the appropriate 2D linear system obtained from the x-and y-coordinates. Fourth, we determined the z-coordinates for the mesh of the top slice by forcing the z-coordinates to satisfy the appropriate 3D linear system using the 2D weights. At this point, we had the mesh for the top slice.
Our second task was to generate meshes for each of the remaining seven slices. This was done using our FEMWARP algorithm to warp the mesh for the top slice into meshes for each of the remaining slices. In order to accomplish this, the first step was to determine the coordinates of the additional boundary nodes for the mesh of the appropriate slice. This was done using 1D FEMWARP. Then, the (x, y) coordinates of the interior nodes of that slice were determined using 2D FEMWARP. The z-coordinates for the interior nodes were found by forcing them to satisfy the appropriate 3D linear system using these weights.
The third step was to connect the triangular meshes for each of the eight slices into one tetrahedral mesh for the canine ventricles. To do this, the corresponding triangles between two slices were connected to form a triangular prism. After a temporary mesh of triangular prisms was created, the triangular prisms were subdivided into tetrahedron using the method outlined in [7].
After the initial tetrahedral mesh was created, we checked its quality using the inverse meanratio mesh-quality metric. (The mean ratio was defined in [23] and was adapted for tetrahedral elements in [12].) Using this test, it was determined that the initial mesh was of poor quality. This was because the eight slices were equally-spaced even though the curvature of the ventricles changes much more rapidly near the bottom of the heart. Thus, we decided to use linear interpolation in conjunction with FEMWARP in the obvious way in order to add two additional slices of nodes near the bottom of the heart. Because the curvature of the ventricles changes more rapidly near the bottom of the heart, the first additional slice was placed halfway between levels 7 and 8, and the second additional slice was placed halfway between the first new level and level 8. The resulting initial mesh is shown in Figure 8.1.
After the initial mesh was created, the heart data was used to move the 192 data points on the boundary of the mesh to their new positions The same process as above (i.e., FEMWARP in 1D, FEMWARP in 2D, and using 1D FEMWARP to add the two new levels of data near the bottom) was used in order to reposition the remaining boundary points. Once the boundary nodes were relocated to their positions for timestep t = 2, the 3D version of FEMWARP was used to move the interior nodes to their new positions for this timestep. This process was performed iteratively in order to study the movement of the heart at timesteps t = 3, . . . , 32.
The simulation of the canine ventricular movement produced a series of meshes that show the ventricles twisting, expanding, and then contracting over the cardiac cycle. This is consistent with what occurs in nature. Because the dynamic range of the motion is small, it cannot be detected in single figures (separate from an animation). During each timestep, the inverse mean ratios of the tetrahedra in the mesh were computed. The inverse mean ratio computations showed that the heart remained untangled throughout the entire simulation. This is not very surprising since the heart mesh is composed of elliptical rings that seem to undergo less movement on each timestep than the circular rings in the test cases. However, the motion of the heart is anisotropic which makes it difficult to predict in advance how it will tolerate deformations. Interestingly enough, the values of the minimum and average inverse mean ratios were relatively constant across all timesteps. Only the value of the maximum inverse mean ratio changed a significant amount. However, it only increased by as much as four percent of its initial value and decreased by as much as seven percent of that value. Thus the inverse mean ratio computations indicate that the heart meshes are of sufficiently good quality for use with a numerical PDE solver that requires moving meshes.
In order to further test our mesh warping algorithm, the motion of the ventricles was exaggerated by a factor of 3. In this case, the motion was large enough to detect in separate figures and is shown in Figure 8.2. We note that the FEMWARP algorithm also performed successfully in this case, which is encouraging given the much larger deformations. Small-step FEMWARP was not needed for this problem.
9. Conclusions. We studied an algorithm called FEMWARP for warping triangular and tetrahedral meshes. The first step in the algorithm is to determine a set of local weights for each interior node using finite element methods. Second, a user-supplied deformation is applied to the boundary notes. The third and final step is to solve a system of linear equations based upon the weights and the new positions of the boundary nodes to determine the final positions of the interior nodes.
FEMWARP falls into a more general class of methods that we call linear weighted laplacian smoothing (LWLS). LWLS methods have several advantages. First, if a continuous boundary deformation is given, then methods within the framework are valid for computing the resulting trajectory that specifies the movement of the interior nodes. In addition, these trajectories will be continuous, which is vital for applications where continuity of motion is required. Second, sparse matrix algorithms may be used to solve the linear system which determines the final positions of the interior nodes. Third, the methods are exact if the boundary deformation is affine.
We then analyzed the case that FEMWARP fails, i.e., produces element reversals. Some workarounds include: taking smaller steps, using a finer mesh, and finally, a hybrid of FEMWARP and Opt-MS.
We tested the robustness of FEMWARP, small-step FEMWARP, and hybrid FEMWARP/Opt-MS on 2D annulus test cases and 3D general unstructured meshes. The latter two algorithms generally outperform plain FEMWARP, sometimes significantly. We also used FEMWARP to study the motion of the canine ventricles under normal conditions. 10. Acknowledgements. The authors wish to thank O. Faris and E. McVeigh from the Laboratory of Cardiac Energetics at the National Institutes of Health for the moving canine heart data that they provided. In addition, they wish to thank Dr. Lori Freitag-Diachin of Lawrence Livermore National Laboratory and Dr. Patrick Knupp of Sandia National Laboratories for providing us with the majority of the 3D test meshes. They benefited from conversations with G. Bailey and A. Schatz of Cornell, C. Patron of Risk Capital, T. Tomita of BRM Consulting, and especially H. Kesten of Cornell. The authors thank the two anonymous referees for their careful reading of an earlier version of this manuscript.