Dynamic mesh optimization based on the spring analogy

We present an implementation of the spring analogy for three dimensional meshes in OpenFOAM. All parameters of the spring system are treated as fields that can either be pre-defined by the user, or updated at each time step according to specified geometrical regions or diffusion equations. The purpose of the method is to provide a preprocessing tool for mesh optimization. We study three simple test cases, a deformed block, an airfoil and a hill, and we analyze the evolution of skewness, non-orthogonality and aspect ratio during the approach of dynamic equilibrium.


Introduction
Mesh quality is essential for computational fluid dynamics (CFD) simulations, and yet remains a time consuming if not frustrating issue in many cases.Complex geometries often require unstructured meshes, and the corresponding meshers are not always tailored to work easily for the cases of interest.
Here we present a pre-processing tool for OpenFOAM [1] (version 2.1.1)that aims at improving the quality of an existing mesh based on a physical principle.
This principle is dynamical equilibrium of a system of point particles, subject to nearest-neighbour forces.In the easiest approach followed here, these forces are springs of vanishing or finite equilibrium length and a given stiffness.The spring system is obtained by interpreting the mesh points as dynamical point objects of unit mass, and the edges as springs interconnecting them.
For unstructured triangular meshes around airfoils this idea was first studied by Batina [2], and revisited by many authors ever since (for a review see for example [3]).Often the main interest lies in the moving boundary problem, where during run-time of the simulation the geometry or its relative position with respect to the flow mesh changes.In OpenFOAM, this has been solved effectively based on the principle of diffusion [4][5][6] by a Laplacian approach (cf.[7]).Here this is not our focus, we are interested in mesh optimization during pre-processing instead.
The spring analogy approach has well known issues with the preservation of the cell topology.Depending on the choices of the parameters and the initial configuration, straight-forward implementations may show edge collapse and face or cell inversion.Batina [2] proposed linear springs with a stiffness inversely proportional to the spring length to prevent node collision.A successful generalization of the idea to modify the spring constant in order to achieve stability are torsional springs, developed by Nakahashi and Deiwert [8].Farhat et al. used and generalised this approach ITM Web of Conferences for triangulated meshes in two [9] and three dimensions [10].Another approach within the framework of a linear spring system is the ball-vertex method [11], where additional springs are added that resist the motion of a vertex to its opposite face.For more work on the stabilization of spring systems and other self-adaptive mesh motion methods, we refer the reader to [3,7,12] and references therein.
Here a different approach is followed, based on parameter fields that allow for case tailored dynamic mesh solutions.The benefit of the approach is that specific requirements on the mesh, like local refinement in selected regions, can be obtained by adjusting the parameters that enter the dynamics.The drawback is that the stability of the method depends on the parameter choices, and thus the approach can be expected to be less robust in general.
In Section 2 the physics of the underlying spring system is revisited, and a brief summary of its implementation in OpenFOAM is given in Section 3. Section 4 then presents three test case examples for the method, a deformed block, an airfoil and a smooth hill.We finally discuss the results and conclude in Section 5.

