---
title: "Case-writing scripts: case_gen, compressible and site_abl"
url: "https://tryreynolds.com/docs/toolbox/case-writing"
description: "Reference for the scripts that write an OpenFOAM case onto an existing mesh: case_gen for incompressible flow, compressible for transonic and supersonic flow, and site_abl for an atmospheric inlet, with every option and the output they print."
---

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

Toolbox

# Toolbox: writing a case

Reference for the scripts that write an OpenFOAM case onto an existing mesh: case_gen for incompressible flow, compressible for transonic and supersonic flow, and site_abl for an atmospheric inlet, with every option and the output they print.

These write `0/`, `constant/` and `system/` for a mesh that already exists, with everything sized to that mesh. They build no geometry.

## case_gen.py

Writes an incompressible case for `simpleFoam` or `pimpleFoam`. From the mesh it reads the patch names and types, the cell count, the bounding box and smallest cell, and each patch's area, centre and normal. From those it works out which way the inlet flows, the hydraulic diameter the Reynolds number is on, and whether this is a body in open flow or a passage, which sets the free-stream turbulence. Every patch gets a role and a `boundaryField` entry in every field the turbulence model reads.

Give it a speed, a Reynolds number and a length and it solves for the viscosity. Give it `--nu` and it prints the Reynolds number that implies.

