1 Introduction

The advantage of high-order numerical methods for solving partial differential equations is their higher degree of accuracy compared to low-order numerical methods. A major hurdle in the usage of these methods in the presence of complex geometries is the absence of robust high-order mesh generation methods [23]. In other words, these methods need a high-order mesh that accurately captures the features of the geometry to achieve their full potential [1, 10].

The typical approach for generating high-order meshes is to transform a coarse linear mesh [2,3,4,5,6, 9, 11, 12, 14, 16, 17, 19,20,21,22, 24]. At a high-level, these transformations usually consist of the following three steps: (1) the low-order mesh is enriched with additional nodes; (2) the new nodes that lie along the boundary of the mesh are moved to the true boundary; (3) the interior nodes are moved based on the boundary deformation. The main challenge of these methods arises from step (2). In particular, the curving of the elements along the boundary can result in invalid mesh elements. With that in mind, these high-order mesh generation methods use different approaches in step (3) in an effort to obtain a valid high-order mesh. Methods for transforming the linear mesh usually fall into two groups. The first group of methods transform the mesh based on the solution to a partial differential equation [3, 12, 14, 24]. The second group of methods are based on optimization of an objective function [2, 4, 5, 9, 16,17,18,19,20,21].

In this paper, we describe an optimization-based approach for generating high-order meshes based on affine combinations of nodal positions. The remainder of this paper is organized as follows. In Sect. 2, we present our new method for high-order mesh generation. In Sect. 3, we demonstrate the performance of our proposed method on several aerospace engineering geometries. Finally, in Sect. 4, we offer some concluding remarks and possible directions for our future work.

2 High-Order Mesh Generation Based on Affine Combinations of Nodal Positions

In this section, we present our optimization-based method for high-order mesh generation. Our proposed method uses affine combinations of nodal positions to determine the movement of the interior nodes after deforming the boundary. Our method consists of three steps. First, for each interior node in the high-order straight-sided mesh, an optimization problem is solved to calculate a set of weights that relates the interior node to its neighbors. Second, the boundary nodes are moved to the true boundary. Third, the new positions of the interior nodes are calculated by solving a linear system of equations using the weights and the new boundary positions. In spirit, this method is similar to the weight-based method that we proposed in [19] with two major differences. The first difference is that we propose an affine combination of nodal positions in this work, as opposed to a convex combination. This change allows us to remove the inequality constraint and log-barrier term, leaving only the equality constraints. We also propose an alternative objective function that when combined with the equality constraints allows us to directly solve the optimization problem via a QR factorization. This change results in simplified computational complexity and faster execution time.

To frame our discussion of the method, we introduce the following notation for the 2D formulation of the problem; the 3D formulation is similar. Let the x- and y-coordinates of the ith interior node be represented as (x i, y i). In addition, define the x- and y-coordinates of the vertices adjacent to node i as {(x j, y j): j ∈ N i}, where N i is the set of neighbors of node i. For each interior node i, this information can be represented as the following linear system, where w ij are the weights:

$$\displaystyle \begin{aligned} &\sum_{j \in N_{i}} w_{ij}x_{j} = x_{i}\\ &\sum_{j \in N_{i}} w_{ij}y_{j} = y_{i},\\ \end{aligned} $$

where

$$\displaystyle \begin{aligned}N_{i} = \{\text{high-order nodes of the patch to which }i\text{ belongs}\}.\end{aligned}$$

There are several potential choices for the local neighboring set based on use of the low-order nodes, high-order nodes, or both. We include only the high-order nodes as neighbors, as only the high-order boundary nodes move during the boundary deformations. Using either the low-order nodes or both the low- and high-order nodes would dampen the effect the boundary deformation has on the interior nodes, which might lead to tangling near the boundary. Including additional nodes as neighbors would also result in a less sparse matrix when solving (7). Another important consideration is that while the weight calculation is based on only the local neighbors, the position of an interior node is indirectly affected by the deformation of all the interior nodes through the solution of (7).

Adding the additional constraint that the weights sum to one results in the following linear system Aw = b for finding an affine combination of the x- and y-coordinates of the vertices adjacent to node i:

$$\displaystyle \begin{aligned} \begin{bmatrix} x_{1} & x_{2} & \dots & x_{n} \\[0.5em]y_{1} & y_{2} & \dots & y_{n} \\[0.5em] 1 & 1 & \dots & 1 \end{bmatrix} \left[ \begin{array}{c} w_{i1} \\[0.5em] w_{i2} \\[0.5em] \vdots \\[0.5em] w_{in} \end{array} \right] = \left[ \begin{array}{c} x_{i}\\[0.5em] y_{i}\\[0.5em] 1 \end{array} \right], \end{aligned}$$

where n = |N i|. Based on the set of neighbors, this linear system will be underdetermined (i.e., A = m × n with m < n) in general. If we assume that A has full rank, we can find one particular solution to our problem by requiring that w has the smallest norm of any solution. This results in the following optimization problem:

