• CFD, Fluid Flow, FEA, Heat/Mass Transfer
  • +91 987-11-19-383
  • amod.cfd@gmail.com

Mesh Generation

Meshing for CFD is 50% capability and 50% art!

A good mesh might not lead to the ideal solution, but a bad mesh will always lead to a bad solution - Patrick Baker (Pointwise)

Solid modeling (required to create 3D geometry) and mesh generation are at present separate steps, performed using different programs and software environment, and a greater seamless integration is still in distant future. The first step of meshing is to ensure the "topological consistency" of the 3D geometry when the data is transferred from "Solid Modeling" environment or "mesh generation" environment. The topology refers to the way points, lines and surfaces connect to form a three-dimensional space.

Meshing is not same as Tessellation.

This step involves division of the computational domain into small sub-divisions called a grid or mesh of cells/elements/control volumes. The 2D boundaries of this smaller (discretized) domains are called Faces, the 1D boundaries are called Edges and 0-D boundaries are called Nodes or Vertices. The solution of flow problems are defined at the nodes of the cells. In general, the accuracy of CFD simulation is governed by cell size. Finer the mesh (lower the cell size), better is the result. However, the hardware resource increase with increase in no. of cells (elements) in the mesh. Hence, a trade-off is required.

  1. The mesh resolution near walls affect calculation of wall shear as well as separation zone and location of separation. Appropriate mesh sizing is critical because fidelity of local wall shear predictions affects the prediction of frictional drag for external flows or pressure drop (which is also a form of frictional drag) for internal flows. Both the frictional and pressure drag for bluff bodies is dependent upon extent of separation zones.
  2. When you use the Spalart-Allmaras model or any other eddy-viscosity model with enhanced wall function, you should check that y+ of the wall-adjacent cells is either very small (on the order of y+ = 1), or y+ ≥ 30.
  3. The requirement of a non-uniform mesh is a necessity and not a limitation. The cell size is smaller is the regions of sharp gradients of field variables (velocity, pressure, temperature, shear stress, etc) and larger in the regions of less gradients.
  4. Though the region of sharp gradients cannot be anticipated a priori, this is the time where an insight into the physics of the problem is helpful.
  5. Most modern solvers come with a feature called "mesh-adaption". The solver automatically refines the mesh based on various setting such as y+ refinement. However care should be taken so that enough memory is available after such refinements as the mesh size (no. of cells / elements) can increase significantly after such adaptation.
  6. If machine time in computation is ignored, it takes approximately 70~80% of the overall simulation time in a good mesh generation activity.
Some of the jargons associated with meshing are:
  • Bi-directional associativity between CAD environment and pre-processing environment: This refers to the automatic updation of mesh when associated CAD geometry is updated.
  • Virtual topology such as slicing in Ansys Workbench, imprint in STAR-CCM+: This refer to changing the geometry to suit meshing requirements without affecting the underlying geometrical description. Note that there is a difference the way CAD environment treats geometrical entities and the way mesh generator software use those information.
  • Swept meshing, Multi-zone meshing, Paving, Blocking
Types of elements: note that a node is a 0-D element, an edge is an 1-D element, triangles and quadrilaterals are 2-D elements and tetrahedrons, hexahedrons, pyramids and wedges are 3-D elements. The 2-D elements which constitute the boundaries of a 3-D elements are called faces. Element which define the boundary of a computational domain will always have dimension 1 less than the dimension of the flow domain. For example, for 1-D cases the boundaries will be represented by nodes, for 2-D cases the boundaries will be of type edge elements and for 3-D cases the boundaries will have 2D elements.

Types of Elements

A wedge or prism element is normally created by slicing a tetrahedron parallel to its base. Since, this element is created by rule near the boundaries namely of type walls, they will appear triangles from one side and quadrilateral from other side.

The elements defining the flow domains other than boundaries are called interior elements. Note that the mesh topology used to specify simulation parameters may be different than the mesh topology internally created by the solver. For example, a solver may create a mesh around each node by connecting the centroids of all the elements associated with it. This is called a vertex-based scheme (e.g. CFX). In some cases, the mesh supplied to the solver will be used as provided such as FLUENT. This is known as cell-centred scheme.

Cell-centred vs. vertex-centred approach

Mesh Duality

