---
title: "Geometry and CAD scripts: looking at surfaces, tessellating STEP, auditing patch sets"
url: "https://tryreynolds.com/docs/toolbox/geometry"
description: "Reference for the geometry scripts in the Reynolds toolbox: geometry_view, cad_convert, cad_audit, cad_export, domain_probe, surfaces, b123d_api and site_stl, 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/geometry. It lives at https://tryreynolds.com/docs/toolbox/geometry.md, and
[tryreynolds.com/llms.txt](https://tryreynolds.com/llms.txt) indexes every one of them.

Toolbox

# Toolbox: geometry and CAD

Reference for the geometry scripts in the Reynolds toolbox: geometry_view, cad_convert, cad_audit, cad_export, domain_probe, surfaces, b123d_api and site_stl, with every option, what each prints and what it needs.

These scripts work on surfaces and solids, before any mesh exists. They draw and measure a surface, turn a CAD file into triangles at a tessellation you choose, check that a set of patch files closes as one surface, and say which side of it is fluid. For the route as a whole, read [geometry formats](https://tryreynolds.com/docs/guides/geometry-formats.md) and [geometry and meshing](https://tryreynolds.com/docs/geometry-and-meshing.md).

## geometry_view.py

Draws a surface from four fixed views with every facet edge and the bounding box ticks on, and prints open edges, non-manifold edges, connected bodies, extents and the face-area range. It reads `.stl`, `.obj`, `.ply`, `.vtk` and `.step` or `.iges` (tessellated coarsely for the picture and thrown away afterwards). It gives no verdict, because whether forty open edges matter depends on where they are.

| Option | Default | What it does |
|---|---|---|
| `paths` | required | Surface files, or a directory. |
| `--out OUT` |  | Defaults to ./renders. |
| `--per-part` |  | Also one picture per surface. |
| `--check` |  | Numbers only, draw nothing. |

```bash
python3 /work/.toolbox/geometry_view.py constant/triSurface --per-part
python3 /work/.toolbox/geometry_view.py body.stl --check       # the numbers, no picture
```

**Needs** numpy and pyvista; gmsh as well for a STEP or IGES file. **Exit code** 0.

## cad_convert.py

Converts STEP, IGES and BREP to STL through the OpenCASCADE kernel inside gmsh, so a circle is read as a circle and a declared unit as a unit. You choose the facet size; nothing is defaulted, because a tessellation that is too coarse becomes the geometry and reaches the force coefficients without looking wrong. The report gives the unit it read, the entity counts, the tightest curve and the chord error that implies, the facet count, the longest edge, and the gmsh calls in order.

A rule that works: `--clmax` about half the surface cell size, with `--curvature 20` so a tight radius drives its own facets. The chord error for a chord L on a radius R is about L squared over 8R.

| Option | Default | What it does |
|---|---|---|
| `path` | required | A .step, .stp, .iges or .igs file. |
| `--clmax CLMAX` |  | Max facet edge, metres. |
| `--clmin CLMIN` |  | Min facet edge, metres. |
| `--unit UNIT` |  | What the numbers mean, if the file does not say. |
| `--curvature CURVATURE` | `20.0` | Elements per full circle, so a tight radius drives its own facet size. |
| `--tolerance TOLERANCE` | `1e-08` | Geometry tolerance handed to the kernel. |
| `--out OUT` |  | STL to write (default: alongside). |
| `--binary` |  | Write binary STL. |
| `--json` |  | The report as JSON as well. |

```bash
python3 /work/.toolbox/cad_convert.py part.step --clmax 0.002 --out constant/triSurface/part.stl
python3 /work/.toolbox/cad_convert.py part.brep --clmax 0.002 --unit mm
```

It refuses in two places, both of them where a wrong answer looks right: no `--clmax`, and a file that declares no unit with no `--unit`. Every `.brep` is in the second group, because OpenCASCADE writes raw coordinates and leaves the unit with whatever wrote them.

**Needs** gmsh. **Exit code** 0, or 2 on a refusal.

## cad_export.py

The exporter the CAD desk uses, called from Python rather than from a shell because its argument is a live build123d shape. It tessellates the shape once and writes one STL per named patch, so the seams between patches weld. The common alternative, one `export_stl` per patch, meshes each patch separately and tears the seam along every patch boundary, which a mesher reads as a leak.

| Argument | Default | What it does |
|---|---|---|
| `shape` | required | The solid whose surface becomes the mesh boundary. |
| `patches` | required | Patch name to faces. One patch may be `...`, meaning every face the others did not name. |
| `directory` (or `out_dir`) | `constant/triSurface` | Where the STLs and `patches.json` go. |
| `tolerance` | required | Largest distance a facet may sit from the surface, in metres. About a quarter of the finest surface cell. |
| `angular_tolerance` | 0.1 | Largest angle between adjacent facets, rad. |
| `location_in_mesh` | none | The fluid-side point, written into `patches.json`. |
| `binary` | `True` | Binary STL. |
| `clean` | `True` | Remove STLs in the directory that this call did not write. |
| `quiet` | `False` | Do not print the report. |

```python
import sys; sys.path.insert(0, "/work/.toolbox")
from cad_export import export_patches

export_patches(fluid, {"inlet": ins, "outlet": outs, "walls": ...}, tolerance=2.5e-4)
```

It asserts every face into exactly one patch before a triangle exists, and a face that does not belong to the shape is refused with its distance to the nearest one that does. It prints triangles and area per patch, the extent in metres, and the open-edge and winding counts of the union. **Needs** build123d and numpy. It raises `Refused` rather than guessing.

## cad_audit.py

Measures an exported patch set as one surface. Each file of a patch set is open on its own (an inlet has a rim, a wall has the holes the inlet was cut out of), so a per-file closure check fails on every correct export. This asks the question of the union: is it closed, manifold and wound one way, is every face in exactly one patch, are there self-intersections or degenerate triangles, and is it in metres.

| Option | Default | What it does |
|---|---|---|
| `directory` | required | A `<case>`/constant/triSurface with patches.json in it. |
| `--json` |  | The report as JSON. |
| `--surface-check` |  | Also run OpenFOAM's surfaceCheck on each patch file. |
| `--derive` |  | With no patches.json, read the directory as its own patch set; one STL per patch, its stem the name. What is derived cannot say whether a file on disk was meant to be exported, and `manifest` says so rather than implying it. |

```bash
python3 /work/.toolbox/cad_audit.py constant/triSurface
python3 /work/.toolbox/cad_audit.py constant/triSurface --derive     # no patches.json
```

Findings print as `closure`, `manifold`, `normals`, `coverage`, `self_intersection`, `degenerate`, `scale` and, with `--surface-check`, `surface_check`. Above the triangle limit the expensive ones come back `skipped` with the reason, never `ok`. **Needs** numpy; OpenFOAM only for `--surface-check`. **Exit code** 0 whatever it finds, 2 when there is no `patches.json` and no `--derive`.

## domain_probe.py

Answers two questions about a closed surface with no mesh: is this point inside what the surfaces enclose, and how wide is the domain there. The first is the check `locationInMesh` needs, since a point on the wrong side still meshes and still passes `checkMesh`. The second is the diameter of the largest sphere that fits inside and holds the point, which is not twice the distance to the nearest wall. The same field between two shells is the minimum wall thickness.

| Option | Default | What it does |
|---|---|---|
| `directory` | required | A triSurface directory: one STL per patch. |
| `--point X Y Z` |  | The locationInMesh point to validate. |
| `--width-samples WIDTH_SAMPLES` | `120` | Interior points the width field is measured at. |
| `--suggest` |  | Propose a point at the deepest part of the domain. |
| `--json` |  | The envelope as JSON too. |
| `--derive` |  | Accepted and already the behaviour: this reads patches.json when it is there and the directory's own STLs when it is not. It takes the flag so one command shape drives both audits; `cad_audit.py` needs it, and a caller should not have to remember which. |

```bash
python3 /work/.toolbox/domain_probe.py constant/triSurface --point 0.1 0 0
python3 /work/.toolbox/domain_probe.py constant/triSurface --suggest
```

A point within 1e-6 of the diagonal from a triangle is reported as on the surface, with the distance measured, rather than resolved to a side. **Needs** numpy. **Exit code** 0, or 2 when the directory cannot be read.

## surfaces.py

The triangle machinery the CAD scripts share. It is a library with no command line, imported rather than run. `Index` is a spatial index over an (n, 3, 3) triangle array whose queries may return too many candidates and never too few; `weld()` rounds coordinates to one rule; `tri_tri_intersect()` counts touching as meeting; `ray_hits()` casts again by itself when a ray runs along a shared edge; `signed_distance()` is negative inside. **Needs** numpy.

## b123d_api.py

Writes `b123d_api.md`, a curated index of what build123d offers, grouped by purpose: operations, primitives, geometry helpers, import and export, the selectors face tagging is written in, and the boolean operators. The agent searches that page with `grep` rather than guessing at names. Exact signatures are left to `help()` against the installed library, which cannot go stale.

| Option | Default | What it does |
|---|---|---|
| `--out OUT` | beside the script | Where to write the index. |
| `--check` |  | Only report entries that no longer resolve. |
| `--stdout` |  | Print instead of writing. |

```bash
grep -n "extrude" /work/.toolbox/b123d_api.md
python3 /work/.toolbox/b123d_api.py --check
```

**Needs** build123d. **Exit code** 0; 2 when a curated name no longer resolves or the library is missing.

## site_stl.py

Turns the building footprints and elevation grid in a `site.json` into STL for wind work. The `site.json` comes from `openreynolds site --lat ... --lon ...`, which runs on your own machine because the workspace has no network. Footprints are extruded to closed solids with the roof and floor ear-clipped, so an L-shaped terrace comes out as its own shape. Terrain is two triangles per cell in the same east-north-metres frame.

| Option | Default | What it does |
|---|---|---|
| `--site SITE` | required | A site.json from `openreynolds site`. |
| `--buildings BUILDINGS` |  | Where to write the footprints. |
| `--terrain TERRAIN` |  | Where to write the elevation grid. |
| `--default-height DEFAULT_HEIGHT` | `0.0` | Height for footprints with no height tag. 0 leaves them out. |
| `--min-area MIN_AREA` | `0.0` | Leave out footprints smaller than this, in m^2. |
| `--clip CLIP` | `0.0` | Keep only what is within this many metres of the origin. |
| `--sink-buildings` |  | Set each base from the terrain under its centroid. |
| `--per-building-solid` |  | One named STL solid per footprint instead of one for all. |
| `--json` |  | One JSON object. |

```bash
python3 /work/.toolbox/site_stl.py --site site.json --buildings b.stl --clip 300 --min-area 50
python3 /work/.toolbox/site_stl.py --site site.json --buildings b.stl --terrain t.stl --sink-buildings
```

What it leaves out it counts: a footprint with neither a height nor a storey count is skipped unless `--default-height` says otherwise, and a ring that ear clipping cannot close is named by its OSM id. **Needs** the standard library only. **Exit code** 0, or 2 when the inputs are refused. See [wind comfort](https://tryreynolds.com/docs/guides/wind-comfort.md).

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