DLpisoFoam
Machine Learning enhanced CFD solvers: isothermal & thermal fluid flow
Install / Use
/learn @pauloacs/DLpisoFoamREADME
DLpisoFoam, DLbuoyantPimpleFoam & DLbuoyantPimpleFoam_auto
Deep Learning-Enhanced CFD Solvers for Accelerated Fluid Flow Simulations
<p align="center"> <img src="figures/solvers_overview.png" alt="Solvers Overview" width="700px"/> </p>📋 Contents
- Introduction
- Surrogate Model Overview
- What This Repository Enables
- Key Features
- Publications
- Repository Structure
- Getting Started
- Available CFD Solvers
- Legacy Solvers
- Citation
- Contact
- Acknowledgments
🎯 Introduction
This repository contains machine learning-enhanced OpenFOAM solvers that accelerate computational fluid dynamics (CFD) simulations by replacing the computationally expensive pressure Poisson equation solver with a deep learning surrogate model.
DLpisoFoam, DLbuoyantPimpleFoam, and DLbuoyantPimpleFoam_auto are based on OpenFOAM v8 and implement the PISO/PIMPLE algorithms with integrated neural network surrogate models for improved pressure-velocity coupling. DLbuoyantPimpleFoam_auto is self-contained — it trains its own surrogate model on-the-fly during the simulation, requiring no pre-trained model or offline dataset generation.
This is an all-in-one repository containing both surrogate models and CFD solvers, building upon the work from Solving-Poisson's-Equation-through-DL-for-CFD-applications.
UPCOMING: AUTO-trainable ML-enhanced CFD Solvers (surrogate train and simulation in a single command)
Surrogate Model overview
<p align="center"> <img src="figures/SM_integration.jpg" alt="Surrogate Model integration with the CFD solver" width="700px"/> </p>🎯 What This Repository Enables
This repository provides a complete workflow for accelerating CFD simulations with machine learning:
- Generate Training Data: Run CFD simulations to create comprehensive datasets from various flow scenarios (examples in
gen_datasets/) - Train Surrogate Models: Develop neural network models that learn to predict pressure corrections in unsteady CFD simulations (examples in
train_SM/) - Deploy in Production: Integrate trained models with custom OpenFOAM-based solvers for accelerated simulations (examples in
tutorials/)
✨ Key Features
- 🚀 Accelerated simulations: Up to 40% less iterations required to convergence when compared to standard OpenFOAM solvers
- 🧠 ML-powered: Machine Learning surrogate models enhance pressure Poisson solver
- 🌡️ Multiple physics: Supports isothermal and thermal flows
- 🔧 OpenFOAM compatible: Drop-in replacement for
pisoFoamandbuoyantPimpleFoam - 🤖 Self-training:
DLbuoyantPimpleFoam_autotrains its surrogate model automatically during the simulation — no pre-trained model needed - 🐳 Docker ready: Pre-built containers for easy deployment
- 📊 2D & 3D: Surrogate models available for both 2D and 3D simulation cases
📚 Publications
1. Surrogate Model Development
Application of machine learning to model the pressure Poisson equation for fluid flow on generic geometries
Neural Computing and Applications (2024)
- Detailed description of the ML surrogate model architecture and training
2. DLpisoFoam Benchmark
Enhancing CFD solver with Machine Learning techniques
Computer Methods in Applied Mechanics and Engineering (2024)
- Performance benchmarks and validation of DLpisoFoam solver
3. Improved Pressure-Velocity Coupling
- Enhanced pressure surrogate model and integration methodology
4. 3D Extensions (Coming Soon)
- Extension to 3D surrogate models and complex geometries
📁 Repository Structure
DLpisoFoam/
├── source/ # Solver source code
│ ├── DLpisoFoam/ # Incompressible isothermal solver
│ ├── DLbuoyantPimpleFoam/ # Thermal flow solver
│ └── DLbuoyantPimpleFoam_auto/ # Self-training thermal flow solver
├── pressure_SM/ # Surrogate models
│ ├── 2D/ # 2D models
│ │ ├── train_and_eval/ # Training & evaluation scripts
│ │ └── CFD_usable/ # Interface for integration with CFD solver
│ └── 3D/ # 3D models
│ ├── train_and_eval/ # Training & evaluation scripts
│ │ └── CFD_usable/ # Interface for integration with CFD solver
├── tutorials/ # Example test cases
├── gen_datasets/ # Dataset generation scripts
├── other_solvers/ # Legacy solver versions
├── Dockerfile # Docker build configuration
└── env_311.yml # Python environment specification
🚀 Getting Started
This guide will walk you through:
- Setting up your environment (Docker or local)
- Training a surrogate model (SM) from scratch
- Running CFD simulations with the trained model
Prerequisites
- For Docker: Docker installed (Get Docker)
- For local install:
- OpenFOAM v8
- Conda or Miniconda
- Python 3.11
Part 1: Environment Setup
Option 1: Docker (Recommended)
Easiest method with automated setup and guaranteed reproducibility.
Pull pre-built image:
docker pull pauloacs/dlpisofoam:latest
Or build locally:
docker build -t dlpisofoam .
Run container:
docker run -it -v $(pwd):/home/repo --rm pauloacs/dlpisofoam bash
This mounts your current directory inside the container at /home/repo.
Option 2: Local Installation
Step 1: Create Python environment
conda env create -f env_311.yml
conda activate python311_solver
Step 2: Install surrogate model packages
python -m pip install -e .
Step 3: Set up OpenFOAM environment
source /opt/openfoam8/etc/bashrc # Adjust path to your OpenFOAM installation
./prep_env311.sh # Set Python/NumPy paths
Note: You may need to modify prep_env311.sh with paths to your conda environment:
export PYTHON_INCLUDE_PATH=$CONDA_PREFIX/include/python3.11
export NUMPY_INCLUDE_PATH=$CONDA_PREFIX/lib/python3.11/site-packages/numpy/core/include
export PYTHON_LIB_PATH=$CONDA_PREFIX/lib
export PYTHON_LIB_NAME=lpython3.11
Step 4: Compile the solvers
For DLpisoFoam:
cd source/DLpisoFoam
wclean
wmake
For DLbuoyantPimpleFoam:
cd source/DLbuoyantPimpleFoam
wclean
wmake
Verify installations:
which DLpisoFoam
DLpisoFoam -help
which DLbuoyantPimpleFoam
DLbuoyantPimpleFoam -help
Part 2: Preparing Datasets & Training Your Surrogate Model
Part 2.1: Generate CFD Training Data
Use the scripts in gen_datasets/ to generate training datasets from various flow scenarios:
- Confined flows over chip arrays: Electronics cooling simulations
- Flow around squared cylinders: Bluff body aerodynamics
- Flow over inclined plates: Boundary layer studies
All configurations support both isothermal and thermal conditions to match your application requirements.
Modified versions of pisoFoam and buoyantPimpleFoam are included to extract the necessary flow field data for training. Depending on the simulation type, generation can be fully or semi-automatic.
Part 2.2: Train the Surrogate Model
Navigate to train_SM/ and use the run_train.sh scripts to train your model:
cd train_SM/
# Edit run_train.sh to set your datasetPath
./run_train.sh
Key Configuration:
- Required: Set
datasetPathto your training dataset location - Optional: Adjust hyperparameters (learning rate, batch size, dropout, etc.)
Training Outputs:
- Model file: HDF5 format TensorFlow model (e.g.,
model_MLP_small-std-drop0.1-lr0.0005-regNone-batch1024.h5) - Compression artifacts: Tucker factors (3D cases) or PCA vectors (2D cases) (required for CFD deployment)
These files are ready to use with the CFD solvers - the model weights/biases load automatically via TensorFlow.
Part 3: 🏃 Running Your First CFD Simulation with the Surrogate Model
Part 3.1: Run the DLpisoFoam Test Case with the PRE-TRAINED Surrogate Model
# Navigate to test case
cd tutorials/DLpisoFoam/
# Run mesh generation (if needed)
./genMesh.sh
# Run the solver
DLpisoFoam
# Open in ParaView
paraFoam
# Or use bui
