Meshing : a crucial step in CFD

In the series of articles concerning the backstage of my job, I offer you today a short description of a particularly important step in CFD (in any case, when using software based on the finite volume method) : the mesh.

Some generalities

Mesh definition

In CFD (and in numerical physics of continuums in general), the mesh is the spatial discretization of the medium that one wishes to model, composed of a set of elements connected to each other and whose union constitutes the domain of study. This mesh grid, embellished with boundary conditions on the edges of the domain, is thus used to numerically solve the discretized partial differential equations of the problem posed.

In the case of the use of “classical” or Eulerian numerical techniques (finite differences, finite volumes or finite elements), this is therefore a crucial and essential step in the modeling process*. The two CFD solvers mainly used at NEMOSFLOW (OpenFOAM and Code_Saturne) being based on the finite volume method, it is this point of view that is adopted in the rest of this article.

* There are indeed other types of methods which are devoid of the dependence on a mesh grid, we speak of Lagrangian methods. This is the case, for example, of the SPH (Smoothed Particle Hydrodynamics) method, based on the definition of a set of particles and their interactions.

Hybrid hexahedral / tetrahedral mesh according to the zones, with the presence of a prismatic boundary layer

Remark

When the resolution grid does not evolve during the calculation time, we speak of a static mesh. For certain problems (movement of the domain and/or inside the calculation domain, fluid-structure interaction, evolution of the refinement to follow the zones with strong gradient, for example), it is necessary that the mesh be updated regularly , even at each iteration: we then speak of a dynamic mesh. Many techniques exist, it could be the occasion of a next article 😉

Why is the mesh so important in CFD?

To perform a CFD simulation with a finite volume type solver, a quality mesh is often very important, even essential, for many reasons:

  • It must correctly discretize the geometry of the problem, which in many cases can be complex.

  • It must obviously make it possible to correctly capture all the expected physical phenomena. The accuracy and relevance of the solution obtained are directly related to it.

  • Its quality must be sufficient to ensure the convergence of the calculation.

  • For a given number of elements, a quality mesh will make it possible to obtain a convergence of calculation much faster during the resolution of the various iterative systems than a mediocre mesh: the saving of time and energy can prove to be substantial .

As a result, it is a step that should not be underestimated by the CFD engineer. From a methodological point of view, the whole of the following depends on it.

The different types of mesh

As said previously, in the context of a CFD solver using the finite volume method, the mesh is made up of small elements, voluminal if we are in 3D, connected to each other and whose set forms the domain of calculation. These elements can be of several types:

  • Tetrahedral

  • Hexahedrals

  • Pyramids

  • Prismatics

  • Polyhedral

  • Etc

The images below give an overview of some typical meshes. Each type of element has its own characteristics, with in particular different ways of managing the calculations of gradients or flows. As the next section will detail more, each type of mesh has its advantages and disadvantages, and there is no universal rule to favor. Obviously, a mesh can be totally hybrid and composed of all kinds of elements.

Hexahedral mesh
Tetrahedral mesh with prismatic boundary layer

What is a good mesh?

The absence of universal rules

The answer to this question retains, in all cases, an element of subjectivity: there is no standard methodology, to be followed systematically, to establish a quality network. However, there are a number of best practices. So, in general:

  • The realization of a good mesh is very dependent on the quality of the geometry built upstream. It is therefore important to spend time on this step: simplification of unnecessary details for modeling, repair of any surface defects, etc.

  • A reflection is imperative on the expected physical phenomena and the models that one wishes to use to simulate them. For example, modeling turbulence by a RANS-type model or by an LES-type model does not at all imply the same expectations in terms of mesh.

  • The mesh density must be sufficient to capture the different flow scales for a given physical model.

  • This mesh density can however be reduced in areas of low interest, or in areas with little evolution of the different fields, in order to optimize the computation time. A good mesh does not necessarily imply a uniform mesh density over the entire area!

  • Elements making up the mesh must, as far as possible, facilitate the calculations due to their characteristics. As such, certain mathematical tools make it possible to obtain quantitative analysis criteria, a brief overview of which is offered in the next section.

The most common quality criteria

N.B.: The few diagrams in this section are taken from one of the Wolf Dynamics presentations under the Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0). Thanks to them !

Orthogonality

Mesh orthogonality

Consider two elements with respective centers P and N, separated by a face with center f. The orthogonality of the mesh is defined by the angular deviation between the vector S, normal to the face with center f, and the vector d connecting P and N. A significant non-orthogonality of the mesh has an impact on:

  • Gradient calculation

  • Laplacians calculation

  • Numerical diffusion

Skewness

Consider two elements with respective centers P and N, separated by a face with center f. The skewness of the mesh is defined by the distance Δi separating fi, point of intersection between the vector d and the face with center f, and the point f. A significant skewness has an impact on:

  • Interpolation calculations

  • Convective, diffusive and gradient calculations

  • Diffusion and numerical errors
