A production-ready Python automation pipeline and CLI for external aerodynamics CFD, generating watertight OpenFOAM cases, conformal multi-region meshes, and real-time telemetry from raw STL geometries.
OpenFOAM is one of the most capable open-source CFD solvers in computational fluid dynamics, but setting up external aerodynamics simulations requires manually configuring dozens of complex, interdependent C++ dictionary files—including blockMeshDict, snappyHexMeshDict, fvSchemes, fvSolution, decomposeParDict, and individual boundary condition vector fields. For Formula Student (FSAE) race teams rapidly iterating through front wings, rear wings, sidepods, and undertrays, this manual workflow creates a severe engineering bottleneck prone to human error, mesh non-orthogonality, and divergence.
To eliminate this friction, I developed OpenFOAM Case Generator—a standalone, zero-dependency Python engineering pipeline that automates the entire external aerodynamics workflow from raw ASCII STL geometry to converged force post-processing using standard OpenFOAM commands.
The pipeline is architected around a declarative JSON specification (configs/config.json) and built exclusively with the Python standard library, requiring no external package installations for core case generation or force extraction:
nutUSpaldingWallFunction) and k-ω SST turbulence closure.surfaceFeatureExtract (140° included angle), blockMesh background grids, distance-based refinement shells (e.g., 25 mm → Level 4, 80 mm → Level 3), a two-stage wake refinement architecture (nearWakeBox and farWakeBox), prism boundary layer inflation (Fast, Standard, Fine presets), parallel checkMesh quality diagnostics, and bandwidth-optimizing renumberMesh.potentialFoam before RANS solving; configures SIMPLEC pressure-velocity coupling (consistent true;) with tuned relaxation factors (p = 0.7, U = 0.7), TVD velocity divergence schemes (bounded Gauss limitedLinear 1), and fast GAMG multigrid elliptic pressure solvers.stopAt writeNow; for clean auto-stopping, and an interactive 4-page animated live dashboard (read_forces.py --live).run.sh) configured for high-performance computing clusters (such as the Chulalongkorn University e-Science cluster), featuring Scotch MPI domain decomposition, node-local high-speed scratch disk execution ($TMPDIR / /dev/shm), 15-second background sync loops, and POSIX signal traps (SIGTERM, SIGINT) to safeguard and reconstruct simulation results against cluster preemption.Key Engineering Takeaway
"Automating CFD isn't just about scripting dictionary files—it requires embedding aerodynamic domain physics directly into computational geometry algorithms. By coupling streaming STL processing with automated multi-box wake refinement, physics-aware boundary conditions, and real-time force convergence monitors, we transformed an error-prone multi-hour manual setup into a deterministic, single-command pipeline."
The generator drastically compressed aerodynamic setup times from over 2–3 hours of manual dictionary editing down to under 5 seconds for case generation, allowing engineering teams to focus on aerodynamic innovation rather than software troubleshooting:
./Allrun.parallel or direct simpleFoam execution) without vendor lock-in or proprietary binary wrappers.