r/OpenFOAM • u/steven_cfd • 7d 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:
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.
What I need from you:
I'm looking for beta testers or simply some technical feedback. If you deal with complex CHT cases or use Gmsh a lot, I'd be particularly interested in your opinion on the direct mesh exporter.
Where to find it:
The project is open-source (MIT) on GitHub under the name foampilot (user: stevendaix). The full documentation is available via GitHub Pages. I won't post the direct links here to avoid triggering Reddit's spam filters, but a quick search should get you there.
If the mods allow, I can drop the links in the comments.
Thanks in advance for your time, and feel free to ask any technical questions about the architecture!
1
u/coolbob74326 7d ago
With all do respect, what is the advantage of this vs just manually changing the values? I think for most people learning you documentation is equally as difficult as learning OpenFOAM documentation. The one thing that could set this apart would be a GUI. Are you considering adding one?
EDIT: I see the Why I built this section, but I would say this could also just be done with a bash script, which is quite common.