$$\displaystyle \begin{aligned} \underset{w}{\text{min}}||w||{}_{2}^{2}{} \end{aligned} $$
(1)
$$\displaystyle \begin{aligned} \text{subject to} \ Aw=b{}. \end{aligned} $$
(2)

From the Karush–Kuhn–Tucker (KKT) theory [13], we know that the following conditions must hold for a solution (w ∗, λ ∗) to our problem to be optimal:

$$\displaystyle \begin{aligned} \nabla_{w}\mathcal{L}(w^{*},\lambda^{*}) = 0{} \end{aligned} $$
(3)
$$\displaystyle \begin{aligned} Aw^{*}-b = 0 \end{aligned} $$
(4)
$$\displaystyle \begin{aligned} \lambda^{*}(Aw^{*}-b)=0{}. \end{aligned} $$
(5)

The Lagrangian of our problem is given by:

$$\displaystyle \begin{aligned} \mathcal{L}(w,\lambda) = w^{T}w - \lambda^{T}(Aw-b),\end{aligned}$$

where λ are the Lagrange multipliers.

Using (3)–(5), we can find the following solution pair (w ∗, λ ∗) as follows:

$$\displaystyle \begin{aligned}\nabla_{w}\mathcal{L}(w,\lambda) = 2w - A^{T}\lambda.\end{aligned}$$
$$\displaystyle \begin{aligned}\nabla_{w}\mathcal{L}(w^{*},\lambda^{*}) = 0 \Rightarrow w^{*} = \frac{1}{2}A^{T}\lambda^{*}.\end{aligned}$$
$$\displaystyle \begin{aligned}Aw^{*}-b = 0 \Rightarrow A(\frac{1}{2}A^{T}\lambda^{*})-b = 0.\end{aligned}$$
$$\displaystyle \begin{aligned}\lambda^{*} = 2(AA^{T})^{-1}b \end{aligned}$$
$$\displaystyle \begin{aligned}w^{*} = \frac{1}{2}A^{T}\lambda^{*} = \frac{1}{2}A^{T}2(AA^{T})^{-1}b = A^{T}(AA^{T})^{-1}b.\end{aligned}$$

Although we have verified that (w ∗, λ ∗) is a stationary point, we cannot yet claim that it is a minimum. To do so, we must investigate \(\nabla _{w}^2\mathcal {L}(w^{*},\lambda ^{*})\):

$$\displaystyle \begin{aligned} \nabla_{w}^2\mathcal{L}(w,\lambda) = 2I_{|N_{i}|\times |N_{i}|}\\ \nabla_{w}^2\mathcal{L}(w^{*},\lambda^{*}) = 2I_{|N_{i}|\times |N_{i}|} \end{aligned} $$

From the second-order sufficient conditions, if w ∗ satisfies (3)–(5) and the following condition is satisfied:

$$\displaystyle \begin{aligned} z^{T}\nabla_{w}^{2}\mathcal{L}(w^{*},\lambda^{*})z > 0, \text{for all } z\in C(w^{*},\lambda^{*}), z\neq 0, {} \end{aligned} $$
(6)

where C(w ∗, λ ∗) = {z | ∇w c(w ∗) T z = 0} is the critical cone and c(w) = Aw − b, then our solution is a minimum. Since \(\nabla _{w}^2\mathcal {L}(w^{*},\lambda ^{*})\) is symmetric positive definite, the inequality in (6) is satisfied for any choice of z. Thus we can conclude that our solution w ∗ is a minimum of (1)–(2).

Now that we have established that w ∗ is our solution, we will discuss calculating it via a reduced QR factorization. Suppose that A T = QR, where Q n×m, R m×m is upper triangular, and Q T Q = I m×m. Substituting in the QR factorization of A T into w ∗, we get the following:

$$\displaystyle \begin{aligned} w^{*} = A^{+}b = A^{T}(AA^{T})^{-1}b &= QR(R^{T}Q^{T}QR)^{-1}b = QR(R^{T}R)^{-1}b\\ &= QRR^{-1}R^{-T}b = QR^{-T}b \end{aligned} $$

Rearranging this into linear system form, we have:

$$\displaystyle \begin{aligned}R^{T}Q^{T}w^{*}=b.\end{aligned}$$

If we let t = Q T w ∗, then R T t = b and w ∗ = Qt. Thus calculating w ∗ involves a QR decomposition of A T, solving the lower triangular system R T t = b by forward substitution, and calculating the matrix-vector product Qt.

After calculating the weights, a boundary deformation is applied. The final step is to solve for the new locations of the interior nodes \([\hat {x}_{I},\hat {y}_{I}]\) by solving the following global linear system:

$$\displaystyle \begin{aligned} A_{I}[\hat{x}_{I},\hat{y}_{I}] = -A_{B}[\hat{x}_{B},\hat{y}_{B}] {}, \end{aligned} $$
(7)

