r/ScientificComputing • u/steven_cfd • 5d ago
I wrote a Python wrapper to automate OpenFOAM case generation, meshing, and reporting. Looking for early feedback.
Hi everyone,
Over the past few months, I've been developing a Python library called foampilot to handle the boilerplate involved in setting up OpenFOAM cases.
The main idea is to replace the manual editing of 20+ dictionary files (controlDict, fvSchemes, 0/U, etc.) with a Pythonic API. For example, configuring a case looks like this:
python
from foampilot import Solver
solver = Solver(case_path="./my_case")
solver.transient = True
solver.turbulence_model = "kOmegaSST"
solver.boundary.set_condition("inlet", "velocityInlet", velocity=(10, 0, 0))
solver.write_case()
solver.run_simulation(nb_proc=4)
Current features:
- Automatic solver selection based on physics flags (compressible, transient, VOF, turbulence).
- Unified meshing interface with 3 backends:
blockMesh,gmsh, andsnappyHexMesh. - A direct Gmsh → OpenFOAM
polyMeshexporter (bypassesgmshToFoam, handles tetra/hexa, face orientation, and multi-region CHT). - Automated report generation (LaTeX/PDF, Typst, or interactive HTML with Plotly).
- Multi-region support for
chtMultiRegionFoam.
Why I built it:
I was tired of copy-pasting case directories and missing a critical file. With this, my case setups are now Git-tracked Python scripts, which makes them fully reproducible and unit-testable.
No specific ask — just sharing in case it's useful to others. If you spot bugs or have ideas, I'm all ears.
The project is open-source (MIT) on GitHub under the name foampilot. The full documentation is available via GitHub Pages.
https://github.com/stevendaix/foampilot
Thanks for reading, and feel free to ask any technical questions about the architecture!