---
title: "Tutorial: a mesh convergence study with an error bar"
url: "https://tryreynolds.com/docs/tutorials/mesh-convergence"
description: "Ask the agent for the same quantity on three meshes, turn the three numbers into an observed order, an extrapolated value and an error bar with grid.py, and read what an order below the scheme's own means."
---

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

Start here

# Run a mesh convergence study

Ask the agent for the same quantity on three meshes, turn the three numbers into an observed order, an extrapolated value and an error bar with grid.py, and read what an order below the scheme's own means.

One mesh gives a number. Three give a number and an error bar, and tell you whether the discretisation is behaving. You will do the arithmetic on a laptop first, with values from a published worked example, then ask the agent for the same thing on a case of your own.

**You will learn** to read the observed order, the extrapolated value and the Grid Convergence Index, and to recognise the three shapes a convergence study can take.

**You need** Python with numpy for the first half and a Reynolds session for the second. Ten minutes plus the solves.

## The arithmetic

A scheme of order `p` on cells of size `h` leaves an error of about `C h^p`. Two unknowns and a third value need three grids. With refinement ratio `r` between successive grids:

`p = ln((f3 - f2) / (f2 - f1)) / ln(r)`

and the Richardson value is `f1 + (f1 - f2) / (r^p - 1)`. The Grid Convergence Index is that correction as a percentage with a safety factor, and it is the error bar to quote.

## Steps

### Run the worked example

```bash
git clone https://github.com/InviscidAI/OpenReynolds && cd OpenReynolds
python -m pip install -e ".[toolbox]"
python openreynolds/toolbox/grid.py --spacing 1:0.97050 --spacing 2:0.96854 --spacing 4:0.96178
```

The three numbers are NASA Glenn's published example, at spacings of 1, 2 and 4. Output, run here:

```
## refinement
  h=2 -> h=1: r = 2.0000, the value changes by +0.00196
  h=4 -> h=2: r = 2.0000, the value changes by +0.00676

## three-grid estimate on h=1, h=2, h=4
  convergence           monotone
  observed order p      1.786170
  order used            1.786170 (observed from the three grids)
  formal order          2
  extrapolated value    0.97130033 (Richardson, h -> 0)
  GCI on the fine grid   0.103083%
  GCI on the coarse pair 0.356249%
  asymptotic ratio      1.0020 (Roache's check; 1 is in the asymptotic range)
  safety factor Fs      1.25 (the default for this many grids)

## the answer
  value = 0.9705 +/- 0.001000 on h=1
```

The order of 1.786170, the extrapolated 0.97130 and the index of 0.103083% are the published ones.

### Ask for three meshes

In any study with a steady answer, for example [the heated pipe](https://tryreynolds.com/docs/tutorials/heated-pipe.md):

```
Repeat this case on three meshes: the current one, and two that double the cells in each direction. Keep the grading the same shape. Give me the quantity on each, then run grid.py on the three and report the observed order, the extrapolated value and the error bar. Say whether the order is close to the scheme's own.
```

The agent runs the meshes one at a time, because each is a job. A 2D case grows four times per doubling in cells and more in time.

### Do it yourself on the finished cases

```bash
python3 /work/.toolbox/grid.py coarse medium fine --quantity Cd --dim auto --tail 200 --png gci.png
```

`--quantity` names a column in `postProcessing/*.dat`, `--tail` averages the last rows, and `--dim auto` reads whether the mesh is 2D from its `empty` patches. With numbers you already have, use `--grid CELLS:VALUE` instead, three times, with `--dim 2` or `--dim 3`.

## Read the result

Three patterns cover most studies. Each row is a recorded result from this repository.

| Pattern | Example | What it means |
|---|---|---|
| Order near the scheme's | Hartmann channel, errors falling by 4.0 per doubling on 100 x 20, 100 x 40 and 100 x 80 | the scheme is in its asymptotic range |
| Order too low | the sliding interface in a Couette annulus, observed 0.79, where the same mesh without the interface gave 1.93 | something other than the spacing sets the error |
| Error at first order on a step | the porous slab's pressure drop, -2.5% at 80 cells across and -0.82% at 160 | the smeared interface is one cell wide and is the error |

![Error against cell size for the sliding-interface annulus, with guides at first and second order. The control, in blue, follows second order. The sliding interface, in red, follows first order, and refining the cells at a fixed time step does not move it.](https://tryreynolds.com/assets/ami-convergence-CuBFg1bS.png)

Error against cell size for the sliding-interface annulus, with guides at first and second order. The control, in blue, follows second order. The sliding interface, in red, follows first order, and refining the cells at a fixed time step does not move it.

An order **above** the scheme's, or one that jumps about, means the meshes are not a family. Cells that were not scaled together, or a y+ that crosses a wall-function limit between them, are the usual causes.

## Check it

- **The three are a family.** The same grading and shape, and ratios stated in `h`, not in cell count.
- **The time step moved too**, on a transient case. Holding the time step while halving the cells measures a mixture. Keep the Courant number instead.
- **The quantity settled on each mesh.** A number that is still drifting on the coarse mesh gives a fictitious order.

## Try next

1. Feed `grid.py` the same three values with a factor of two wrong on one, and see what it says.
2. Run two grids only and read how the safety factor changes.
3. Use [the parametric sweep](https://tryreynolds.com/docs/tutorials/parametric-sweep.md) to put an error bar on a design variable.

## When it goes wrong

### The order comes out as a negative number or an error

The three values are not monotone, so the arithmetic has no answer. Report it as that; a fourth mesh settles whether the middle one is the odd one out.

### Two different refinement ratios

Use `--grid` with the cell counts and `--dim` and the script reports a ratio per pair. The textbook single-ratio formula turns unequal ratios into a 20% error in the exponent.

### The value stops moving and then starts again

Wall treatment. On a turbulent wall the first cell crosses from the sublayer into the log layer as you refine, and the model answers a different question on each side. Read `wall.py` on every mesh.

## Next

[Resume a study and take it with you](https://tryreynolds.com/docs/tutorials/resume-and-export.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.