Mesh Top Down Approach

Hanging Node
A surface is bounded by edges and edges are connected at vertices or keypoints or nodes. So, a rectangular surface is bound by 4 edges and the 4 edges themselves make 4 corners and thus 4 nodes, vertices or keypoints. Any straight edge of surface must be a connection between two nodes. Any node not meeting this requirement is called a a "hanging node" as described below.

Hanging Node Definition

Hanging nodes are considered crack in FE solvers for structural simulations. However, hanging nodes are acceptable in most of of the CFD solvers and FLUENT even has a method of mesh adaption based on handing nodes creation.

Mesh Generation Process: the two broadest categories of mesh are (a)structured mesh and (b)unstructured mesh. As the names suggest, structured mesh has a unique, predictable and repeatable topology whereas unstructured mesh is a pseudo-random distribution of element in space. Strcuctured meshes are composed of either quadrilaterals or hexahedrals. Unstrctured mesh can be a combination of all types of elements. Yet, a mesh consisting of only hexahedrals can also be unstructured mesh.

There are various mesh generation algorithms available in industry: OCTREE (QUADTREE), Delaunay, Advancing Front, Directed Meshing (Swept Meshing), Cut-Cell or Cartesion or snappyHexMesh, Paving, Multi-zone, Hexa-core ... to name few. Directed meshing techniques work on extrudable geometry: this refers to shapes which can be generated by linear (translational) and rotational or combination of both operation on a lower dimension geometry to get a higher dimension geometry. For example, a frustum is a linear extrusion of circular disk in radial as well as tangential direction, a cylinder is a uniform extrusion of circular disk, a circular disk is rotational extrusion of a line about one of its ends. The extrusion process is also known as sweeping or lofting operation.

Non-Manifold Vertices (Nodes)
A mesh or finite element representation of a real geometry is a connection of edges and points in a certain way. When the connection is representing a real geometry, it is said to be topologically correct. However, since edges and point can be connected in any arbitrary manner, they may not always represent the physically plausible geometry. Thus:

a non-manifold geometry or 3D shape cannot be unfolded into a 2D surface with all its normals pointing the same direction. In other words, a 3D model can be represented digitally but there is no geometry which can physically support it in the real world. In the following picture, a hexahedral element has internal tetrahedral element which is not necessary at all.

Non-manifold hexahedron

Similarly, if a vertex is attached to the interior of a surface or if surrounded by a volume but not connected with any of the edges defining that volume, it is called a non-manifold vertex.

One important aspect of mesh is the node-element relation for tri/tetra and quad/hexa elements. It is worth noting the fact that the ratio of nodes/elements tend to 1.0 for quadrilaterals and the ratio of number of nodes and number of elements defined by those nodes tend to 0.5 for triangles. They are explained in two sketches below. Hence, the memory space required to store triangle elements would be approx twice that of quadrilateral elements.

Node-Element Topology for Quad elements
Node-Element Topology for Quad elements

Node-Element Topology for Tri elements
Node-Element Topology for Triangle elements

One important consideration in generating mesh is also to capture the physics of the flow. Most of the time, we are focused on the boundary layer resolution over the walls and near the separation and reattachment regions. The underlying principle is to capture the gradient of field variables, in whatever direction they might be present. One such similar consideration is flow gradient in the entrance region when "uniform flow velocity" is to be applied. Here the gradient is along the direction of flow, similar to the one we observe perpendicular to the wall. Following images demonstrates the recommended mesh in the entrance region.

Mesh in Entrance Region
Mesh Not OK for Entrance Region

Mesh in Entrance Region
Mesh OK for Entrance Region

Mesh Quality

Recommendation from ANSYS FLUENT: For any other software, it is recommended to check the rating scale. For example, ICEM CFD considers skewness of 1.0 as perfect and scale is exactly opposite to that of FLUENT.

Skewness00 ~ 0.250.25 ~ 0.500.50 ~ 0.75 0.75 ~ 0.950.95 ~ 1.001.00
CategoryPerfect Excellent GoodFair PoorVery Poor Degenerate

