This repository provides a PyTorch + PyG (PyTorch Geometric) implementation of MeshGraphNets—a powerful graph neural network framework for learning mesh-based physical simulations. We focus on the flow around a circular cylinder problem, reproducing and extending the groundbreaking work from DeepMind.
🔬 Original Paper:
Learning Mesh-Based Simulation with Graph Networks
Tobias Pfaff, Meire Fortunato, Alvaro Sanchez-Gonzalez, Peter W. Battaglia
ICLR 2021
- Physics-aware learning: Leverages mesh structure to respect geometric and physical priors.
- High performance: Runs 10–100× faster than traditional solvers while maintaining fidelity.
- Extensible: Built on PyTorch Geometric—easy to adapt to new PDEs, materials, or domains.
Install dependencies via:
pip install -r requirements.txt💡 Note: TensorFlow < 1.15.0 is required only for parsing the original TFRecord datasets.
We use DeepMind’s cylinder_flow dataset:
aria2c -x 8 -s 8 https://storage.googleapis.com/dm-meshgraphnets/cylinder_flow/train.tfrecord -d data
aria2c -x 8 -s 8 https://storage.googleapis.com/dm-meshgraphnets/cylinder_flow/valid.tfrecord -d data
aria2c -x 8 -s 8 https://storage.googleapis.com/dm-meshgraphnets/cylinder_flow/test.tfrecord -d dataConvert to PyTorch-friendly format:
python parse_tfrecord.pyOutput saved in
./data/.
python train.pyFOR MULTI-GPU TRAINING:
export NGPUS=2 # set as your machine's available GPUs
torchrun --nproc_per_node=$NGPUS train_ddp.py --dataset_dir dataGenerate long-horizon predictions and render videos:
python rollout.py # saves results to ./results/
python render_results.py # generates videos in ./videos/| Demo 0 | Demo 1 |
|---|---|
![]() |
![]() |
| Demo 2 | Demo 3 |
|---|---|
![]() |
![]() |
✅ The model generalizes well—even to unseen flow regimes and mesh configurations!
Have questions, suggestions, or want to collaborate?
📧 Reach out: [email protected]
⭐ If you find this project useful, please consider starring the repo!
Your support helps us keep improving open-source scientific ML tools.