where \(\hat {x}_{B}\) and \(\hat {y}_{B}\) are the new x- and y-coordinates for the boundary nodes, and A I and A B contain the weights for the interior nodes and boundary nodes, respectively. In this global linear system, each row of the weight matrix corresponds to an interior node with nonzero entries for the node’s neighbors and zero entries for the remainder of the row. The resulting global weight matrix is very sparse with irregular structure. In an effort to shift the nonzero entries closer to the diagonal, we apply the sparse reverse Cuthill–McKee ordering provided in Matlab. In Fig. 1, we show the matrix sparsity plots for the natural node ordering and the updated node ordering for the first two examples in Sect. 3. After applying the matrix reordering, the linear system is solved using a sparse LU factorization.

Fig. 1
figure 1

Sparsity plots for the first two examples in Sect. 3: (a and c) the nonzero entries using the original node ordering; (b and d) the nonzero entries after applying the sparse reverse Cuthill–McKee ordering

3 Numerical Experiments

In this section, we demonstrate the results from applying our method to generate several high-order meshes. We use Gmsh [7, 8, 15, 21] to generate the initial straight-sided high-order meshes. Our method then uses this mesh to calculate the weights (step 1). Next, we curve the boundary nodes (step 2) using Gmsh. The positions of the interior nodes in the resulting curved high-order mesh are then updated (step 3) by our method. For each example, we show the mesh which results from our method (with high-order nodes visible), the mesh element distortion for the curved boundary mesh generated using Gmsh, and the distortion for the mesh resulting from our method. When reporting the mesh distortion, we list the minimum distortion, maximum distortion, average distortion computed over all elements (referred to as Avg1 in figures), and average distortion computed over curved elements (referred to as Avg2 in figures). The ideal distortion value is 1, indicating that the element is straight. We also list the execution times needed for steps 1 and 3 of our method (excluding I/O) in Table 1. The code was run using Matlab R2018a, and the wall-clock execution times were measured on a machine with 16GB of RAM and a Ryzen 7 1700 CPU. All mesh visualizations and distortion evaluations were done using Gmsh. Our first example is a third-order mesh of a square region around a NACA0012 airfoil. In Fig. 2a, b, we show the mesh resulting from our method and a table of the mesh quality values as measured by the distortion metric. In this example, our method increased the minimum distortion from 0.744 to 0.799, while causing only minor changes in the average distortion.

Table 1 The number of elements and the wall clock times for steps 1 and 3 of our method (excluding I/O) for each example
Fig. 2
figure 2

NACA0012 airfoil example: (a) the mesh resulting from our method and (b) the mesh quality as measured by the element distortion metric

Fig. 3
figure 3

Extruded NACA0012 airfoil example: (a) the mesh resulting from our method and (b) the mesh quality as measured by the element distortion metric

In our second example, we extrude the NACA0012 airfoil and create a third-order mesh of the resulting region. In Fig. 3a, b, we show the mesh resulting from our method, and a table of the mesh quality values. For this example, our method improved the minimum distortion by 0.125, increasing it from 0.317 to 0.442.

Our third and final example is a second-order mesh of an Airbus A319 aircraft. Unlike our previous examples, this geometry resulted in tangled elements after curving the boundary. Although our method still increased the minimum quality, it was not able to untangle the mesh. To address this, we applied the high-order regularization scheme available in Gmsh as a post-processing step. Aside from changing the target Jacobian range to 0.3–2 and fixing the boundary nodes, all other parameters were left at their default values. The untangling for the original mesh took 14.14 s, while untangling the mesh resulting from our method required only 1.64 s. In Fig. 4a–c, we show the surfaces of the mesh resulting from our method, a view of a cut through the interior volume mesh, and a table of the mesh quality values. In Fig. 4c, we list the distortion for the mesh after curving the boundary, the distortion for the mesh resulting from our method, and the distortions of both meshes after applying the regularization scheme in Gmsh.

Fig. 4
figure 4

Airbus A319 example: (a) surfaces of the mesh resulting from our method; (b) a view of a cut through the interior volume mesh, and (c) the quality of the mesh with only boundary curving, the quality of the mesh resulting from our method, and the quality of both meshes after applying the regularization scheme available in Gmsh

Aside from the third test case, all of these examples were relatively straightforward. In each case, our method increased the minimum distortion when compared to only curving the nodes along the boundary. While additional testing is necessary to confirm this, our results for the third example seem to indicate that our method could be used to reduce the severity of the mesh tangling and thus simplify the work for an untangling method during post-processing.

4 Concluding Remarks and Future Work

We have presented a new optimization-based method for generating high-order meshes. Our examples have shown that the proposed method based on affine combinations of nodal positions tends to improve the quality of the most distorted elements, while causing minor changes to the least distorted elements. While our approach is optimization-based, we have demonstrated that the optimization problem can be solved directly using a QR factorization as opposed to the typical iterative optimization approach. This change results in lessened computational complexity and reduced execution time.

As part of our future work, we will consider other definitions for the set of neighbors of an interior node. We will also investigate other aspects of the linear system including other node reordering schemes and solvers. Finally, we will apply the untangling method that we proposed in [20] after extending it to 3D.