Verbatim copy form ANSYS FLUENT 12.0/12.1 Documentation: Skewness is defined as the difference between the shape of the cell and the shape of an equilateral cell of equivalent volume. Highly skewed cells can decrease accuracy and destabilize the solution. For example, optimal quadrilateral meshes will have vertex angles close to 90°, while triangular meshes should preferably have angles of close to 60° and have all angles less than 90°.

  • A general rule is that the maximum skewness for a triangular/tetrahedral mesh in most flows should be kept below 0.95, with an average value that is less than 0.33.
  • A maximum value above 0.95 may lead to convergence difficulties and may require changing the solver controls, such as reducing under-relaxation factors and/or switching to the pressure-based coupled solver.

Verbatim copy form ANSYS FLUENT 12.0/12.1 Documentation: Aspect ratio is a measure of the stretching of the cell. For highly anisotropic flows, extreme aspect ratios may yield accurate results with fewer cells.

  • Generally, it is best to avoid aspect ratios in excess of 5:1 in the bulk flow (away from the walls).
  • The quadrilateral/hexahedral/wedge cells inside the boundary layer, on the other hand, can be stretched to aspect ratio of up to 10:1 in most cases.
  • With regard to the stability of the flow solution, it can go as high as possible; however, with regard to the stability of the energy solution, the maximum aspect ratio should be kept below 35:1.

Flow-Field Dependency: The effect of mesh quality (refinement and cell shape) on the accuracy and convergence of the solution process is dependent on the flow field being simulated. E.g. highly skewed or non-orthogonal cells can be tolerated in flow regions with no swirl or separation. On the other hand same mesh can be detrimental to simulation accuracy in regions with strong flow (pressure) gradients. Since the locations of strong flow gradients generally cannot be determined a priori, user needs to guess the flow field based on his/her past experiences as well as using analogy between actual flow field and standard flow conditions namely "flow over a cylinder", flow over a flat plate, "flow inside a duct" and flow between parallel plates.

All hexa mesh in T- and Y-Junction

The O-grid techniques can be used to generate hexahedron meshed in complicated geometries such as Tee-junctions and Wye-junctions as demonstrated in following image.

Mesh: Y- and T-junction

Some tips and tricks of mesh generation:
  • Delaunay method of mesh generation typically results in smoother transition from coarse mesh to fine mesh regions. Most of the meshing programs have provision to use an existing surface mesh to generate the volume mesh.
  • Sometimes, ICEM CFD is not able to generate surface mesh if the surface has strong curvature or iso-lines are not well defined. The surface mesh can be generated by
    • creating volume mesh using more robust OCTREE method
    • deleting volume mesh
    • repairing surface mesh
    • smoothing surface mesh with Laplacian smoothing switched OFF
    • smoothing surface mesh with Laplacian smoothing switched ON and finally
    • smoothing surface mesh with Laplacian smoothing switched OFF.
  • Once a good quality surface mesh is available, Delaunay method can be used to generate good quality volume mesh with better transition from coarse mesh region to fine mesh region and vice versa.

Mesh Types

A mesh is designated as structured, unstructured, hybrid, overset, conformal or non-conformal. These are based on the connectivity of the cells, nodes and edges. One of the misunderstanding is that a mesh consisting of only quad elements are always structured. This is not true and a structured mesh is identified by a pattern where each node is connected to same number of elements.

A mesh consisting of more than 1 element types such as tetrahedrons and hexahedrons are called hybrid. They may or may not be conformal. In case a hybrid mesh consisting of tetrahedrons and hexahedrons are conformal, pyramid elements need to be used to transition from tetra to hexa elements.

A non-conformal mesh has grid nodes which do not match up along an interface. This type of mesh is useful for design study where parts can be replaced without regeneration of the entire mesh. Sometimes, this type of mesh becomes a necessity for meshing complex geometries. Recommended approach to have number of nodes / elements in the ratio 2:1 or less on the two sides of a non-conformal interface.

For complex geometries such as engine under-hood thermal management, structured mesh quad/hex meshes are neither possible nor show any numerical advantage, thus one can save meshing effort by using a mesh consisting of tri/tetra elements.

Mesh Quality

The quality of mesh is a collective summary of quality of individual elements. Aspect ratio, skewness, orthogonality, determinant and Jacobian are some of the methods used to designate the quality of elements. One of the key quality metrics for mesh used in CFD simulations is skewness.

Skewness definition

