openfoam-sim
You are driving OpenFOAM through sim-cli. This file is the index.
Detail lives in references/ — load progressively, only what the task needs.
How to load this skill
Don't read every reference up front — context is precious. Walk this list:
- Always read
references/case-setup.md before authoring any case.
- Pick a solver via
references/solver-selection.md.
- Look up the fields & dictionaries you'll need in
references/field-and-dictionary-matrix.md.
- For boundary conditions:
references/boundary-conditions.md.
- If the case has turbulence:
references/turbulence-setup.md.
- If the case is multiphase / VOF:
references/multiphase-vof.md.
- If the case has heat or buoyancy:
references/heat-transfer.md (and references/conjugate-heat-transfer.md for solid+fluid).
- For mesh generation:
references/mesh-and-blockmesh.md.
- For schemes / solvers / relaxation:
references/numerics-and-schemes.md.
- For runtime monitors / probes / forces:
references/function-objects.md.
- For parallel execution and decomposition:
references/parallel-execution.md.
- For runtime log diagnosis:
references/log-parsing-and-residuals.md.
- For post-processing (sample lines, point queries, integrals):
references/post-processing.md.
- For complete case skeletons by scenario:
references/case-recipes.md.
- When something fails:
references/error-recovery.md — decision tree + fix sequences.
sim-cli integration (one-shot mode)
Most benchmark/single-shot use is one-shot:
# 1. Write your driver script. Conventionally `solve.py`.
# The script invokes blockMesh / solver / postProcess via subprocess,
# parses the result, and writes the answer to disk.
# 2. Run via sim-cli:
uv run sim run solve.py --solver openfoam
# sim wraps the script in a RunResult (exit_code, stdout, stderr, duration,
# errors) and stores it under `.sim/runs/`. Browse with:
uv run sim logs # list runs
uv run sim logs last # full last RunResult
uv run sim logs last --field exit_code
Persistent-session mode (uv run sim serve + uv run sim connect/exec/inspect/disconnect)
is supported when sim-server is reachable, but is not required for
typical case authoring.
Work sequence (the protocol)
Before writing any OpenFOAM file, classify the case:
- Time: steady or transient?
- Compressibility: incompressible or compressible?
- Phases: single-phase, two-phase (VOF), or multi-region?
- Turbulence: laminar, RANS (k-ε / k-ω SST / SpalartAllmaras), or LES/DNS?
- Heat/buoyancy: isothermal, forced convection, or buoyancy-driven?
This classification fixes the solver family (see solver-selection.md),
the required field set (see field-and-dictionary-matrix.md), and the
turbulence boundary recipe (see turbulence-setup.md).
Then, in this order:
- Mesh (
blockMesh or snappyHexMesh); validate with checkMesh.
- Fields in
0/: one per required field; consistent patch names with the mesh.
- Properties in
constant/: transport, turbulence, thermophysical (when relevant).
- Numerics in
system/: controlDict, fvSchemes, fvSolution. Start
conservative (upwind, low CFL, tight relaxation) and upgrade after the
case is stable.
- Run the chosen solver; tail the log; check the convergence signals
(
references/log-parsing-and-residuals.md).
- Post-process to extract the requested KPI.
Validate at every layer — don't push to "run solver" before checkMesh is
clean and the field files reference patches that exist in the mesh.
Hard guardrails
These are mistakes LLMs make often. Don't.
- Don't invent dictionary keys, patch types, or solver names. Every key
in
controlDict / fvSchemes / fvSolution / transportProperties /
field files comes from a closed vocabulary. If you're not sure the key
exists, look it up rather than guess.
- Don't mix turbulence-model fields. k-ε needs
k + epsilon + nut;
k-ω SST needs k + omega + nut; Spalart-Allmaras needs nuTilda +
nut. Mixing fields across models causes solver to abort at startup.
- Don't use
p when the solver expects p_rgh. Buoyant solvers
(buoyantBoussinesqSimpleFoam, buoyantSimpleFoam, chtMultiRegionFoam)
and VOF (interFoam) want p_rgh. Pure incompressible (icoFoam,
simpleFoam, pimpleFoam) want p.
- Don't use
linear (central differencing) for alpha.water convection
in VOF. It's unbounded; alpha will blow past [0,1]. Use vanLeer
or MUSCL via the interfaceCompression family.
- Don't set relaxation factors to 1.0 in steady-state SIMPLE without
consistent yes (SIMPLEC). It's a recipe for divergence on most cases.
- Don't keep aggressive second-order convection schemes on a fragile
case. Stabilize with
upwind first, upgrade to linearUpwind once
residuals are well-behaved.
- Don't treat
checkMesh warnings as optional if the log is already
diverging. Most divergence on a fresh case is a mesh-quality issue.
- Don't assume
0/ exists. Many tutorials ship 0.orig/ and rely on
Allrun to copy it; if you skip Allrun, do it yourself: cp -r 0.orig 0.
- Don't run on more MPI ranks than
numberOfSubdomains in
decomposeParDict. They must match, or mpirun will hang or crash.
Output expected
When you finish, produce a short summary that states:
- Solver and physics family chosen
- Required fields and dictionaries authored
- Turbulence model + wall treatment (if any) + estimated inlet turbulence
- Numerical schemes used and any relaxation choices
- Convergence signal observed (
End reached? final residuals? continuity errors?)
- The requested KPI value, with units
- Any stability concerns or follow-up recommendations
For benchmark/grader contexts, this summary is implicit in the produced
/tmp/agent/result.json — you still benefit from doing the mental
checklist before submitting.
Reference index
| File |
When to read |
references/case-setup.md |
Always, first |
references/solver-selection.md |
Picking a solver / pressure convention |
references/field-and-dictionary-matrix.md |
"What files do I need?" lookup |
references/boundary-conditions.md |
Concrete BC syntax per type |
references/turbulence-setup.md |
Any turbulent case |
references/mesh-and-blockmesh.md |
Mesh generation, blockMesh, checkMesh |
references/numerics-and-schemes.md |
fvSchemes, fvSolution, relaxation, algorithm controls |
references/multiphase-vof.md |
Two-phase / VOF cases |
references/heat-transfer.md |
Buoyant or compressible-thermal |
references/conjugate-heat-transfer.md |
Multi-region fluid + solid |
references/parallel-execution.md |
decomposePar, MPI, reconstructPar |
references/log-parsing-and-residuals.md |
Diagnosing solver progress + convergence |
references/post-processing.md |
postProcess, sample, point queries |
references/function-objects.md |
Runtime monitors (probes, forces, yPlus) |
references/case-recipes.md |
Complete skeletons by scenario |
references/error-recovery.md |
Failure decision tree + fix sequences |
references/failure_patterns.md |
Catalog of historical failures (legacy) |
1---2name: openfoam-sim3description: Use when the user asks Codex, Claude Code, or another AI coding agent to run, inspect, or debug OpenFOAM cases through sim-cli. Supports case checks, solver execution, log inspection, result artifacts, replayable CFD workflows, and benchmark tasks.4---56# openfoam-sim78You are driving **OpenFOAM** through **sim-cli**. This file is the **index**.9Detail lives in `references/` — load progressively, only what the task needs.1011---1213## How to load this skill1415Don't read every reference up front — context is precious. Walk this list:16171. **Always** read `references/case-setup.md` before authoring any case.182. Pick a solver via `references/solver-selection.md`.193. Look up the fields & dictionaries you'll need in `references/field-and-dictionary-matrix.md`.204. For boundary conditions: `references/boundary-conditions.md`.215. If the case has turbulence: `references/turbulence-setup.md`.226. If the case is multiphase / VOF: `references/multiphase-vof.md`.237. If the case has heat or buoyancy: `references/heat-transfer.md` (and `references/conjugate-heat-transfer.md` for solid+fluid).248. For mesh generation: `references/mesh-and-blockmesh.md`.259. For schemes / solvers / relaxation: `references/numerics-and-schemes.md`.2610. For runtime monitors / probes / forces: `references/function-objects.md`.2711. For parallel execution and decomposition: `references/parallel-execution.md`.2812. For runtime log diagnosis: `references/log-parsing-and-residuals.md`.2913. For post-processing (sample lines, point queries, integrals): `references/post-processing.md`.3014. For complete case skeletons by scenario: `references/case-recipes.md`.3115. **When something fails**: `references/error-recovery.md` — decision tree + fix sequences.3233---3435## sim-cli integration (one-shot mode)3637Most benchmark/single-shot use is one-shot:3839```bash40# 1. Write your driver script. Conventionally `solve.py`.41# The script invokes blockMesh / solver / postProcess via subprocess,42# parses the result, and writes the answer to disk.4344# 2. Run via sim-cli:45uv run sim run solve.py --solver openfoam4647# sim wraps the script in a RunResult (exit_code, stdout, stderr, duration,48# errors) and stores it under `.sim/runs/`. Browse with:49uv run sim logs # list runs50uv run sim logs last # full last RunResult51uv run sim logs last --field exit_code52```5354Persistent-session mode (`uv run sim serve` + `uv run sim connect/exec/inspect/disconnect`)55is supported when sim-server is reachable, but is **not** required for56typical case authoring.5758---5960## Work sequence (the protocol)6162Before writing any OpenFOAM file, classify the case:6364- **Time**: steady or transient?65- **Compressibility**: incompressible or compressible?66- **Phases**: single-phase, two-phase (VOF), or multi-region?67- **Turbulence**: laminar, RANS (k-ε / k-ω SST / SpalartAllmaras), or LES/DNS?68- **Heat/buoyancy**: isothermal, forced convection, or buoyancy-driven?6970This classification fixes the solver family (see `solver-selection.md`),71the required field set (see `field-and-dictionary-matrix.md`), and the72turbulence boundary recipe (see `turbulence-setup.md`).7374Then, in this order:75761. **Mesh** (`blockMesh` or `snappyHexMesh`); validate with `checkMesh`.772. **Fields** in `0/`: one per required field; consistent patch names with the mesh.783. **Properties** in `constant/`: transport, turbulence, thermophysical (when relevant).794. **Numerics** in `system/`: `controlDict`, `fvSchemes`, `fvSolution`. Start80 conservative (upwind, low CFL, tight relaxation) and upgrade after the81 case is stable.825. **Run** the chosen solver; tail the log; check the convergence signals83 (`references/log-parsing-and-residuals.md`).846. **Post-process** to extract the requested KPI.8586Validate at every layer — don't push to "run solver" before `checkMesh` is87clean and the field files reference patches that exist in the mesh.8889---9091## Hard guardrails9293These are mistakes LLMs make often. Don't.9495- **Don't invent dictionary keys, patch types, or solver names.** Every key96 in `controlDict` / `fvSchemes` / `fvSolution` / `transportProperties` /97 field files comes from a closed vocabulary. If you're not sure the key98 exists, look it up rather than guess.99- **Don't mix turbulence-model fields.** k-ε needs `k` + `epsilon` + `nut`;100 k-ω SST needs `k` + `omega` + `nut`; Spalart-Allmaras needs `nuTilda` +101 `nut`. Mixing fields across models causes solver to abort at startup.102- **Don't use `p` when the solver expects `p_rgh`.** Buoyant solvers103 (`buoyantBoussinesqSimpleFoam`, `buoyantSimpleFoam`, `chtMultiRegionFoam`)104 and VOF (`interFoam`) want `p_rgh`. Pure incompressible (`icoFoam`,105 `simpleFoam`, `pimpleFoam`) want `p`.106- **Don't use `linear` (central differencing) for `alpha.water` convection107 in VOF.** It's unbounded; `alpha` will blow past [0,1]. Use `vanLeer`108 or `MUSCL` via the `interfaceCompression` family.109- **Don't set relaxation factors to 1.0 in steady-state SIMPLE without110 `consistent yes` (SIMPLEC).** It's a recipe for divergence on most cases.111- **Don't keep aggressive second-order convection schemes on a fragile112 case.** Stabilize with `upwind` first, upgrade to `linearUpwind` once113 residuals are well-behaved.114- **Don't treat `checkMesh` warnings as optional if the log is already115 diverging.** Most divergence on a fresh case is a mesh-quality issue.116- **Don't assume `0/` exists.** Many tutorials ship `0.orig/` and rely on117 `Allrun` to copy it; if you skip Allrun, do it yourself: `cp -r 0.orig 0`.118- **Don't run on more MPI ranks than `numberOfSubdomains` in119 `decomposeParDict`.** They must match, or `mpirun` will hang or crash.120121---122123## Output expected124125When you finish, produce a short summary that states:126127- Solver and physics family chosen128- Required fields and dictionaries authored129- Turbulence model + wall treatment (if any) + estimated inlet turbulence130- Numerical schemes used and any relaxation choices131- Convergence signal observed (`End` reached? final residuals? continuity errors?)132- The requested KPI value, with units133- Any stability concerns or follow-up recommendations134135For benchmark/grader contexts, this summary is implicit in the produced136`/tmp/agent/result.json` — you still benefit from doing the mental137checklist before submitting.138139---140141## Reference index142143| File | When to read |144|---|---|145| `references/case-setup.md` | Always, first |146| `references/solver-selection.md` | Picking a solver / pressure convention |147| `references/field-and-dictionary-matrix.md` | "What files do I need?" lookup |148| `references/boundary-conditions.md` | Concrete BC syntax per type |149| `references/turbulence-setup.md` | Any turbulent case |150| `references/mesh-and-blockmesh.md` | Mesh generation, `blockMesh`, `checkMesh` |151| `references/numerics-and-schemes.md` | `fvSchemes`, `fvSolution`, relaxation, algorithm controls |152| `references/multiphase-vof.md` | Two-phase / VOF cases |153| `references/heat-transfer.md` | Buoyant or compressible-thermal |154| `references/conjugate-heat-transfer.md` | Multi-region fluid + solid |155| `references/parallel-execution.md` | `decomposePar`, MPI, `reconstructPar` |156| `references/log-parsing-and-residuals.md` | Diagnosing solver progress + convergence |157| `references/post-processing.md` | `postProcess`, `sample`, point queries |158| `references/function-objects.md` | Runtime monitors (probes, forces, yPlus) |159| `references/case-recipes.md` | Complete skeletons by scenario |160| `references/error-recovery.md` | Failure decision tree + fix sequences |161| `references/failure_patterns.md` | Catalog of historical failures (legacy) |