---
title: "Geometry and meshing: from a CAD file to a mesh that checks out"
url: "https://tryreynolds.com/docs/geometry-and-meshing"
description: "How geometry gets onto the instance and becomes a mesh: STEP and STL import, parametric CAD in Python, gmsh primitives and booleans, the mesh tool that builds and measures and revises, blockMesh, snappyHexMesh and cfMesh, the 2D recipe, patch naming, layers, and every check applied to the result."
---

**[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/geometry-and-meshing. It lives at https://tryreynolds.com/docs/geometry-and-meshing.md, and
[tryreynolds.com/llms.txt](https://tryreynolds.com/llms.txt) indexes every one of them.

# Geometry and meshing

Meshing is where a CFD study is won or lost, so it gets the most instrumentation: a geometry looked at before it is meshed, a mesh rendered and measured rather than assumed, and a named reason for every patch.

## Four ways to get a geometry

- **A file you have.** STEP, IGES, BREP, STL, OBJ, PLY or VTK. Push it up and it is read as it is. A STEP or a BREP is read as real geometry through an OpenCASCADE kernel, with exact circles, declared units and real trimmed surfaces, which is a much better starting point than a tessellation of the same part.
- **A shape described in words.** Parametric CAD in readable Python is on the instance, so a solid can be a short script: a cylinder minus a cylinder is a tube, and the result exports as STEP, which any CAD program opens.
- **Primitives and booleans.** The geometry kernel and the mesher are the same tool here, so boxes, cylinders, spheres, cones, fillets and boolean cuts can be built and meshed in one pass, with no intermediate file at all.
- **A real site.** For wind work, building footprints and a terrain elevation grid become STL directly, with footprints extruded into closed solids so an L-shaped or notched terrace comes out as its own shape rather than as a fan from a centroid outside it.

## Looking at it first

Before anything is meshed, the surface is drawn and measured: four fixed views with every facet edge and the bounding-box ticks on, plus open edges, non-manifold edges, connected bodies, extents and the face-area range. No verdicts are attached, because whether forty open edges matter depends entirely on where they are, and the agent is better placed to decide that with the picture in front of it.

```
python3 /work/.toolbox/geometry_view.py body.stl         # four views, edges, extents, open edges
python3 /work/.toolbox/cad_convert.py part.step --clmax 2e-3 --unit mm
python3 /work/.toolbox/domain_probe.py . --point 0.1 0 0  # is this point inside, and how wide is it there
```

The converter refuses in exactly two places, both of them where a wrong answer looks right: with no maximum element size given, and on a file that declares no unit with no unit supplied. Everything else it reports: the unit it read, the entity counts, the tightest curve it found and the chord error that implies, the facet count and longest edge that came out, and the calls it made in order.

## From a CAD part to a fluid domain

A customer part is usually the solid, and what a flow solver needs is the space around or inside it. That conversion is a recipe rather than a button: import and repair, defeature the features that are smaller than the physics, pick among the solids, boolean, subtract and cap the openings, tag the faces that will become patches, export. The toolbox carries it as a page the agent reads and works through a cell at a time in a live kernel, so a B-rep costs a minute once rather than once per question asked of it.

Two checks make that safe. The patch set is audited as one surface rather than as a directory of files: the union of every named patch is what gets asked whether it is closed, manifold and wound one way, because each individual file is an open surface and asking the question of it separately answers nothing. And the point that tells the mesher which side is fluid is tested rather than assumed, along with how wide the domain is at that point, because a point on the wrong side still meshes and still passes a mesh check.

## The mesh tool

The agent has a tool that takes a shape described in words and returns an OpenFOAM mesh of it on the same machine. Behind that tool is a second agent working on the same instance: it builds the mesh, renders it, measures it against what was asked for, and revises until `checkMesh` passes and the shape measures up. One bash block per step, with a verified finish.

That division is deliberate. Meshing is iterative and visual, and it generates a lot of output that the main study does not need to carry. What comes back is a mesh and a measurement of it, not a transcript of forty attempts. [The mesh editor](https://tryreynolds.com/docs/mesh-editor.md) is how you put your own hands on the result in the browser: pick faces, name them, draw a domain, move and scale, and hand it back with what you meant by it.

## The meshers

Four, and each is right for something different.

| Mesher | What it is good at |
|---|---|
| `blockMesh` | Anything that is genuinely a block or maps to one: a channel, a duct, an O-grid around a cylinder. Exact control, perfect hexahedra, no surprises. The structured meshes behind several published studies are these. |
| gmsh | Body-fitted meshing straight off geometry, with the same kernel that built it. A primitive cut out of a flow box and meshed with tetrahedra needs no STL and no snapping step at all. It also meshes a planar face in quads and extrudes it one cell thick, which is how a 2D case is built here. |
| `snappyHexMesh` | The standard route for a complicated surface in a hex background mesh, with refinement regions and a layer stage. OpenFOAM's own, and the right answer for a hull or a vehicle. |
| cfMesh | Prebuilt in the image, needs no build and no exports. Its layer stage extrudes a sheet and optimises afterwards, so nothing can un-extrude a face: on one hull wall it covered 100.0% where the other route reached 88.6% on its first iteration and eroded to 66.7% by its fiftieth. |

A gmsh mesh is converted with `gmshToFoam`, which types every patch as a plain patch, so walls are retyped afterwards. That retyping is a step the templates below all include, because a wall left as a patch is a slip wall nobody meant to ask for.

![A mesh around a staggered bundle of circular tubes, refined close to each tube wall with prism layers wrapping the surfaces and coarser cells between them](https://tryreynolds.com/assets/bundle-mesh-BfR8Qn6L.png)

A mesh around a staggered tube bundle, with layers on every tube. The mesh is rendered and measured as part of building it, not after somebody wonders whether it worked.

## Keeping a case 2D

OpenFOAM has no 2D mesh. It has a 3D mesh one cell thick with the two faces normal to the thickness typed `empty`, and the common way a 2D case turns out to be a slow thin 3D one is a mesh several cells deep, or a side face left as a wall where `empty` was meant. The recipe is baked into the templates rather than left to be rediscovered: quads recombined on the plane, extruded with exactly one element, recombined into hexahedra, and both side faces retyped.

It is worth insisting on, because a 2D case is often two orders of magnitude cheaper than the 3D one and answers the same question. Several studies on this site are 2D for that reason, and they say so.

## Naming patches from the geometry

Patch names come out of the geometry as it is built, never out of the finished mesh. A physical group per surface as it is created, or a bounding-box query against the box's own known corners: either way the inlet is the inlet because that is the face that was built as the inlet. Whatever boundary faces are left over once the known ones are accounted for become the body, named as a group rather than assumed to be one face.

On a snappy case the surface list is written from what is on disk rather than typed in four places, because a surface named in the geometry block and missing from the refinement block is a mesh that silently does not refine where it was supposed to.

## Layers and the first cell

A wall-bounded answer depends on where the first cell sits, so that gets measured from both ends. One script reports the first-cell height at every face of every patch, and how much of each wall genuinely carries a prism layer rather than how much the mesher said it inserted. Another reads back the y+ the finished run reached, face by face, against the value predicted before it started. On a generated aerofoil O-grid that comparison is how a predicted y+ of order one was found to be nothing of the kind.

The reference for the comparison is in the toolbox too: the sublayer, the log law and the crossing between them at y+ 11.0623, with the laminar branch exact and the turbulent fits carrying their scatter. [Turbulence and the wall](https://tryreynolds.com/docs/solvers-flow.md) has it.

## Checking the mesh

`checkMesh` is the first verdict, and four instruments sit around it.

| Script | What it answers |
|---|---|
| `mesh_look.py` | Is this the shape that was meant, and is the inlet the end you think it is. One PNG with a colour per patch, plus cells, bounds, patch areas and normals, and the mesh check's own verdict. |
| `mesh_digest.py` | The mesh check's output as a metric table, numbers and patch table, with no thresholds applied to them. |
| `mesh_quality.py` | The cells that failed, rather than the number they failed on. Where the bad cells are is what tells you whether to refine, repair or ignore. |
| `reference_area.py` | How much of the body this mesh holds, and the area its forces should divide by, read off the mesh whoever built it. A symmetry patch that cuts the body halves the area, and a force coefficient divided by the wrong area is wrong by exactly that factor. |

That last one is why a published drag coefficient on this site is quoted on a measured wetted area: [a submarine hull measured off its own geometry](https://tryreynolds.com/studies/suboff-submarine-hull.md) is the study where that distinction does the work.

## Refining while it runs

OpenFOAM can refine a mesh while the solve is running, driven by a field: a dictionary naming the field, the band of values that triggers refinement, the buffer layers, the maximum level and a cell ceiling. The toolbox writes that dictionary with every entry the class reads without a default, and refuses the ranges that are fatal at the first update rather than letting the run get there. It is the right tool for an interface that moves or a shock whose position you do not know in advance.

## The mesh templates

The meshing recipes ship as working scripts rather than as prose to retype. Copy one into an empty directory, edit the two numbers marked at the top, and run it: it meshes, checks and draws the result.

| Template | What it builds |
|---|---|
| `duct2d.py` | A closed planar outline meshed in quads and extruded one cell into hexahedra. The 2D recipe, with every gotcha baked in. |
| `body_in_box.py` | A primitive cut out of a flow box with a boolean and meshed body-fitted with tetrahedra. No STL and no snapping stage. The box is sized in body radii, further downstream than upstream because a wake needs more room than an approach. |
| `free_surface.py` | A tank with a water column, set as geometry rather than as a uniform field, as a complete two-phase case. |
| `rotating.py` | A bladed vessel with two cell zones and the rotation as a source term. |
| `porous.py` | A duct with a porous slab across it, its coefficients derived from a measured pressure-drop curve. |
| `thermal_stress.py` | A constrained bar, meshed and written as a stress case with the thermal term on. |
| `mhd_hartmann.py` | A channel with a field across it, its cell height chosen against the wall layer. |
| `cht_wall.py` | Two regions and the interface between them, split and checked per region. |
| `viv_cylinder.py` | An O-grid around a cylinder, written as both the bolted and the released case. |
| `evaluate_steady.py` | One round of a parametric study, taking its shape from a constants file the caller writes beside it. |

Every one of them ends in a mesh check and a drawing of the result, and all but the first two write dictionaries that are the real ones rather than stubs for the mesh tools, so the case they leave behind is meant to be solved as it stands. [Cases you can run](https://tryreynolds.com/docs/tutorials.md) lists what is known about each one's answer before its solver starts.

## Notes for agents

### 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.

### 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.