Mesh skewness reduces the accuracy of face integrals (calculation of face flux) since the interpolated face value does not lie in the center of the face F, but instead lies at the intersection of vector joining cell centres and the common face, denoted by R above.

Warp: It applies only to quadrilateral elements and is defined as the variation of normals between the two triangular faces that can be constructed from the quadrilateral face. Warp value is the maximum of the two possible ways triangles can be created in a quadrilateral/rectangular face.

Various checks required to ensure the geometrical and topological consistency of a mesh is completely described by the options available in ANSYS ICEM CFD as shown below. Similar checks is possible in any other software such as ANSA, ANSYS Meshing, Pointwise and GridPro.

CFD Mesh Check Parameters

Mesh Generation in FLUENT Mesher
FLUENT mesher is a powerful mesh generation tool from ANSYS. This is a new avatar of T-grid. Import Mesh or CAD Geometry:

FLUENT Mesher import meshes


FLUENT Mesher toolbars

Hole Repair Steps:

FLUENT Mesher example of hole repair

Proximity Checks:

FLUENT Mesher proximity checks


FLUENT Mesher Wrapping

Volume Mesh Setting:

FLUENT Mesher Volume Mesh Generation

Mesh Generation in ANSA
Starting ANSA for CFD Application:

ANSA Startup Window

Mouse Button Setting:
  • The left mouse button is mainly used to: activate modules buttons, select or define entities. The double click of the left mouse button is mainly used to: edit entries in lists, control visibility by clicking on the screen
  • The middle mouse button is mainly used to: declare the end of a selection process, cancel the currently activated function
  • The right mouse button, depending on the function, is mainly used to: deselect previously selected items, reapply last action to other entities, pick closest point position (Working Plane mode), access the right click menu in lists, activate hidden windows, select buttons to custom place them on ANSA desktop panel. The double click of the right mouse button is mainly used to: control visibility by clicking on the screen
  • The mouse-buttons combined with the Control (Ctrl) key, are used for the View control. Mouse-buttons combined with the Shift key, are used for the definition of a polygon selection area.
ANSA Geometry Resolution Setting:

ANSA Geometry Resolution Setting

ANSA Geometry Import Setting:

ANSA Geometry Import Setting

The concept of Feature Area, which is defined according to the feature angle, is widely used in many functions in ANSA. The Feature Area is defined as the area of shell elements between whom the angle that is formed at their common edge is < the given feature angle. This is equivalent to "fill up to an angle" in ICEM CFD. Similarly for edges "Feature Line" selection tool uses the concept of "Corner Angle" which is defined as the angle formed by two consecutive element edges.

ANSA Geometry Check Options:

ANSA Geometry Check Options

SETs: for management of SET groups of ANSA entities like elements, properties, Faces, ... The CONS (Curves ON Surfaces) are the boundaries of the Faces. According to their connectivity, they are colored in Red (single edge), Yellow (double connectivity), Cyan (triple of more connectivity), orange when a double CONS has been joined. The Hot Points are the end points of CONS. A more handy way to deal with Faces is to use the Crosshatches. These appear as green dashed lines and represent the isoparametrics of the Surface on which the Face lays. A Face can be selected by its Crosshatch. In case that a Face is “frozen” (by the Freeze function), its crosshatch is colored in blue.

Use the function CHECK > GEOMETRY to identify and fix automatically some problems. Watertight preparation: Having extracted the outer surfaces, you must create the watertight model by sealing all gaps and eliminating the overlaps. If these gaps are small (close to the Tolerances), they can be closed by TOPO or PASTE functions. If they exceed (by far) the tolerances, then new Faces must be created (usually with SURFs>COONS) to close them.

Checking for intersections and proximities at Geometry level: You should make some checks for intersection and proximity while constructing your model. First of all, use the CHECKs > PENETRATION [Intersections] to locate intersecting areas (wrong topology, misplaced parts etc). Fix these areas using TOPO functions (like FACEs>INTERSECT). Use the ISOLATE > FLANGES [Proximity] function to isolate Faces within a certain distance apart. This will indicate you all the proximity problem areas that may cause problems in volume meshing. Then use the FACEs>FUSE function to close these narrow proximity passages, where possible.

ANSA Meshing Parameters Setting:

ANSA Meshing Parameters Setting