The spring analogy
Meshes for CFD calculations consists of a finite number of cells which are organized in a specific topology.Each cell can be defined by a set of faces that fully encloses a finite and non-zero volume.Each face is defined by a finite number of points, and each of the points is connected to two other points of the same face by an edge.
The spring analogy is based on the idea of mapping a mesh to a system of point objects connected by springs.This is achieved by identifying the mesh points with the dynamic point objects and the edges of the mesh with the springs, whose properties are to be specified.The dynamical system is then solved for its equilibrium configuration.Ideally, the latter can be back translated to a mesh with improved cell quality.
The defining property of a spring is the fact that the restoring force F is proportional to the displacement from the equilibrium position.For the spring between objects A and B with positions x A and x B , the force acting on object A is Here l 0 is the equilibrium length of the spring and k the spring stiffness.The force induced by object A onto object B through the spring is F BA = −F AB .The total force acting on object A due to edge springs is then The discrete dynamics of object A, subject to the force F A , can be expressed in terms of the velocity v A , Here A is a dimensionless constant bound by 0 and 1, modelling friction, n labels the time step, and t is the respective time increment.For a review on mesh spring systems and their numerical solution, see eg. [3].In the approach discussed here, the parameters k, l 0 , are treated as independent fields, and t is a constant.The mass field m can be absorbed into the stiffness fields, and is thus set to unity in the following.
For each spring a core with width l core is defined.The spring force from Eq. ( 1) is replaced by First Symposium on OpenFOAM in Wind Energy where l = |x B − x A |.This force diverges as l approaches zero.Note that for 0 < l < l core < l 0 the factor inside the square brackets is negative and thus object A experiences a repelling force.Thus edge collisions can be prevented, with a repulsive force of variable strength.Additional to the edge springs, further stabilizing forces from face and cell centres to the corresponding vertices are introduced, as sketched in Figure 1.They follow the spring law (1), with equilibrium length l 0 given by the mean of the distances from the mesh element centre to the vertices.The corresponding spring constants are denoted as k face and k cell , respectively.Core regions are defined similar to Eq. ( 4), where the subscript 'el' represents 'face' or 'cell', n points from the centre to the vertex, and V el is the volume of the element.The core volume is in both cases determined by a radius r el,core , In total, eight additional parameter fields were introduced, k core , l core , k face , k face, core , r face, core , k cell , k cell, core , r cell, core .They are available for additional control of the mesh dynamics, if necessary.

Dynamic mesh solver
A new dynamic mesh solver was implemented for OpenFOAM 2.1.1,solving Eq. ( 3) for each time step.The name of the solver is pointForceMotionSolverDynamics, it is derived from OpenFOAM's fvMotionSolver.It reads the mass, friction and total point force fields, all stored with support on the mesh points.The point force field has three underlying sources: The edge-supported spring force field and the face and cell stabilization force fields.All three yield contributions to the total force at each node and are updated at each time step.

Parameter field manipulation
The stiffness and the equilibrium spring length fields are spring specific data, and therefore stored with support on the edges of the mesh.For convenience they are combined from an isotropic and an axial contribution, both stored as point-based scalar data fields.In addition, a vector field n axial with point support is defined.The axial contribution to the spring properties is then calculated by projection of the edge vector onto n axial , and multiplication with the mean value of the axial scalar field at the corresponding edge points.

ITM Web of Conferences
Three methods are implemented for manipulating the parameter fields, including isotropic and axial edge property data and the axial vector field n axial : 1.The fields can be read from files and then be treated as constant.
2. The fields can be recalculated at each time step, given specific values in pre-defined geometrical regions.The list of cells that are inside the fixed regions is updated based on an algorithm that checks all neighbour cells, as long as the cell centre is found to lie inside.3. The fields can be solutions of diffusion equations, updated at each time step.
The latter method may for example be applied to the axial direction field n axial , which can thus be set up to follow normals from one patch to its opposite counterpart.

Boundary conditions
The following OpenFOAM boundary conditions for the vector field that defines the mesh point motion are supported: -fixedValue: Usually the displacement vector is set to zero on the boundary.
calculated: The boundary points are let free, the boundary thus deforms subject to the spring forces acting on the patch points1 .-fixedNormalSlip: Given the constant and homogeneous normal vector of the patch, the corresponding component of the displacement is ignored.This only works well for planes.
For non-plane boundary geometries, a new boundary condition was implemented: -tangentialSlide: The initial geometry is stored in memory, and each patch point is associated with a nearest face on that original geometry.After each infinitesimal movement it is projected back onto the geometry, by a divide and conquer algorithm with respect to that nearest face.The latter is updated based on a neighbour search at each time step.An optional parameter can be specified to realise a smooth transition between the calculated and the tangentialSlide boundary conditions.