Mesh skewness

Aspect ratio

Mesh aspect ratio

The aspect ratio of an element is the ratio between its longest edge Δx and its shortest edge Δy. A large aspect ratio has an impact on:

  • Gradient calculations, unless the gradients are weak in the widest direction

  • Numerical diffusion

Expansion rate

The expansion rate defines the size transition between two adjacent cells, i.e. the ratio between Δy2 and Δy1 on the sketch. Too high an expansion rate notably adds digital diffusion to the calculation.

In general, it is estimated that this rate should ideally not exceed 1.2 or 1.3.

Mesh expansion rate

Remark

There are many other mesh evaluation criteria (determinant, Jacobian, etc.). With experience, and depending on the tools at his disposal, the CFD engineer generally learns to limit himself to only some of them, because it quickly becomes very difficult to want to satisfy all the criteria simultaneously as soon as the geometry is not academic.

Should we privilege a type of elements?

Historically, hexahedral type meshes have long performed better than their counterparts. However, with the increasing development of new methods and new numerical schemes, this discrepancy is generally no longer relevant, or at least no longer systematically. A few general rules can be followed:

  • Hexahedral or prismatic meshes retain a strong interest when the resolution grid can be aligned with the flow direction.

  • In particular, hexahedral or prismatic meshes are strongly recommended for the resolution of boundary layers.

  • In the case of complex flow, the hexahedral meshes are no longer of particular interest (outside the boundary layer).

  • Tetrahedral type elements inherently generate more numerical approximation/diffusion. However, these effects can be greatly mitigated by choosing the right digital schemes.

  • Tetrahedra have the advantage of adapting very easily to complex geometries, and the generation of a tetrahedral mesh is generally much easier and automatic than that of a hexahedral mesh.

  • While the numerical solution is generally faster with a hexahedral mesh than with a tetrahedral mesh (faster convergence of iterative subsystems), the time saved by “just” building a tetrahedral mesh can sometimes be enough to compensate for this gap.

  • Polyhedral meshes have the advantage of minimizing errors thanks to the high number of faces of a given element for the reconstruction of flows.

Conclusion

  • The construction of a good mesh requires good preparation of the upstream stages (quality of the geometry, analysis of the expected physical phenomena, choice of physical models).

  • It is strongly recommended to use hexahedral or prismatic elements for boundary layer resolution.

  • Outside the boundary layer, the choice of the type of elements has to be arbitrated according to the configuration and the numerical solvers available. In the case of flows with a dominant direction, the hexahedral meshes remain however the most recommended.

  • It is imperative to analyze the quality of its network based on the quantitative criteria defined above (or based on other criteria deemed more relevant, as the case may be). Most of the time, mesh generation tools and/or CFD solvers have utilities to perform this analysis.

  • Beyond the overall quality of the mesh, it is important to pay special attention to the few worst elements. They will indeed be responsible for a significant increase in the calculation time, or even a pure and simple numerical divergence!

Some used tools at NEMOSFLOW

As for the rest of my activity, I favor open source tools to generate my meshes. Several software offers this, of which here is a non-exhaustive list.

Salome

Digital multiplatform developed by EDF, which contains, among other things, a CAD module and a mesh generation module. The graphical interface is fluid and pleasant, and this tool has many features. In particular, there is the possibility of developing programming scripts (python language), which are very useful for adapting from one case to another, for example.

For more information, you can consult the website of the Salome platform.

Gmsh

2D/3D mesh generator developed by Christophe Geuzaine and Jean-François Remacle. The geometry and the mesh can be generated using scripts (C type language), which is very interesting for parametric evolutions. Its main flaw is that at present, this tool does not offer automatic 3D boundary layer generation.

For more information, you can consult the gmsh website.

BlockMesh

OpenFOAM utility, multi-block mesh generator. This tool generates high quality hexahedral meshes for simple geometries. This is typically the tool I use for building academic-type cases.

For more information, you can consult the OpenFOAM website.

SnappyHexMesh

OpenFOAM utility, hexahedral dominant mesh generator, from geometric surfaces defined in stl format. If it is necessary to provide it with the geometry upstream, this tool proves to be very powerful for generating good quality meshes, with an important control of the quality criteria of the mesh.

For more information, you can consult the OpenFOAM website.

CfMesh

Utility included in OpenFOAM, tetrahedral, hexahedral or polyhedral mesh generator, from surfaces defined in stl or fms format. This tool has less control and parameters than SnappyHexMesh, but it is remarkably fast and offers very good meshes for semi-automatic type generation.

Note that if CfMesh is open source, it is also the precursor of a commercial extension, named CfMesh+.

For more information, you can consult the CfMesh website.

Thank you for reading this article and for visiting the NEMOSFLOW website. See you soon!

Leave a Comment

Your email address will not be published. Required fields are marked *