LEONSIM Workbench demo

Meshing

The meshes: compared in 2D, still being built in 3D

The C-grids behind every 2D code comparison row, drawn from the files both codes ran on, and the first 3D Ahmed meshes: the snappyHexMesh reference and our own LeonMesh, with its checkMesh failures listed.

7 min read

Status. In 2D, code comparison passed: the meshes below are the ones of the code comparison rows. In 3D, preview, unvalidated: the meshes are work in progress: the snappyHexMesh mesh is the reference mesh OpenFOAM ran on; LeonMesh, our own mesher, does not pass checkMesh yet, is not faster than snappyHexMesh yet, and no solver result in this blog uses it.

Every comparison on the scoreboard depends on the mesh before it depends on the solver. Here are the meshes themselves: the 2D grids of the code comparison cases, regenerated from the same code or read from the same files that LeonSim and OpenFOAM ran on, and the 3D meshes of the Ahmed body, where meshing is the open problem.

2D: body-fitted C-grids

All four 2D rows of the scoreboard use a single-block, body-fitted C-grid. The grid lines follow the wall, the first cell is thin enough to resolve the boundary layer, and the cut in the wake closes onto itself so wake faces are ordinary internal faces. This is what the production solver runs on, and it is the same mesh the OpenFOAM leg of each comparison reads: in these cases the mesh is never a difference between the two codes.

NACA 0012, the OpenFOAM comparison

Four views of the NACA 0012 C-grid: the whole domain out to 200 chords, the section with its wake, the nose with cells packed against the wall, and the trailing edge with the wake cut.
The grid of the region-by-region comparison: 139,776 cells, 320 faces per side, first cell 2 µm, growth ratio 1.1, outer boundary 200 chords away. The whole-domain view draws every 12th and 6th line; the nose and trailing-edge views draw every cell edge.

NACA 4412, NASA’s grid

Four views of NASA's NACA 4412 C-grid: whole domain 100 chords out, the section, the nose and the trailing edge with the wake.
NASA’s own 449×129 C-grid (57,344 cells), the middle level of the separation case; the other two levels are 225×65 and 897×257. This is a TMR file, not our generator, so its wake and far field are laid out differently from ours.

NASA TMR flat plate and bump

The NASA TMR flat-plate grid (whole domain and leading edge) and the bump-in-a-channel grid (whole box and a close-up of the bump), with cell edges drawn.
The grids of the plate and bump verification at one level each (137×97 and 177×81). The tables there run four levels, up to 545×385 and 705×321.

Laminar Re 500

The laminar NACA 0012 C-grid, whole domain 10 chords out and a close-up of the section.
The middle grid of the laminar case: 9,408 cells (64 faces per side, 32 wake cells), first cell 0.001 chord, domain 10 chords. The two others have 2,976 and 34,944 cells.

The earlier tutorial posts (6 to 10) used a Cartesian cut-cell mesh instead; it is not drawn here because it is no longer the production path.

3D: the Ahmed body, half model

3D is where the mesh is still the hard part. The Ahmed body (25° slant) on four stilts over a floor needs layers on a body with sharp edges, thin stilts and a concave stilt-underside junction. Both meshes below are the half model (symmetry plane at y = 0), with four prism layers on the body, stilts and the floor around the body, first layer 1 mm, growth 1.2. Both are drawn from their polyMesh files, on a CPU.

The reference: snappyHexMesh

Slices through the snappyHexMesh Ahmed mesh: the symmetry plane around the body, a section across the body, close-ups of the rear, the slant-base corner and the nose, and a slice through the stilts.
snappyHexMesh, 358,593 cells (OpenFOAM v1912 on the sandbox; the mesh the OpenFOAM run of record used differs by 0.2 %). The slice through the stilts shows the two stilts as gaps; on the 30 mm cylinders the reference holds about one prism layer (18.6 % of the requested thickness).

LeonMesh: our own, work in progress

The same slices through the LeonMesh Ahmed mesh. Layers follow the slant, the base and the nose; the stilt slice shows layers around the stilts.
LeonMesh, 442,502 cells, the same views. The symmetry plane, the section across the body and the slant look regular. The failures are localised at two places: the stilt-underside junction and the nose ridge where the two fillets meet.
checkMesh, OpenFOAM v1912, all geometry and topology checkssnappyHexMeshLeonMesh
cells358,593442,502
topologyOKOK
negative volumes00
failed checks36
non-orthogonality, max / average60.1 / 6.090.5 / 6.9 (11 faces above 70°)
max skewness3.162,417 (13 faces)
faces failing the face-tet check0214
wrongly oriented face pyramids024
cells with small determinant / low-weight faces98 / 120 / 7
concave cells11,62514,119
meshing time65 s on 4 cores (80 s with set-up)95 to 104 s on 1 NumPy core

The three failures of the snappyHexMesh reference are the soft kind (small determinants, concave cells, low interpolation weights) that OpenFOAM runs through. LeonMesh’s extra failures are not: a skewness of 2,417 and 214 bad face decompositions are the kind of defect that breaks a solver, and the skewed faces are the same faces as the bad-decomposition ones. 10 of the 13 are at the nose ridge, 3 at the stilt-underside junction.

The body wall mesh of the snappyHexMesh Ahmed half model from above and from below, coloured by region, with the two stilt feet on the underside.
The body wall mesh of the snappyHexMesh reference from above (left) and from below (right), coloured by wall region, with the two stilts of the half model.
The body wall mesh of the LeonMesh Ahmed half model from above and from below, coloured by region, with the two stilt feet on the underside.
The body wall mesh of LeonMesh, same views. The wall mesh is finer than the reference’s because the surface is refined before the layers are built; the stilt feet, on the right, are where the defects of the stilt-underside junction are.

Where the fast mesher stands

LeonMesh is our attempt at a mesher that is much faster than snappyHexMesh, runs on the GPU and writes an OpenFOAM polyMesh, so that the result can be checked against OpenFOAM on the same mesh. It is a draft pull request (#118), off by default. What exists is a NumPy reference on the CPU: an octree with polyhedral hanging-node faces, snapping with a quality gate and feature edges, an offset surface and prism layers, and a port of checkMesh. What it does not have yet:

  • A clean checkMesh. Six failed checks against the reference’s three, all from the two spots named above. Two obvious fixes (shrinking the failing columns, tapering the layers near edges) made it worse and are kept off.
  • Speed. About 95 to 104 s on one CPU core against 65 s on four cores for snappyHexMesh. The two slow NumPy steps, the snap (about 60 s) and the surface refinement (27 s), are the ones to port to GPU kernels. The GPU speed is a target only; nothing has been timed on a GPU.
  • The acceptance gates that count. OpenFOAM’s forces on a LeonMesh mesh against the same case on the reference mesh (the Ahmed case) and a second geometry (the NACA 0012 slab) have not run: they need a mesh that passes checkMesh first, and a small amount of compute (about $0.7 for the whole round).

So there is no claim here about accuracy, only about shape. If the two spots are fixed, the next evidence is a checkMesh no worse than the reference, and then the OpenFOAM force comparison on both meshes. Until both exist, snappyHexMesh remains the Ahmed reference.

Numbers: docs/cgrid-gpu/fast-mesher.md (section 8) and the logs log.checkMesh.snappy-sandbox-v1912 and log.checkMesh of the LeonMesh case in the project files. Reproduce the 2D figures with python3 website/renders/mesh_plots.py and the 3D ones with python3 website/renders/mesh3d_plots.py; the LeonMesh polyMesh comes from python3 tools/leonmesh_ahmed.py --out CASE --checkmesh on the branch of PR #118.