2.2. The Structured Surface Mesh Generation Method and Improvement Based on NURBS Surface Interpolation Mapping
The mapping method [
34] is the main method for structured surface mesh generation in CFD analysis. The existing mapping method is difficult to handle NURBS surfaces with trimming and parameterization problems. It also cannot reflect the impact of surface curvature changes on mesh quality.
Therefore, this paper proposes an improvement method. Firstly, the geometric preprocessing is performed on each partition surface of the ship hull to obtain a high-quality ship hull model. For any partition surface, by constructing multiple implicit planes (assuming the number of implicit planes is
m) and calculating the intersection points between each implicit plane and the partition surface,
m transverse section lines can be generated. Based on the NURBS curve interpolation algorithm, an equal number of discrete points (assuming the number of discrete points is
n) can be obtained on each transverse section line, thereby forming a regular topological point cloud with
m rows and
n columns. Subsequently, based on the NURBS surface interpolation algorithm, this partition surface can be reconstructed. The detailed steps of the intersection algorithm can be referred to in reference [
35], and the detailed steps of the NURBS interpolation algorithm can be referred to in reference [
36]. This preprocessing can eliminate the trimmed surfaces and problem surfaces in the original ship hull model and construct high-quality NURBS partition surfaces.
Next, the structured mesh generation is performed on the partition surface of the midship that has completed geometric preprocessing. The main process of mesh generation can be described as follows.
(1) Constructing the mapping parameter domain based on the NURBS surface.
By constructing the mapping parameter domain and mapping relationship of the NURBS surface, the space surface can be mapped to the parameter plane. The NURBS surface is a standard expression of current surface modeling technology. Its surface information can be provided through its surface control points, weight factors, and degrees. The coordinates of different positions on the surface can be obtained based on the node vectors in parameter direction
u and parameter direction
v. The expression of the NURBS surface with degree
is as follows:
where
represent the surface control points, which are used to form a rectangular topology array called the control grid;
represent the weight factors, which correspond to surface control points separately;
and
are the B-spline basis functions with degree
p,
q, which can be defined by the recursive formula, as follows:
where
k is the degree;
are the knots, which form the knot vector
. Clamped knot vector whose beginning and ending knot values are repeated with multiplicity equal to
is usually used, which can make the generated NURBS surface pass through the control polygon and tangents to both ends of the control polygon.
In the standard NURBS surface, the value range of the node vectors U and V is . And any mesh node on the space surface can correspond to a unique node vector. Therefore, the node vectors U and V can be used as parameter domain coordinates, and a unit-length parameter plane can be constructed as the mapping parameter domain. Based on the NURBS surface expression method, the coordinate conversion between the space surface and the mapping parameter domain can be achieved.
(2) Generating the structured surface mesh based on the mapping parameter domain.
Based on the required number of structured mesh in two dimensions, the node vectors in direction
u and direction
v of mapping parameter domain are uniformly divided. The positions and topological information of mesh nodes on the mapping plane are obtained. The node coordinate values in row
i and column
j of the mapping plane mesh topology can be represented as follows:
where
represents the weight factor of the control point closest to the surface target point, its value range is
;
m and
n, respectively, represent the number of rows and columns that generate mesh nodes along the direction
u and direction
v.
In the ship engineering field, the weight factors of all control points on the NURBS surface are usually set to 1, and Equation (
8) can be simplified as follows:
However, the mesh generated based on the above method cannot accurately represent the hull shape of the location where surface curvature changes significantly. Therefore, our method incorporates a mesh node position optimization algorithm based on surface curvature features, in order to further enhance the mesh quality.
Without changing the topology and number of mesh elements, our method adjusts the parameter domain coordinates of each mesh node on the partition surface boundary based on its curvature and then obtains the parameter domain coordinates of each mesh node inside the partition surface based on the linear interpolation algorithm.
According to Equation (
9), the coordinate values of the four boundaries (
;
;
;
) in the mapping parameter domain can be obtained. Taking the boundary
as an example,
j is set to 1 at this time. When the weight factors of all control points on the NURBS surface are equal and uniformly discrete, the parameter domain coordinate values of discrete point
i on this boundary can be represented as follows:
The distance between two adjacent points on this boundary can be represented as follows:
Since the boundary NURBS curve expression of the partition surface is known, the coordinate value and curvature of any point on the curve can be obtained. Assuming there is a point i on the boundary with a corresponding curvature , the distance between point i and point can be adjusted using the following method.
The distance calculation function that includes curvature features needs to satisfy the following conditions:
- (1)
The relationship between curvature and distance should be represented using the non-piecewise function, ensuring the smooth transition for distance adjustment;
- (2)
The curve formed by the function should be smooth at both ends and nearly linear in the middle;
- (3)
The function should have upper and lower limits to avoid generating excessively large or small mesh elements;
- (4)
Since the minimum curvature value is 0, and the maximum curvature value can approach infinity. When using the average curvature to measure the curvature feature, it should be ensured that the curvature transition is smoother when the curvature increases than when it decreases.
To satisfy the above conditions, a combination of exponential function and inverse trigonometric function is used to obtain the objective curve. The distance between two adjacent points in the parameter domain based on curvature features can be represented as follows:
where
represents the average curvature of this boundary NURBS curve;
represents the curvature of the point
i;
represents the initial distance between point
i and point
, which has been given by Equation (
11);
represents the adjusted distance between point
i and point
.
According to Equation (
12), when
is equal to the average curvature
,
is equal to
, indicating that the mesh size remains unchanged. When
is less than
,
increases gradually with the decrease in
, which means that the curvature decreases, the geometric complexity reduces, and the mesh size increases accordingly. When
is greater than
,
decreases gradually with the increase in
, which means that the curvature increases, the geometric complexity rises, and the mesh is refined progressively to satisfy the requirement of geometric adaptability.
The minimum value of curvature is 0, and its maximum value can approach infinity. Even in the extreme case, the value range of is approximately between 0.707 and 1.189, which means that through mesh size adjustment, there will not be a huge multiple difference between the maximum mesh size and minimum mesh size, thereby affecting the mesh quality.
Based on the above method, the parameter domain coordinates of all discrete points on this boundary can be calculated iteratively. However, due to the adjustment of the distance between adjacent points (the distance is no longer but adjusted to ), the number of newly generated points on this boundary may be inconsistent with the number of initial points.
If the number of newly generated points is greater than the number of initial points, which means that
is too small,
should be adjusted as follows:
If the number of newly generated points is less than the number of initial points, which means that
is too large,
should be adjusted as follows:
According to the above strategy, the iterative calculation is performed, is adjusted and is recalculated until the number of newly generated points is consistent with the number of initial points.
Based on the above method, the parameter domain coordinates of all discrete points on the four boundaries of the partition surface can be calculated. Then, based on the interpolation algorithm, the parameter domain coordinates of each mesh node inside the partition surface can be calculated.
Assuming two boundaries in direction u (; ), the parameter domain node coordinates of the discrete points in row i are and , and the line obtained by connecting these two points is ; there are two boundaries in direction v (; ), and the parameter domain node coordinates of the discrete points in column j are and . The line obtained by connecting these two points is . The node in row i and column j of the mapping plane mesh topology are the intersection point of lines and .
Based on the above method, the structured mesh on the mapping parameter plane can be generated, and corresponding node coordinates and mesh topology information can be obtained.
(3) The reverse mapping of mesh nodes in the parameter domain.
The mesh nodes generated in the parameter domain are reverse mapped to 3D space, and the structured mesh of the actual 3D space surface can be generated. Since the point coordinates in the mapping parameter domain represent the knot vectors along
U and
V dimensions of the NURBS surface, these point coordinates can be input into Equation (
7) to calculate the mesh node basis functions
and
at these positions. Then, the basis functions can be input into Equation (
6), and the coordinate values of the mesh node on the space surface can be obtained.
Since the structured surface mesh generation is based on the ship hull NURBS surface, its mesh nodes strictly adhere to being located on the ship hull surface, the error between the mesh and the actual ship type is equal to the modeling error. Based on the above method, high-quality structured mesh node coordinates can be obtained. By arranging these nodes according to the quadrilateral mesh topology, the ship hull structured surface mesh can be obtained.
2.3. The Unstructured Surface Mesh Generation Method and Improvement Based on Advancing Front Technique
The advancing front method is the common method for unstructured surface mesh generation in CFD analysis. By combining the mapping relationship between the parameter domain and the space surface in the mapping method, the parameter surface is used to calculate the mesh node coordinates, which improves the mesh generation efficiency, and generates high-quality mesh elements [
37]. However, due to the non-uniformity of metric mapping between the surface and the parameter plane, it is nearly impossible to accurately describe the distortion of element metric mapping. As a result, the quality of meshes mapped onto the 3D surface cannot be fully guaranteed. Meanwhile, the mesh quality on the parameter plane may deteriorate severely, making it impossible to apply conventional 2D advancing front mesh generation method.
Therefore, this paper proposes the advancing front corner segmentation strategy, according to the size of the angle formed by adjacent fronts, the angle is divided and an unequal number of mesh units is generated, which enhances the controllability and stability of the algorithm. Additionally, this paper optimizes the method based on surface curvature features to ensure that the mesh can accurately reflect the geometric shape of the hull. The influence of surface curvature features is mainly reflected in the following two aspects: the generation of the initial advancing front and the determination of the advancing step length. Its mesh generation process can be described as follows.
(1) Constructing the parameter surface.
Before generating the unstructured mesh of the surface, it is necessary to construct its corresponding parameter surface. In this paper, the parameter surface is the 2D parameter domain, which is composed of node vectors in direction
u and direction
v of the NURBS surface parameter domain. Therefore, the method of constructing the parameter surface in the unstructured mesh generation is exactly the same as the method of constructing NURBS surface mapping parameter domain in the structured mesh generation. The detail steps can be referred to in
Section 2.2, which will not be repeated here.
(2) Constructing the initial advancing front based on the surface curvature feature.
The initial advancing front is the foundation for generating mesh using the advancing front method. It represents discrete points connected in a certain order on the surface boundary. Therefore, from the geometric perspective, this step is also referred to as the discretization of surface boundary points. During construction of the initial front, in order to ensure that the generated mesh element approximates the shape of the equilateral triangle as much as possible, the traditional advancing front method needs to satisfy the approximate equal distance between any two adjacent nodes. Since the parameter surface constructed based on the NURBS surface parameter domain is a unit-length square, the length of each edge along the parameter surface boundary is equal. However, the length of each side along the actual space surface is unequal. To ensure equal distance between adjacent discrete points after the discretization of boundary points, the values of adjacent nodes on each side in the parameter domain can be represented as follows:
where
represents the distance between any two adjacent discrete points on edge
m of the surface in the parameter domain,
represents the length of edge
m on the surface,
N represents the total number of discrete points on the surface boundary.
Then, the distance between two adjacent nodes at the initial advancing front can be adjusted based on its curvature. The distance adjustment method is the same as the adjustment method for boundary discrete points in the structured mesh generation method. The distance between point
i and point
on edge
m of the surface in the parameter domain can be represented as follows:
The detailed calculation and iteration steps can be referred to in
Section 2.2, which will not be repeated here.
(3) Determining the advancing direction based on the advancing front corner segmentation strategy.
The conventional advancing front method does not always yield ideal results in surface triangulation. The cause lies in the fact that corner points on the surface cannot always be divided into two triangles. In an ideal scenario, when the included angle between two 3D curves at a corner point is
, the conventional method can achieve good results. However, when the included angle
between the two curves at the corner point deviates significantly from
, this method is bound to cause intersections of the two triangles at the corner point in the parametric plane (when
) or generate cracks (when
), as shown in
Figure 2. To ensure the continuation of the triangulation process, it is necessary to perform compromise processing on the meshes at the intersecting or cracked areas. This compromise will reduce the mesh quality at these locations, deteriorate the advancement results of the next front, and accumulate errors gradually during the progressive advancement.
In many commercial software, such as Pointwise, Gambit, and ANSYS Fluent, there are already solutions for these problems. These software have designed their own mesh element detection methods, which can check the mesh element validity, determine whether the mesh nodes of the newly generated mesh element fall in a reasonable area. If an incorrect mesh element is generated, it will be deleted and a new element will be generated to avoid mesh intersection or crack.
However, the specific principles for solving these problems in these commercial software cannot be found in their public materials. In order to reduce the losses caused by such problems, this paper proposes the advancing front corner segmentation strategy, according to the size of the angle formed by adjacent fronts, the angle is divided and an unequal number of mesh units is generated.
Firstly, the front to be advanced should be determined. Among all front nodes, an angle is formed by three adjacent front nodes. Each iteration selects the smallest angle in the front for judgment. If , only one triangle is formed at this corner point; if , two triangular elements are formed; if , three triangular elements are formed.
As shown in
Figure 3, if the angle
, point
A and point
C are directly connected to form a triangular mesh element. Otherwise, the angle needs to be divided into two or three equal angles, and the shorter edge can be selected to form a new triangular mesh element by generating a new mesh node
D.
The red dash line in
Figure 3 represents the new topological connection line of the mesh nodes, and the triangle identified by this line is the newly generated triangular mesh element.
(4) Determining the advancing step length based on the surface curvature feature.
As shown in
Figure 3, to ensure the quality of the triangular mesh element generated after advancement, the advancing step length
is set to be equal to the length
of the front edge to be advanced.
Then, the curvature correction parameter can be introduced to adjust the advancing step length
. Assuming the mapping point of point
D on the curve segment
is
M, the mean curvature of the point
M is
, the mean curvature of the point
D is
, the ratio of advancing step lengths of these two positions can be represented as the curvature correction parameter
K. By substituting them into Equation (
16), it can be represented as follows:
where
represents the mean curvature of this partition surface.
By replacing the initial advancing step length
with
, the corrected advancing step length based on curvature features can be obtained. According to Equation (
17), compared with the advancing front, when the curvature of node
D increases,
decreases, the curvature correction parameter
K is less than 1, indicating that the geometric complexity rises and a smaller mesh element is required, resulting in a decrease in the advancing step length; on the contrary, when the curvature of node
D decreases,
increases, the curvature correction parameter
K is greater than 1, indicating the geometric shape is relatively flat, the advancing step length can be correspondingly increased.
(5) Calculating the mesh nodes based on the parameter surface.
Assuming that two adjacent points on the front are A and B, respectively, the corresponding coordinates of these two points on the parameter surface are a and b, the distance between the target mesh node D and the existing node B is , the angle with B as the vertex angle is . Based on the method described above, the size of angle can be determined through the advancing front corner segmentation strategy; the length of distance can be determined through the corrected advancing step length. When and are known, the node on the surface has a unique solution.
Firstly, the actual coordinate of the mapping point M of D on the curve segment can be calculated. Since and are known, the actual coordinate of M can be directly calculated based on the sine theorem. The corresponding point of M on the parameter surface is m, the parameter domain coordinate of m can be calculated based on the linear interpolation algorithm.
Subsequently, the parameter domain coordinate of
D can be calculated. Assuming that
represents the direction vector of the curve segment
,
represents the unit normal vector at point
M; then, the unit advancing vector of the surface at point
M, also known as the direction vector of the curve segment
, can be represented as follows:
Since the non-overlapping of the two dimensions in the parameter surface, along the parameter direction
u and parameter direction
v, the partial derivatives of any surface point can be obtained, and the vector product of these two derivatives is not 0. Therefore, for point
D and point
M, the following equation can be satisfied:
where
and
, respectively, represent the increments of the coordinate
d relative to the coordinate
m in the parameter direction
u and parameter direction
v,
d is the corresponding point of
D on the parameter surface;
represents the distance between the actual coordinates of point
M and point
D.
The corresponding parameter increments
and
can be obtained by solving Equation (
19). The position of
d on the parameter surface can be represented as follows:
The principle of calculating a new mesh node based on the parameter surface mentioned above can be shown in
Figure 4.
After calculating the coordinate of the target node in the parameter domain, it is reverse mapped to 3D space, the corresponding coordinate of the target node on the space surface can be calculated.
(6) Detecting and adjusting the intersecting mesh nodes.
Since the advancing front method only generates one new mesh element at a time, when using this method to advance the mesh, the following situations will always occur: the generated new mesh element overlaps with other existing mesh elements, or the remaining space after advancing the mesh front is difficult to continue generating high-quality mesh elements. The above situations will seriously affect the mesh quality, and even prevent the completion of the mesh generation process.
Based on the method of constructing the detection point, the intersecting mesh detection can be completed. The coordinate of detection point e in the parameter domain can be calculated by using 1.5 times the length of and as increments. Then the line between a and e, and the line between b and e in the parameter domain can be constructed. By detecting whether these two lines intersect with the lines between other adjacent points on the front, it can be determined whether the intersecting mesh node needs to be adjusted.
For the mesh node that needs to be adjusted, the distance between all nodes on the advancing front and the target mesh node D should be calculated, and D will be moved to the position of the node closest to it, which can avoid the mesh overlapping.
(7) Determining the termination criterion of advancing front method.
In theory, the advancing front method can continuously generate mesh elements until the advancing front does not include any mesh node. However, if the number of mesh nodes on the front is small, continuing to advance may result in low-quality grids due to algorithmic reasons, continuing to advance the mesh front may result in low-quality mesh elements. It is necessary to handle certain specific situations, which can ensure the mesh elements near the center of the surface advancing front have high quality.
When the number of mesh nodes in the convex polygon formed by the advancing front is less than 7, it enters the termination stage of the advancing front algorithm. For the regular hexagon, generating a new node at its centroid position can ensure that all generated mesh elements are equilateral triangles, which means that the mesh elements achieve the theoretically optimal quality. Based on the above description, it is apparent that when the number of mesh nodes is less than 7, only an additional new mesh node needs to be generated, which can meet the requirements of high-quality mesh elements.
Based on the above method, the unstructured mesh can be generated.
2.4. The Surface Mesh Optimization Strategy Based on Mesh Quality Evaluation Parameters
The mesh quality evaluation parameters are the quantitative criteria for measuring mesh quality. The averaging optimization method based on Laplacian smoothing [
38] cannot directly improve mesh quality, it requires multiple algorithm iterations to satisfy mesh quality. The mesh node optimization method based on the optimization principle [
30] can use mesh quality evaluation parameters as the objective functions to optimize the mesh, which makes the mesh optimization objectives clearer. The specific steps can be described as follows.
(1) Constructing the mesh optimization objective function.
The mesh quality is the criterion for measuring whether the geometric shape and smoothness of the mesh can satisfy the calculation requirements. There are numerous types of mesh quality evaluation parameters, and different software and research often verify mesh quality based on multiple mesh quality evaluation parameters, all of them have different verification criteria. In response to this situation, it is necessary to impose certain limitations on the selection of the objective function during the mesh optimization process.
During the mesh optimization process, the selection of the objective function has the following requirements:
- (1)
In the parameter domain, the objective function is a continuous unimodal function, and for any position within the solution domain, there is a unique function value corresponding to this position.
- (2)
The objective function that needs to calculate the average value should theoretically have upper and lower limits on the function value, which can avoid individual results with excessively large or small function values affecting the average value; the objective function that needs to calculate the ratio should avoid the range of function values that include 0, or special processing should be applied to results containing 0.
- (3)
Since the mesh optimization algorithm can only optimize a single mesh node during each processing, the objective function should ensure that it can reflect the geometric quality of the grid element. The global mesh quality evaluation parameters, such as mesh regularity, cannot be used as the objective functions in the optimization process.
- (4)
To ensure the efficiency of mesh optimization, the selected objective function should be as convenient as possible for calculation.
To satisfy the above requirements, some mesh quality evaluation parameters that are common and easy to calculate can be selected, such as angle skewness, aspect ratio, size change. Then these parameters should be normalized. The normalized processing converts these parameter values to values between the interval of . This paper selects the angle skewness as the objective function for mesh optimization. As the mesh quality improves, the mesh angle skewness will gradually decrease.
(2) Determining the low-quality mesh elements and calculating the optimized mesh node coordinates based on the threshold of the objective function.
When using a certain normalized mesh quality evaluation parameter, we assume that its mesh optimization threshold is . Based on this mesh quality evaluation parameter, all mesh elements on the ship hull can be calculated to verify the mesh quality, and the mesh elements with mesh quality evaluation parameters below threshold can be selected.
Then, by moving the mesh node to be optimized, the quality of the mesh composed of this node and its surrounding nodes is optimized.
Taking
Figure 5 as an example, the angle skewness is selected as the objective function. By moving the node
P, the angle skewness values of all triangle meshes connected to node
P are optimized.
Since the target mesh node P is located on the surface formed by its surrounding nodes , the parameter domain coordinate of P must be within the polygon enclosed by the corresponding parameter domain coordinates of . In the corresponding parameter domain coordinates of , by extracting the maximum value and minimum value in direction u and direction v, a quadrilateral region can be determined.
Based on the quadtree subdivision algorithm, the quadrilateral region mentioned above can be divided into four subregions. The actual mesh node coordinates corresponding to the center points of these four subregions are calculated separately, and the triangular meshes be constructed by connecting these nodes with nodes . The angle skewness results of these meshes are compared. The subregion with the best result is selected for the next quadtree subdivision iteration.
This process is repeated until the objective function value at a certain calculation point meets the threshold requirement of the objective function. Then, this calculation point is selected as the parameter domain coordinate values of the optimized mesh node, the actual coordinate values of this node can be calculated to achieve the mesh node optimization.
(3) Determining the termination criterion of the quadtree iteration.
In the practical calculation, since the limit of the mesh element geometric shape, it is possible that the surface mesh cannot reach the mesh optimization threshold, which will lead to an infinite loop in the mesh optimization process. To prevent this situation, it is necessary to set the threshold for the number of iterations. When the required number of iterations is not reached, the optimized node coordinates are obtained, the mesh element must satisfy that the objective function value is larger than the objective function threshold, and the optimized mesh node coordinates can be directly determined. When the required number of iterations is reached, it is necessary to judge the objective function value of the mesh element at this time. If the objective function value is larger than that before optimization, it proves that the objective function has reached the optimization value, the node coordinates can be directly used as the optimized mesh element coordinates. However, if the objective function value is smaller than that before optimization, it means that the quadtree method may have fallen into the local optimum. The original mesh node coordinates should be kept unchanged, and the mesh optimization should not be carried out.
By substituting the normalized mesh quality evaluation parameters into the method described in this section, the optimization of specific mesh quality evaluation parameters can be achieved directly. Since different mesh quality evaluation parameters are measures of the mesh geometric shape, it is impossible to adjust a single mesh quality evaluation parameter while keeping other parameters unchanged. Compared with the Laplacian smoothing algorithm, the mesh node optimization algorithm based on mesh quality evaluation parameters combines the operation of mesh quality evaluation with the operation of mesh quality optimization, the single determined mesh node position is the local optimal position of mesh quality, the repeated iteration optimization for all mesh nodes is not necessary. It can save mesh optimization time, simplify the operation of mesh optimization and evaluation, and make it more efficient overall.
On the other hand, using different objective function thresholds can have two effects. Firstly, it can change the number of low-quality mesh elements to be calculated. Secondly, it can change the iteration number of the mesh node optimization algorithm based on the quadtree method. These adjustments not only affect the mesh optimization time, but also affect the optimized mesh quality. Therefore, by setting different thresholds for the objective function, the mesh generation of different mesh quality can be achieved.