---
title: "Meshing scripts: looking at a mesh, grading it, layers, cfMesh, refinement"
url: "https://tryreynolds.com/docs/toolbox/meshing"
description: "Reference for the meshing scripts in the Reynolds toolbox: mesh_look, mesh_digest, mesh_quality, cells_estimate, layer_report, cfmesh, patch_entries, amr and reference_area, with every option, what each prints and what it needs."
---

**[Reynolds](https://tryreynolds.com)** is agentic CFD, built by
**[InviscidAI](https://inviscidai.com)** and backed by Y Combinator, Winter 2026 batch.
The agent is open source under the MIT licence at
[github.com/InviscidAI/OpenReynolds](https://github.com/InviscidAI/OpenReynolds).
Using it requires no OpenFOAM knowledge.

This is the agent-readable Markdown twin of https://tryreynolds.com/docs/toolbox/meshing. It lives at https://tryreynolds.com/docs/toolbox/meshing.md, and
[tryreynolds.com/llms.txt](https://tryreynolds.com/llms.txt) indexes every one of them.

Toolbox

# Toolbox: meshing

Reference for the meshing scripts in the Reynolds toolbox: mesh_look, mesh_digest, mesh_quality, cells_estimate, layer_report, cfmesh, patch_entries, amr and reference_area, with every option, what each prints and what it needs.

These scripts predict, inspect and measure meshes. Most of them read `constant/polyMesh` directly, so they work on a mesh from any tool and need no solve. [Meshing engines](https://tryreynolds.com/docs/guides/meshing-engines.md) covers which mesher to use.

## mesh_look.py

One picture and one table for a mesh, straight from `constant/polyMesh`. The picture has one colour per patch (a 3D mesh also gets a cut on each axis). The table has cells, faces, points, the bounding box, whether the case is one cell thick, and every patch with its type, face count, area, centre and mean unit normal, which is what tells an inlet from an outlet without guessing from where it sits. Cell zones and face zones are listed with their counts, because a frozen rotor or a sliding interface is named against one.

| Option | Default | What it does |
|---|---|---|
| `case` | `.` | The case directory. |
| `--out OUT` |  | Where the picture goes; a relative path is relative to where you run this from, not to the case (default `<case>`/look.png). The report prints the absolute path written. |
| `--json JSON` |  | Also write the machine-readable report here (relative to where you run this from). |
| `--no-check` |  | Skip checkMesh. |
| `--region REGION` |  | Read constant/`<region>`/polyMesh instead (a CHT case has one mesh per region; this looks at one of them). |
| `--views VIEWS` |  | Also write three composite pictures of the mesh from several sides into this directory (2D: overview, cells, detail; 3D: iso, ortho, cuts); relative to where you run this from, like --out. The JSON lists them under `views`. |

```bash
python3 /work/.toolbox/mesh_look.py . --views looks/
python3 /work/.toolbox/mesh_look.py . --region fluid --no-check
```

On a 1,000-cell plane duct, with `--no-check`, it prints:

```
  1,000 cells, 0 faces, 2,142 points  (one cell thick: a plane case)
  bounds 0.1 x 0.02 x 0.002 m   x 0..0.1   y 0..0.02   z 0..0.002   [100 x 20 x 2 mm]
  patches:
    inlet         patch              20 faces  area 4e-05 m2  at (0, 0.01, 0.001)  faces (-1.00, +0.00, +0.00)
    outlet        patch              20 faces  area 4e-05 m2  at (0.1, 0.01, 0.001)  faces (+1.00, +0.00, +0.00)
    walls         wall              100 faces  area 0.0004 m2  at (0.05, 0.01, 0.001)
    frontAndBack  empty           2,000 faces  area 0.004 m2  at (0.05, 0.01, 0.001)
  zones: none -- constant/polyMesh has no cellZones or faceZones
```

The total face count comes from `checkMesh`, so it reads 0 there. **Needs** numpy and pyvista; OpenFOAM for the `checkMesh` verdict.

## mesh_digest.py

Turns `checkMesh` output into a metric table and a patch table, with no thresholds applied.

| Option | Default | What it does |
|---|---|---|
| `log` | required | checkMesh log, or - for stdin. |

```bash
checkMesh 2>&1 | python3 /work/.toolbox/mesh_digest.py -
```

Keep the log as `log.checkMesh` in the case: `preflight.py`, `explain.py`, `grid.py` and `recover.py` all read it. **Needs** the standard library only.

## mesh_quality.py

Shows the cells that failed, rather than the number they failed on. A maximum skewness of 11 in four cells on a trailing edge is a snapping artefact; the same 11 in a band across the domain is a mesh to throw away, and every summary shows the two identically. For each failing or marginal metric it gives how many cells, what fraction of the mesh, the box they span, the patches they sit on, the worst few with coordinates, and a picture of them inside the mesh.

The cells come from a `cellSet` or `faceSet` that `checkMesh -writeSets vtk` left behind, or from skewness and non-orthogonality recomputed with OpenFOAM's own formulae. Which of the two was used is printed. Aspect ratio is read from `checkMesh` and never recomputed.

### report

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case directory. |
| `--region REGION` |  | One mesh region of a multi-region case. |
| `--log LOG` |  | A checkMesh log, instead of the case's own log.checkMesh. |
| `--skewness SKEWNESS` |  | The skewness a cell is selected at (preflight's warn is 4). |
| `--non-ortho NON_ORTHO` |  | The non-orthogonality in degrees a cell is selected at (preflight's warn is 70). |
| `--worst WORST` | `5` | How many cells per metric are located in full. |
| `--png PATH` |  | The bad-cell picture. |
| `--out DIR` |  | A directory for mesh_quality.png and mesh_quality.json. |
| `--max-draw MAX_DRAW` | `20000` | Cells drawn before the picture is truncated. |
| `--json [PATH]` |  | The same facts as JSON, on stdout or to a file. |

### formats

Which mesh formats can be converted to and from OpenFOAM on this instance, probed by looking for each converter. Fluent, gmsh, VTK, I-DEAS unv, CFX4 and STAR-CCM have converters in the distribution. CGNS has none in either direction.

| Option | Default | What it does |
|---|---|---|
| `--json [PATH]` |  | The same facts as JSON. |

### convert

Runs one converter, or reports the binary it looked for and did not find.

| Option | Default | What it does |
|---|---|---|
| `source` | required | The mesh file, or the case for --from openfoam. |
| `--from {cfx4,cgns,fluent,gmsh,openfoam,star-ccm,unv,vtk}` | required | The format to convert from. |
| `--to {cfx4,cgns,fluent,gmsh,openfoam,star-ccm,unv,vtk}` | required | The format to convert to. |
| `--case CASE` |  | The case the converted mesh is written into. |
| `--json [PATH]` |  | The same facts as JSON. |

```bash
python3 /work/.toolbox/mesh_quality.py report . --png bad_cells.png
python3 /work/.toolbox/mesh_quality.py convert tunnel.msh --from fluent --to openfoam --case .
```

**Needs** numpy, and pyvista for the picture; OpenFOAM for conversions. **Exit code** 0.

## cells_estimate.py

Predicts the cell count from the surface area and the `blockMeshDict` and `snappyHexMeshDict`, in seconds and before the build. It is an order-of-magnitude number, within about a factor of two for ordinary geometry, which is enough to catch a refinement level that implies hundreds of millions of cells.

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case directory. |
| `--stl STL` |  | Defaults to every STL found. |

```bash
python3 /work/.toolbox/cells_estimate.py .
```

**Needs** numpy.

## layer_report.py

Measures how much of each wall carries a prism layer, from the mesh rather than from the mesher's own summary. It computes the first-cell height at every patch face and compares it with a reference wall spacing. snappyHexMesh prints a layer table and cfMesh prints nothing comparable, so this is the number the two can be put side by side on.

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case whose mesh is measured. |
| `--patch PATCH` |  | Patch to measure; repeatable (default: every wall patch). |
| `--ref REF` |  | The same wall meshed with no layer request; its spacing sets the threshold. |
| `--wall-spacing WALL_SPACING` |  | Reference wall spacing in metres, when the no-layer mesh is not around. |
| `--cell CELL` |  | Bucket side for the reference lookup (default: the reference face spacing). |
| `--json` |  | The same facts as JSON. |

```bash
python3 /work/.toolbox/layer_report.py . --patch hull --ref ../hull-nolayers
```

```
# patch 'walls' (wall)
  faces                 100
  COVERAGE              0.0 %  (0 / 100 faces)
    measured as         half this mesh's own median (no reference given)
  first-cell height     min 1.0000   mean 1.0000   max 1.0000 mm
  note: with no --ref and no --wall-spacing the threshold comes from this mesh, so it can only see a split that is somewhere near half
```

That note matters: a wall that is wholly layered and one that is wholly bare look the same without `--ref` or `--wall-spacing`. It reads ascii meshes only. **Needs** numpy. **Exit code** 0.

## cfmesh.py

The route to cfMesh, whose `cartesianMesh` extrudes a layer sheet and optimises afterwards, so it does not lose layers as it goes. The script exists because several mistakes with cfMesh end in exit code 0.

### where

Probes for the four meshers, `generateBoundaryLayers`, and the three surface and mesh tools the routes run.

| Option | Default | What it does |
|---|---|---|
| `--json` |  | The same facts as JSON. |

### box

Writes a body and its domain box as one closed multi-solid STL, which is what cfMesh needs instead of `locationInMesh`. It refuses a body that pokes through the box and names the faces it merely touches, because those are cut planes.

| Option | Default | What it does |
|---|---|---|
| `body` | required | The body STL. |
| `--out OUT` | required | The closed multi-solid STL to write. |
| `--name NAME` |  | Solid name for a binary STL, which has none. |
| `--box X0 X1 Y0 Y1 Z0 Z1` |  | The domain box corners, instead of the multiples below. |
| `--upstream UPSTREAM` | `5.0` | Box extent ahead of the body, in body lengths. |
| `--downstream DOWNSTREAM` | `10.0` | Box extent behind the body, in body lengths. |
| `--side SIDE` | `5.0` | Box extent to each side, above and below, in body lengths. |
| `--angle ANGLE` | `45.0` | Feature angle for surfaceFeatureEdges, in the printed route. |
| `--force` |  | Write over files that are already there. |

### case

Writes `system/meshDict`, keeping its keys and its `surfaceFile` consistent. Against a `.ftr` from `surfaceFeatureEdges` the key has to be the regex `"hull_.*"`; against a raw STL it has to be the literal `hull`. The wrong one matches nothing and the mesh comes out with no refinement and no layers.

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case directory. |
| `--surface SURFACE` | required | The closed surface, .stl or .ftr. |
| `--mesher {cartesianMesh,pMesh}` | `cartesianMesh` | Which binary the printed route runs; both read this same system/meshDict, and pMesh makes the mesh polyhedral. |
| `--max-cell MAX_CELL` | required | `maxCellSize`, metres. |
| `--wall WALL` |  | The solid name the layers go on. |
| `--wall-cell WALL_CELL` |  | Cell size asked for on the wall, metres. |
| `--layers LAYERS` | `0` | Number of boundary layers; at least two, since one is quietly dropped. |
| `--ratio RATIO` | `1.2` | Layer thickness ratio. |
| `--symmetry SYMMETRY` |  | A box face that is a cut plane, typed `symmetry`; repeatable. |
| `--patch NAME[:TYPE]` |  | A solid to keep as its own patch, TYPE defaulting to `patch`. Anything not named here, by --wall or by --symmetry is merged into one --default-name patch; repeatable. |
| `--default-name DEFAULT_NAME` | `farField` | The one patch every unnamed solid is merged into. |
| `--default-type DEFAULT_TYPE` | `patch` | Its type. |
| `--angle ANGLE` | `45.0` | Feature angle for surfaceFeatureEdges, in the printed route. |
| `--force` |  | Write over files that are already there. |

### prepare

Makes the two edits that let cfMesh read an existing snappyHexMesh mesh, in the order that works.

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case directory. |
| `--write` |  | Make the two edits. |

### check

Reads back what the mesh got: whether the wall kept its name, whether its face size is the one asked for, and the layer coverage.

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case directory. |
| `--wall WALL` |  | The wall patch to check. |
| `--log LOG` |  | The cartesianMesh log, read for keys that matched no patch. |
| `--ref REF` |  | The same wall meshed with no layer request; makes the coverage number stand on its own. |
| `--wall-spacing WALL_SPACING` |  | A reference wall spacing in metres, when no such mesh is around. |
| `--json` |  | The same facts as JSON. |

```bash
python3 /work/.toolbox/cfmesh.py box hull.stl --out hull_box.stl
python3 /work/.toolbox/cfmesh.py case . --surface hull_box.stl --wall hull --max-cell 0.15 --layers 5 --patch xMin:patch
cartesianMesh > log.cartesianMesh
python3 /work/.toolbox/cfmesh.py check . --wall hull --log log.cartesianMesh
```

cfMesh sizes the layer stack from the local cell, so there is no y+ to ask for, only one to measure afterwards. Name every box face you need: whatever is not named is merged into one patch, and a mesh with all six box faces in `farField` has no inlet. **Needs** numpy; cfMesh itself to mesh. **Exit code** 0, or 2 on a refusal.

## patch_entries.py

Writes the patch lists in a snappyHexMesh case from what is on disk. A snappy case names every surface in `geometry`, `features`, `refinementSurfaces` and `surfaceFeatureExtractDict`, and one left out of a list is still meshed and takes the wrong boundary condition. This rewrites the marked regions in place, repeatably, reading `constant/triSurface` and `patches.json`.

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case holding constant/triSurface/. |
| `--insert DICT` |  | A dictionary whose marked regions to rewrite in place; repeatable. Relative paths are read under the case. |
| `--print [SECTION]` |  | Print one section's fragment; repeatable. One of geometry, features, refinementSurfaces, extract, or omit the value for all of them. |
| `--level LEVEL` | `0 0` | The (min max) surface refinement level written into refinementSurfaces (default: '0 0', the background size). A re-run rewrites it, so pass it again rather than editing the dictionary and re-inserting. |
| `--feature-level FEATURE_LEVEL` | `0` | Refinement level on the feature edges. |
| `--included-angle INCLUDED_ANGLE` | `150` | surfaceFeatureExtract's includedAngle. |
| `--json` |  | The same facts as JSON. |

```bash
python3 /work/.toolbox/patch_entries.py . --insert system/snappyHexMeshDict --insert system/surfaceFeatureExtractDict --level "2 2"
```

**Needs** numpy (through `preflight.py`). **Exit code** 0, or 2 on a section or file it cannot use.

## amr.py

Writes and checks `constant/dynamicMeshDict` for a mesh that refines while it runs (`dynamicRefineFvMesh`). OpenFOAM reads nine of its entries with no default, so leaving one out stops the run; this writes every one of them and refuses the ranges that are fatal at the first update, plus a `--lower` at or above `--upper`, which OpenFOAM accepts and which refines nothing.

### write

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case directory. |
| `--field FIELD` | required | The volScalarField the criterion reads (alpha.water, mag(U), ...). |
| `--lower LOWER` | required | lowerRefineLevel. |
| `--upper UPPER` | required | upperRefineLevel. |
| `--max-cells MAX_CELLS` | required | maxCells: the only bound on what refinement costs. |
| `--max-refinement MAX_REFINEMENT` | `2` | Levels on any one cell. |
| `--refine-interval REFINE_INTERVAL` | `1` | Time steps between updates. |
| `--n-buffer-layers N_BUFFER_LAYERS` | `1` | Cells of refinement past the marked band. |
| `--unrefine UNREFINE` |  | unrefineLevel; omitted, the mesh only ever grows. |
| `--flux FLUX:VELOCITY` |  | A correctFluxes pair, repeatable; VELOCITY may be none or NaN. |
| `--no-dump-level` |  | Do not write cellLevel as a field. |
| `--force` |  | Write over files that are already there. |

### check

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case directory. |
| `--json` |  | The same facts as JSON. |

```bash
python3 /work/.toolbox/amr.py write . --field alpha.water --lower 0.01 --upper 0.99 --max-cells 200000 --flux phi:U
python3 /work/.toolbox/amr.py check .
```

```
WARN    amr
  measured  maxCells 200000 against 1000 cells now (200.0x)
  means     the bound on what refinement can cost, as a multiple of the mesh it starts from
OK      amr
  measured  application simpleFoam constructs a dynamicFvMesh
```

Only hexahedra are refined; other cells are protected. Nothing in the toolbox has measured what refinement buys, which takes a refined run against a uniformly fine one. **Needs** numpy. **Exit code** 0, or 2 on a refused write.

## reference_area.py

How much of the body a mesh holds, and the area its forces divide by. A symmetry patch that cuts the body halves the meshed area, and the report names the plane and the points it was read from. Frontal area is the rasterised silhouette of the patch as meshed. For each direction it prints whether a mirror doubles the component or cancels it.

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case directory. |
| `--body BODY` | required | The patch forces are taken on; repeatable. |
| `--drag-dir DRAG_DIR DRAG_DIR DRAG_DIR` | `1.0 0.0 0.0` | `forceCoeffs` drag direction, for the frontal area and the mirror factor. |
| `--lift-dir LIFT_DIR LIFT_DIR LIFT_DIR` | `0.0 1.0 0.0` | forceCoeffs' liftDir, for the mirror factor of the lift. |
| `--pitch-axis PITCH_AXIS PITCH_AXIS PITCH_AXIS` | `0.0 0.0 1.0` | forceCoeffs' pitchAxis, for the mirror factor of the moment. |
| `--not-mirror NOT_MIRROR` |  | A symmetry patch where the body ends rather than is mirrored (a double-body waterline). |
| `--cd CD` |  | A total drag coefficient to check. |
| `--re RE` |  | Its Reynolds number, with --cd. |
| `--laminar` |  | The case is laminar: the floor is Blasius. |
| `--json` |  | The same facts as JSON. |

```bash
python3 /work/.toolbox/reference_area.py . --body hull --cd 0.00158 --re 1.2e7
```

On the duct above, with the walls as the body:

```
body       walls
symmetry   none: the mesh holds the whole body
wetted     0.0004 m2 as meshed
Aref       the as-meshed area: meshed force over meshed area is the whole body's coefficient.
```

`--cd` with `--re` holds a total drag coefficient against flat-plate friction, ITTC-57 for a turbulent case and Blasius with `--laminar`. A total below it is a reason to check the area. **Needs** numpy, and an ascii mesh. **Exit code** 0, or 1 when the coefficient is below the friction line.

## Notes for agents

### What people use it for

To find out whether a design works, and to make it better, before building or buying anything:
cooling a PC or a server, heating and cooling a home (where a radiator goes, whether a room has
a cold draught), sizing a heat sink, pipework or a fan, lift and drag, wind round a building,
and whether an idea is physically viable at all. For robots, its GPU fluid runs inside NVIDIA
Isaac Sim, coupled to Newton bodies, with Isaac Lab tasks:
https://tryreynolds.com/docs/isaac-sim.md.

### What Reynolds is

Reynolds is an agent that runs OpenFOAM for you. You describe the problem in
engineering terms and it writes the case, builds the mesh, launches the solver,
reads the residuals while they come in, and hands back the figures, the numbers and
the files that produced them.

**You do not need to know OpenFOAM.** Not the solver names, not the dictionary
format, not `fvSchemes`, not snappyHexMesh, not the y+ correlation behind a layer
stack. Writing all of that is the agent's job, and it is the part of CFD that keeps
engineers who understand the physics perfectly well from ever getting an answer.
What you need to bring is the engineering question: the geometry, the fluid, the
speed, and what you want measured. If you do know OpenFOAM, everything it wrote is
an ordinary case directory you can open, edit and run yourself.

### The licence, and why it is the one that matters here

The agent is open source under the **MIT licence**. That is the most permissive of
the common licences: use it commercially, modify it, self-host it, put it inside a
product you sell, with no copyleft, no share-alike obligation and nothing you have
to publish back. Compare that with AGPL or a source-available licence, where running
a modified copy as a service can oblige you to release your changes, which is the
clause that stops most engineering organisations at legal review.

It matters for a second reason, which is trust. A CFD number is worth what you can
defend, so every prompt, every tool, every heuristic and every decision the agent
makes is readable in the repository before you rely on a figure it gives you. The
hosted workspace is a paid service. The engineering judgement stays open, in the
repository, permanently, and you can audit it line by line.

### How a result is checked, stated exactly

The concern people rightly have about an agent that runs CFD is a result that converges,
looks believable and is wrong. Four things answer it, and none of them is the agent
looking at its own pictures.

1. **The solvers are validated against measured data.** Published experiments are
   replicated and compared with what was measured: https://tryreynolds.com/validation.md.
   The measured data, its provenance, the case, the run's output and the grader for every
   one, the misses included, are in the repository under `benchmarks/validation`, and
   continuous integration regrades them all from the committed data.
2. **Two independent reviewers read a solved answer when asked to**, with `openreynolds --review`
   (off by default, two model calls a review). Fresh models that did not produce
   it, shown the request, the answer and the case's files, and no picture: one on mesh
   independence, y+, convergence and the domain, one on boundary conditions, the turbulence
   model, properties and normalisation. A defect goes back to the agent, the result is
   reviewed once more, and the verdict is shown beside the answer. Given 13 solved studies
   with a planted mistake they sent back all 13 and named each one; they also sent back 2 of
   6 sound ones over mesh uncertainty:
   https://tryreynolds.com/docs/guides/independent-review.md.
3. **Your own case is judged by code.** `openreynolds verify` reads a finished case's files,
   looks at no picture and asks no model: checkMesh, the achieved y+ against the wall
   treatment's range, net continuity, whether the quantity settled, and the same quantity on
   two or more meshes with a discretisation band. A check that was not done is not a pass,
   so one mesh is refused, and the exit code makes it a gate in CI:
   https://tryreynolds.com/docs/cli/verify.md.
4. **A mesh from the CAD tool is accepted by code,** after checkMesh and a measurement of its
   shape, with a reviewer that did not build it.

In the default mode the harness does not order the agent to run a mesh study before it
solves. Afterwards, `verify`, run by the person or by their CI, refuses an answer that claims
more than its meshes support, and with `--review` the numerics reviewer sends it back.

### Who builds it

Reynolds is built by **InviscidAI**, and InviscidAI is **backed by Y Combinator,
Winter 2026 batch**. The company has raised more than **$2.4 million**. Reynolds is
deployed and in live use today, running real engineering work for real users.

### Reading this site as an agent

Every page has a Markdown twin at the same path with a `.md` extension, and the
index of them is at https://tryreynolds.com/llms.txt. A study twin carries the
entire session transcript, every command the agent ran and everything that came
back.