| Option | Default | What it does |
|---|---|---|
| `case` |  | A case directory that already holds constant/polyMesh. |
| `--dry-run` |  | Say what would be written; write nothing. |
| `--force` |  | Write over 0/ and the dictionaries if they are there. |
| `--speed SPEED` | `1.0` | Free-stream or inlet speed, m/s. |
| `--reynolds REYNOLDS` |  | Reynolds number; nu follows (default 100). |
| `--nu NU` |  | Kinematic viscosity m2/s; Re follows. |
| `--length LENGTH` |  | Characteristic length for Re. Default: the hydraulic diameter of the inlet, measured off the mesh. |
| `--direction DIRECTION` |  | Which way the inlet flows: x, y, z, -x, -y, -z. Default: the inlet patch's own normal, pointed into the domain. With --periodic, the drive (default from A toward B); write --direction=-x, since a bare -x reads as a flag. |
| `--turbulence MODEL` | `auto` | auto: laminar below Re 2300, kOmegaSST above. kOmegaSSTLM adds the Langtry-Menter transition equations, which is what a blade or an aerofoil below Re ~ 5e5 needs; assume it turbulent from the leading edge and the lift comes out low however fine the mesh. The LES subgrid models (Smagorinsky, SpalartAllmarasDDES, SpalartAllmarasDES, SpalartAllmarasIDDES, WALE, dynamicKEqn, kEqn, kOmegaSSTDDES, kOmegaSSTDES, kOmegaSSTIDDES, sigma) and DNS switch the case to resolved numerics and need --study transient; auto never picks one, because which eddies a mesh resolves is not something a Reynolds number knows. |
| `--les-delta DELTA` |  | LES filter width. Default cubeRootVol (IDDESDelta for an IDDES model, which refuses anything else). vanDriest damps it to zero at the wall, which is what a wall-resolved run wants and cubeRootVol does not do. |
| `--average-from AVERAGE_FROM` |  | LES/DNS: when fieldAverage starts, in seconds. Default half of --end-time, which is a guess; spectra.py decides when the flow actually settled. |
| `--turbulent-intensity TURBULENT_INTENSITY` |  | Free-stream turbulence intensity. Default 0.001 for a body in open flow, 0.05 inside a passage. |
| `--viscosity-ratio VISCOSITY_RATIO` |  | Target free-stream nu_t/nu; omega follows from it (a body in open flow, default 10). --mixing-length overrides. |
| `--mixing-length MIXING_LENGTH` |  | Turbulent mixing length in metres; overrides the viscosity ratio. |
| `--tracer NAME` |  | Carry a passive tracer of this name (smoke, a pollutant): a 0/NAME field, a scalarTransport function object, and the scheme and solver entries it needs. Needs --source. |
| `--schmidt SCHMIDT` |  | Turbulent Schmidt number for the tracer; alphaDt = 1/Sc_t. Left out, OpenFOAM's own default of 1 applies; no value is written here that was not read from a source. |
| `--external` |  | Treat this as a body in open flow even when the mesh does not say so (it says so when a wall patch is not part of the domain's own bounding box). |
| `--study {mesh,steady,transient}` | `steady` | Which dictionaries to write: mesh only, steady or transient. |
| `--iterations ITERATIONS` | `1000` | Steady: how many. |
| `--end-time END_TIME` | `1.0` | Transient: seconds. |
| `--delta-t DELTA_T` |  | Transient: a fixed step, which turns adjustTimeStep off. |
| `--courant COURANT` | `0.9` | Transient: target max Courant. |
| `--writes WRITES` | `50` | How many times to write. |
| `--purge PURGE` |  | Keep only the last N time directories (0 keeps all). Default: 3 for a steady run (the answer is latestTime), 0 for a transient one (its time series may be the deliverable). |
| `--inlet INLET` |  | Patches the flow enters through. Default: a patch named inlet. |
| `--outlet OUTLET` |  | Patches the flow leaves through. Default: a patch named outlet. |
| `--wall WALL` |  | No-slip walls. |
| `--slip SLIP` |  | Free-slip walls. |
| `--symmetry SYMMETRY` |  | Symmetry planes. |
| `--belt BELT` |  | Walls that translate with the stream; a moving ground. |
| `--spin SPIN` |  | A wall that rotates: name:radius[:axis], e.g. wheel:0.15:z. omega is the road speed over the radius. |
| `--source SOURCE` |  | A patch the --tracer is released from, at a value of 1. Repeatable. The patch keeps whatever role it has in every other field; a vent is still a wall to U. |
| `--body BODY_PATCH` | `body` | The patch forces are taken on, when there is one (default 'body'). A patch by that name gets a forceCoeffs function object. |
| `--dp` |  | Add the two surfaceFieldValue objects a pressure drop is: area-averaged p on the first inlet and the first outlet at every iteration, into postProcessing/pInlet/ and pOutlet/. score.py reads them as dp = p_inlet - p_outlet. |
| `--periodic PERIODIC` |  | A,B: couple two patches as a cyclic pair and drive the cell at the bulk velocity --speed through A, along --direction (default A toward B), with meanVelocityForce; score.py reports dp per period. |
| `--periodic-kind {auto,cyclic,cyclicAMI}` | `auto` | auto: cyclic when the pair's face counts match, else cyclicAMI. |
| `--yplus` |  | Add a yPlus function object: min, max and mean y+ per wall patch at every write, into postProcessing/yPlus/. |
| `--area {frontal,wetted}` | `frontal` | Which area of the body, measured off the mesh as meshed, forceCoeffs divides by (3D; default frontal). |
| `--not-mirror NOT_MIRROR` |  | A symmetry patch where the body ends rather than is mirrored; a double-body waterline. Otherwise a symmetry plane that cuts the body halves its areas and its forces. |

```bash
python3 /work/.toolbox/case_gen.py . --speed 1 --reynolds 10 --length 0.04
python3 /work/.toolbox/case_gen.py car --external --body car --belt road --spin wheel:0.15:z
python3 /work/.toolbox/case_gen.py channel --study transient --end-time 5 --turbulence WALE --les-delta vanDriest --average-from 2
python3 /work/.toolbox/case_gen.py cell --periodic west,east --speed 0.1 --length 0.0032
python3 /work/.toolbox/case_gen.py site --tracer smoke --source vent --schmidt 0.7
```

The first of those, on a plane duct:

```
study      steady   solver simpleFoam
flow       U = 1 m/s, L = 0.04 m, nu = 0.004 m2/s, Re = 10   (nu = U*L/Re)
turbulence laminar   (Re = 10 is below 2300)
mesh       1,000 cells, 0.1 x 0.02 x 0.002 m   (2D, one cell thick)
patches    inlet (20, inlet), outlet (20, outlet), walls (100, wall), frontAndBack (2000, empty)
           length 0.04 m from --length
wrote 7 files into duct
next: simpleFoam -case duct   (the mesh is already there)
```

What it changes together:

- **LES and DNS.** Naming a subgrid model writes the `LES` block and moves convection to `Gauss LUST grad(U)` and time to `CrankNicolson 0.9`, and says so. `--study steady` with one is refused. On a one-cell-thick mesh it says the case is a 2D run with an extra viscosity. See [turbulence models](https://tryreynolds.com/docs/guides/turbulence-models.md).
- **A tracer.** `--tracer` adds OpenFOAM's `scalarTransport` function object with the field, the scheme, the linear solver and the source it needs. The field is dimensionless, so a real concentration is one multiplication afterwards. There is no buoyancy in it.
- **A periodic cell.** `--periodic A,B` couples two patches and drives the cell at a fixed flow rate, so the pressure drop per period is what comes out.
- **Wall spacing.** It measures the first-cell height per wall and prints the y+ a flat-plate correlation predicts. That is a prediction; [wall.py](https://tryreynolds.com/docs/toolbox/measuring.md) reads the measured one.
- **Parametric use.** `--dp` writes the two pressure samplers and `--yplus` the y+ object that [score.py](https://tryreynolds.com/docs/toolbox/studies.md) reads.

It writes no `dynamicMeshDict`, no `pointDisplacement` and no `MRFProperties`; a moving or rotating case starts from a [template](https://tryreynolds.com/docs/toolbox/templates.md) or a tutorial. Run it before `site_abl.py --write`, since this writes `0/` wholesale. **Needs** the standard library; OpenFOAM's `checkMesh` for the smallest cell, and without it the average cell stands in and it says so. **Exit code** 0.

## compressible.py

The same job for a compressible run. Pressure is absolute, in pascals; temperature is a field; `constant/thermophysicalProperties` replaces `transportProperties`; and the viscosity, density and Reynolds number are outputs. It writes for `rhoSimpleFoam` and `rhoCentralFoam` in full, and everything for HiSA except `fvSchemes` and `fvSolution`, which are copied from HiSA's own ONERA M6 example by the `cp` commands it prints.

| Option | Default | What it does |
|---|---|---|
| `case` |  | A case directory that already holds constant/polyMesh. |
| `--dry-run` |  | Say what would be written; write nothing. |
| `--force` |  | Write over 0/ and the dictionaries if they are there. |
| `--mach MACH` |  | Freestream Mach number. Either this or --speed. |
| `--speed SPEED` |  | Freestream speed in m/s; the Mach number follows from the speed of sound at --t. |
| `--p PRESSURE` | `101325.0` | Static pressure, Pa ABSOLUTE. |
| `--t TEMPERATURE` | `288.15` | Static temperature, K. |
| `--mu MU` |  | Dynamic viscosity at --t, Pa s. Refits the Sutherland As so the law reproduces it, rather than contradicting it. |
| `--length LENGTH` |  | Characteristic length for the reported Re. Default: measured off the inlet patch. |
| `--direction DIRECTION` |  | Which way the inlet flows: x, y, z, -x, -y, -z. Default: the inlet patch's own normal, pointed into the domain. |
| `--up UP` |  | Which axis lift is measured towards: x, y or z. Default z, or y on a mesh one cell thick in z. There is no measuring this. |
| `--turbulence {auto,laminar,kOmegaSST,kEpsilon,SpalartAllmaras}` | `auto` | auto: laminar below Re 2300, SpalartAllmaras above. |
| `--turbulent-intensity TURBULENT_INTENSITY` |  | Free-stream turbulence intensity. Default 0.001 for a body in open flow, 0.05 inside a passage. |
| `--viscosity-ratio VISCOSITY_RATIO` |  | Target free-stream nu_t/nu; omega follows from it. |
| `--external` |  | Treat this as a body in open flow even when the mesh does not say so. |
| `--solver {auto,rhoSimpleFoam,rhoCentralFoam,hisa}` | `auto` | Auto prefers hisa where it is actually installed, then picks by regime. A named solver is written whether or not it is on this machine, and the summary says which. |
| `--study {steady,transient}` | `steady` | Steady or transient. |
| `--iterations ITERATIONS` | `2000` | Steady or pseudo-time: how many. |
| `--end-time END_TIME` | `1.0` | Transient: seconds. |
| `--delta-t DELTA_T` |  | Transient: a fixed step, which turns adjustTimeStep off. |
| `--courant COURANT` | `0.5` | Transient: target max ACOUSTIC Courant number (default 0.5); the step is Co*h/(\|U\| + a), not Co*h/\|U\|. |
| `--writes WRITES` | `40` | How many times to write. |
| `--purge PURGE` |  | Keep only the last N time directories (0 keeps all). |
| `--inlet INLET` |  | Patches the flow enters through. |
| `--outlet OUTLET` |  | Patches the flow leaves through. |
| `--farfield FARFIELD` |  | Patches standing in for unbounded fluid. Flow crosses them both ways, so they are neither inlet nor outlet; and nothing guesses the role from the name. |
| `--wall WALL` |  | No-slip walls. |
| `--slip SLIP` |  | Free-slip walls. |
| `--symmetry SYMMETRY` |  | Symmetry planes. |
| `--body BODY_PATCH` | `body` | The patch forces are taken on. |
| `--aref AREF` |  | Reference area for forceCoeffs, m2. Measured on a plane case; on a 3D case nothing can see a planform area, so without this only `forces` (newtons) is written. |
| `--lref LREF` |  | Reference length for forceCoeffs, m. Default: the characteristic length. |

```bash
python3 /work/.toolbox/compressible.py . --mach 0.84 --t 255.6 --p 80459
python3 /work/.toolbox/compressible.py . --mach 0.8395 --t 255.6 --p 80459 --solver hisa --farfield farfield --body wing --aref 0.7532 --lref 0.64607
python3 /work/.toolbox/compressible.py . --mach 2.0 --study transient --end-time 0.01
```

Trimmed, at Mach 0.84 with `--solver rhoCentralFoam`:

```
regime     transonic: M = 0.8400 from U = 285.85 m/s and a = 340.297 m/s
state      p = 101325 Pa (absolute), T = 288.15 K
           rho = 1.22498 kg/m3, mu = 1.78938e-05 Pa s, nu = 1.46074e-05 m2/s
stagnation T0 = 328.814 K, p0 = 160833 Pa, rho0 = 1.70395 kg/m3, q = 50046.5 Pa
outlet     waveTransmissive
time step  1.129e-06 s = Co 0.5 x 0.001414 m (the average cell) / (U + a) = 626.1 m/s
           the acoustic speed is in the denominator, not just U -- 2.19x smaller a step than the incompressible rule gives
```

It ends with a table of every constant it wrote and where each came from. `--solver auto` picks HiSA where it is installed, `rhoCentralFoam` at Mach 1 and above or for a transient study, and `rhoSimpleFoam` otherwise. Nothing guesses a far-field patch or a 3D reference area: `--farfield` and `--aref` are yours. See [compressible setup](https://tryreynolds.com/docs/guides/compressible-setup.md). **Needs** the standard library. **Exit code** 0.

## site_abl.py

An atmospheric boundary layer inlet, from a `site.json` or from numbers. It writes the dictionary that OpenFOAM's `atmBoundaryLayerInletVelocity`, `atmBoundaryLayerInletK`, `atmBoundaryLayerInletEpsilon` and `atmBoundaryLayerInletOmega` conditions read, puts the inlet entry into whichever of `0/U`, `0/k`, `0/epsilon` and `0/omega` exist, and puts roughness wall functions on a named ground patch.

| Option | Default | What it does |
|---|---|---|
| `case` |  | The case directory, for --write. |
| `--site SITE` |  | A site.json from `openreynolds site`. |
| `--statistic {mean,p50,p90,p98,max}` | `mean` | Which of the site file's sector speeds to use as Uref. |
| `--sector SECTOR` |  | Use the sector nearest this bearing instead of the prevailing one. |
| `--uref UREF` |  | Reference speed, m/s. |
| `--zref ZREF` |  | Reference height, m. |
| `--z0 Z0` |  | Roughness length, m. |
| `--roughness ROUGHNESS` |  | A Davenport class instead of --z0: chaotic, closed, open, rough, roughly-open, sea, smooth, very-rough. |
| `--d D` | `0.0` | Displacement height, m. |
| `--flow-dir FLOW_DIR` |  | Streamwise direction, e.g. '1 0 0'. |
| `--z-dir Z_DIR` |  | Ground-normal direction, default '0 0 1'. |
| `--kappa KAPPA` | `0.41` | Default 0.41. |
| `--cmu CMU` | `0.09` | Default 0.09. |
| `--c1 C1` | `0.0` | Default 0.0. |
| `--c2 C2` | `1.0` | Default 1.0. |
| `--inlet INLET` | `inlet` | The inlet patch name. |
| `--ground GROUND` |  | A ground patch to put the roughness wall functions on. |
| `--top TOP` |  | Highest height in the table and figure. Default 20 x Zref. |
| `--write` |  | Edit the case. |
| `--print` |  | Print the dictionary entries and change nothing. |
| `--table TABLE` |  | Write the profile as CSV. |
| `--figure FIGURE` |  | Write the profile as a PNG. |
| `--json` |  | One JSON object. |

```bash
python3 /work/.toolbox/site_abl.py --uref 8 --zref 10 --roughness rough --print
python3 /work/.toolbox/site_abl.py case --site site.json --z0 0.25 --sector 240 --ground terrain --write
```

```
z0       0.25         --roughness rough (scattered obstacles 10 heights apart; low orchards, bushy scrub)
  u* = 0.8832 m/s, from kappa 0.41 x Uref 8 / ln((10 + 0.25)/0.25)
  z in every expression is height above the inlet patch's own lowest point, not above z = 0
      z [m]   U [m/s]          k     epsilon      omega
      0.050    0.3928     2.6004       5.602     23.936
      1.841    4.5756     2.6004     0.80369      3.434
     10.000    8.0000     2.6004     0.16396    0.70057
```

Roughness has no default: without `--z0` or `--roughness` it refuses and prints the Davenport table, because the roughness length moves every profile and the weather reanalysis cannot supply it. **Needs** the standard library, matplotlib for `--figure`. **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.