Examples 4.1 A deformed block
A first test for the spring analogy is the deformed block from Figure 2. The initial mesh has 20 × 12 × 10 = 2400 cells, maximal extension of (1000, 500, 300) m in x, y, z direction, respectively, and simple grading factors (15, 1, 1).All boundary conditions were chosen to be calculated, so the mesh is freely moving under the influence of the spring forces.All parameter fields were uniform, with the following values: -Equilibrium spring length: l 0 = 30 m, -Spring stiffness: k = k face = k cell = 1 N m −1 , -Friction: = 0.08, All spring core coefficients were set to zero.The time increment was t = 0.1 s, the result shown in Figure 2 was obtained after 700 time steps.Clearly the springs have driven the mesh towards its equilibrium configuration.All deformation and grading features have disappeared in the converged solution.This impression is in agreement with the quantitative results shown in the left panel of Figure 3.One clearly observes a reduction of the mesh quality measures skewness, non-orthogonality and aspect ratio for the initially deformed block.Also note the fast convergence for the case of this simple and purely academic example.

A wind turbine airfoil
A C-type mesh around an airfoil was used for demonstrating the effect of inhomogeneous cell-isotropic spring stiffness, cf. Figure 4.The mesh has 2030 cells in each of the 4 layers perpendicular to the height direction z.The total mesh extension is 11 × 10 × 1 chord lengths in (x, y, z) directions, and the chord length is 1 m.The trailing edge was cut at the end.The following parameters were chosen for the mesh dynamics: -Equilibrium spring length: l 0 = 0.03 m, -Spring stiffness: k = 10 N m −1 in a cylinder of radius 1 m centred 0.  All spring core coefficients and the cell and face stabilizing forces were set to zero.The time increment was t = 0.1 s, the result shown in Figure 4 was obtained after 160 time steps.It shows the establishment of smooth boundary layer and wake refinement regions in dynamical equilibrium.Note that both the inflow boundary and the airfoil patch were equipped with the tangentialSlide boundary condition.
Figure 5 shows the mesh quality parameters skewness, non-orthogonality and aspect ratio for airfoil case from Figure 4 (left panel).The corresponding mesh parameters for the case of uniform stiffness2 are shown in the right panel for comparison.The realization of refinement by an inhomogeneous stiffness field is accompanied by reduced mesh quality improvement.

Complex terrain
The effect of axial stiffness, ie., a non-isotropic spring constant field, is shown in Figure 6 for the case of a structured mesh over a hill.For each time step a Laplace equation was solved to find vector field that carries the normals of the ground patch to the inverted normals of the top patch.Another Laplace equation was solved for a scalar field, with fixed value boundary conditions on these two patches, with uniform values -ground : , and zero gradient conditions on the sides.For each edge the total spring stiffness k was then set to the projection of the edge direction onto the patch normal transport field, multiplied with the local value of the axial stiffness field k ax .
The test mesh has 4 × 45 × 30 = 5400 cells and total extension of 100 m × 1000 m × 452 m.The initial structured mesh was created using the open source tool terrainBlockMesher [13], which in principle does not rely on spring dynamics for the creation of a boundary layer over complex terrain.
The following values were chosen for the remaining parameters: -Equilibrium spring length: l 0 = 0 m, -Face and cell stabilization: All spring cores were set to zero, the time increment was t = 0.1 s, and Figure 6 was obtained after 130 time steps.The inhomogeneous spring stiffness field yielded grading in height direction, following the terrain.Furthermore, the equilibrium solution shows splines that are orthogonal to the ground surface.Note that the boundary conditions of both the ground and the top patch were chosen to be tangentialSlide in this example.The mesh quality parameters for this case and their convergence are shown in Figure 3 (right panel).Face skewness and non-orthogonality were efficiently reduced by the spring method.Due to the boundary layer requirement the mean aspect ratio was increased compared to the initial mesh.