Before switching to MESH, activate SHADOW and FOCUS>UNCHECKED. If ANSA leaves any Faces visible, it means that they cannot be shaded and you should fix them also.

ANSA Volume Meshing Parameters Setting:

ANSA Volume Meshing Parameters Setting

ANSA Mesh Quality Checks:

ANSA Mesh Quality Checks

STAR-CCM+ Mesh Import Options:

STAR-CCM+ CAE File Import

STAR-CCM+ Volume Mesh Import:

STAR CCM+ Volume Mesh Import

STAR-CCM+ 3D to 2D Mesh Conversion:

STAR-CCM+ 3D to 2D Mesh Conversion

Mesh Formats

In its simplest form, a mesh is a collection of list describing coordinates of nodes and its connectivity with neighbouring nodes. Additionally, it may contain material information, name of a zone or domain a node and element belong to.
ANSYS format
The content of ANSYS structural *.ans file is as follows:
  1. Section-1: it contains basic information about the way solve has to run. All the lines starting with 'COM' are comments. e.g.
  2. Section-2: this section contains the node definition starting with a statement for coordinate system e.g. CSYS,0. each statement starts with the keyword 'N'.
  3. Section-3: the material properties are defined in this section.
    /COM Material properties 
    EX,        1,  2.068000E+08
    NUXY,      1,  2.900000E-01
    DENS,      1,  7.820000E-06
    GXY,       1,  8.015504E+07
    ALPX,      1,  1.170000E-05
    KXX,       1,  4.500000E+04
  4. Section-4: real constant table, element type and element coordinate system is defined in this section.
    ET,    1,  45,   0,   0,   0,   0,   0,   0
    TYPE,  1 $ REAL,     1 $ MAT,     1
    ESYS,  0
  5. Section-5: here each statement starts with keyword 'EN' followed by element numbers and nodes defining that element.
  6. Section-6: this section contains boundary condition (reaction points, loads and supports), analysis type (static, harmonic, transient ...)
    SFE,  1496,      1,  PRES, 0,  1.00000    
    SFE,  1497,      1,  PRES, 0,  1.00000    
    SFE,  1498,      1,  PRES, 0,  1.00000    
    SFE,  1499,      1,  PRES, 0,  1.00000
    TIME,  1.0000    
    NSUBST,       1
    OUTPR,NSOL  ,1
    OUTPR,RSOL  ,1
    OUTPR,ESOL  ,1
    OUTPR,VENG  ,1

OpenFOAM format The mesh in OpenFOAM is stored in a 'polyMesh' directory in 5 different files as described below:

OpenFOAM mesh data files in PolyMesh

  • boundary: name of boundary patches, the startFace is the index into the face list of the first face in the patch and nFaces is the number of faces in the patch.
  • face: element numbers inside the boundary patches. In the case of boundaries, the connected cell is the 'owner' and the 'neighbour' is assigned the label '-1'.
  • neighbour: a list of neighbour cell labels. Each face is therefore assigned an 'owner' cell and 'neighbour' cell so that the connectivity across a given face can be described by the owner and neighbour cell labels.
  • owner: a list of owner cell labels, the index of entry relating directly to the index of the face, so that the first entry in the list is the owner label for face 0, the second entry is the owner label for face 1 ... The 'owner' file contains an entry for nCells which defines how many cells are in their domain.
  • nodes: node number and X, Y, Z coordinate

Example of mesh for a square block

OpenFOAM mesh format-1

OpenFOAM mesh format-2