Discussion
We implemented a new mesh motion solver in OpenFOAM, based on the spring analogy.It is intended as a pre-processing tool for mesh optimization, and the purpose of this paper was to show that the basic principle works as expected on small test cases.Indeed we showed that by using inhomogeneous spring stiffness fields, the method is capable of creating surface boundary layers and mesh refinement regions as desired.
Our guide during this work was the idea that the dynamical equilibrium of a physical system may have beneficial effects on the quality of a mesh, whose purpose it is to provide the basis for numerical 03001-p.7 ITM Web of Conferences flow simulations with good convergence properties and high quality results.We are aware of the fact that this is a hypothesis, and issues one may have with CFD meshes do not necessarily have a counterpart that can be addressed by dynamic equilibrium.
The strength of the method is that skewness, orthogonality and aspect ratio issues can in principle be cured or alleviated by the spring system approach.The general tendency of the spring dynamics is to smoothen the properties of the mesh on global and local scales.This, however, also yields the possibility that refinement regions are washed away during the approach of dynamical equilibrium in homogeneous conditions.This is physically expected for the spring system, but not desired for CFD meshes.We address this problem by treating all spring and point properties as possibly inhomogeneous fields.
Our pre-processing tool is therefore based on various parameter fields that can be specified prior to the spring system simulation.Alternatively they can be updated at each time step, according to the varying cell content of pre-defined fixed geometrical regions, or solutions of diffusion equations.Especially the option to define inhomogeneous spring stiffness appears to be efficient for the creation of boundary layers and refinement regions.
We tested the approach of inhomogeneous spring stiffness fields in two examples, a C-type mesh around an airfoil and a structured mesh over a smooth hill.In both cases we observed that the method was capable of creating the desired refinement regions.However, these regions have an influence on the mesh quality parameters, since they might enforce stronger deformation conditions on the mesh.In the complex terrain example, the increased aspect ratio at the top of the domain is a direct consequence of the desired boundary layer near the ground patch, compared to the homogeneous stiffness solution.In the airfoil case, the transition between two different stiffness regions may have caused skewness and non-orthogonality.This might be improved by imposing smoothing routines on the inhomogeneous stiffness field, leading to more continuous properties of the dynamic spring system.
Our test examples showed that the spring equilibrium length is a parameter that should be treated with care.In general the spring system behaves unstable if the equilibrium configuration relies on compressive stress.This is intuitive, since small deviations will immediately imply stress release, followed by cell destruction.In contrast, with spring systems under tensile stress we observe rather robust behaviour and good dynamical convergence.
In summary the tool is susceptible to instabilities due to the freedom to set up the parameter fields, but it is precisely this option which allows one to incorporate experience and the understanding of the underlying physics and numerics into the mesh optimization.Future work will be concerned with the parallelization of the method and its application to realistic cases, including a comparative CFD mesh study.

Figure 1 .
Figure1.Springs connecting the centre of a mesh element with its vertices.Their equilibrium length is set to the mean distance of the vertices from the centre.

Figure 2 .Figure 3 .
Figure 2. The calculated boundary condition for the example of a deformed block.Left: the initial mesh.Right: the final mesh.
5 m from the trailing edge, -k = 25 N m −1 in a cube of side length 1 m including the trailing edge region, -k = 20 N m −1 in a cuboid of width and depth 1 m along the straight line from trailing end to the outflow region, -k = 3 N m −1 elsewhere, -Friction: = 0.2.

Figure 4 .Figure 5 .
Figure 4.The tangentialSlide boundary condition combined with inhomogeneous isotropic spring stiffness, for the example of an airfoil.Left: the initial mesh.Right: the final mesh.

Figure 6 .
Figure 6.The tangentialSlide boundary condition combined with inhomogeneous axial spring stiffness following patch normals, for the example of a hill.Left: The initial mesh.Right: The final mesh.