ANSYS FLUENT format - cell topology identifier:
  • Node:
    (10 (zone-id first-index last-index type ND)(
    x1 y1 z1
    x2 y2 z2
    xn yn zn
    If 'zone-id' = 0, it provides the total number of nodes in the grid. In such a case: 'first-index' = 1, 'last-index' = total number of nodes in hexadecimal, 'type' is meaningless, 'ND' = dimensionality of the grid. There will be no X-, Y-, Z-coordinates following the statement and the parentheses for the coordinates will be omitted. For example, (10 (0 1 2bd 99 2)). Note hexadecimal system has base value of 16 (analogous to base value of 10 in decimal system) and digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. In decimal systems 358 = 3x10x10 + 5x10 + 8. In hexadecimal system, 2bd = 2x16x16 + 11x16 + 13 = 701.In MS-Excel HEX2DEC function can be used to convert a hexadecimal number into any other base. e.g. HEX2DEC("2bd") = 701. Note, hexadecimal number is represented as string even though it represents a number, due to presence of text character.
  • Periodic Shadow Faces: 18
  • Cells: 12
    element-typedescription nodes/cellfaces/cell
    0mixed --
  • Faces: 13
    • interior: 2
    • wall: 3
    • pressure-inlet, inlet-vent, intake-fan: 4
    • pressure-outlet, exhaust-fan, outlet-vent: 5
    • symmetry: 7
    • periodic-shadow: 8
    • pressure-far-field: 9
    • velocity-inlet: 10
    • periodic: 12
    • fan, porous-jump, radiator: 14
    • mass-flow-inlet: 20
    • interface: 24
    • parent (hanging node): 31
    • outflow: 36
    • axis: 37
  • Face Tree: 59
  • Cell Tree: 58
  • Interface Face Parents: 61
Example of a quad mesh with no periodic boundary and hanging nodes:

Quad mesh with no periodic boundary and hanging nodes

(0 "Grid:")
(0 "Dimensions:")
(2 2)
(12 (0 1 3 0)   )
(13 (0 1 a 0)   )
(10 (0 1 8 0 2) )
(12 (7 1 3 1 3) )
(13 (2 1 2 2 2) (
1 2 1 2
3 4 2 3))
(13 (3 3 5 3 2) (
5 1 1 0
1 3 2 0
3 6 3 0))
(13 (4 6 8 3 2) (
7 4 3 0
4 2 2 0
2 8 1 0))
(13 (5 9 9 a 2) (
8 5 1 0))
(13 (6 a a 24 2)(
6 7 3 0))
(10 (1 1 8 1 2) (
1.0000e+00 0.0000e+00
1.0000e+00 1.0000e+00
2.0000e+00 0.0000e+00
2.0000e+00 1.0000e+00
0.0000e+00 0.0000e+00
3.0000e+00 0.0000e+00
3.0000e+00 1.0000e+00
0.0000e+00 1.0000e+00))

Definition of zones: cell and face zones

(0 "Zone Sections")
(39 (11 fluid FLUID)())
(39 (12 interior int_GEOM)())
(39 (13 interface INTERFACE_A1)())
(39 (14 interface INTERFACE_A2)())
(39 (15 velocity-inlet INLET)())
(39 (16 wall WALL_BLWR_CASING)())
(39 (17 outlet-vent OUTLET)()) 

STAR-CCM+ format - cell topology identifier for STAR-CD CCM format is described below. The format *.sim used by latest version of STAR-CCM+ from Siemens is proprietary and no description is available in public domain.
  • 1: Point (FLUENT: 10)
  • 2: Line
  • 3: Shell
  • 4: Shell with midside vertices
  • 11: Hexahedron
  • 12: Prism
  • 13: Tetrahedron
  • 14: Pyramid
  • 21: Hexahedron with midside vertices
  • 22: Prism with midside vertices
  • 23: Tetrahedron with midside vertices
  • 24: Pyramid with midside vertices
  • 28: Line with 1 extra node
  • 29: Line with 2 extra nodes
  • 255: Polyhedron

COMSOL format: The mesh file format contains a section with mesh points coordinates, followed by sections with mesh element information, divided into separate subsections for each mesh element type. A COMSOL mesh contains elements for all space dimension levels. For example, a tetrahedral mesh consists of domain (tetrahedra), boundary (triangles), edge, and vertex elements. Furthermore, each element has an index to the geometric entity it belongs to. If a mesh file is incomplete—for example, if it only contains tetrahedrons - the "Mesh Import" operation automatically generates the missing element data.
STL format
solid part0
  facet normal n1 n2 n3
    outer loop
      vertex x1 y1 z1
      vertex x2 y2 z2
      vertex x3 y3 z3
  facet normal ...
endsolid part0

solid part1
Contact us
Disclaimers and Policies

The content on CFDyna.com is being constantly refined and improvised with on-the-job experience, testing, and training. Examples might be simplified to improve insight into the physics and basic understanding. Linked pages, articles, references, and examples are constantly reviewed to reduce errors, but we cannot warrant full correctness of all content.