Computational Fluid Dynamics

January 27, 2021 — November 30, 2023

Fluid dynamics is a specialised sub-discipline of partial differential equations. We start by solving some variants of the Navier-Stokes equations, which govern the motion of fluids. Although these equations are idealised, they are already notoriously complicated and analytically challenging.

I know little of this area, but since I work with CFD people on ML, I need to know at least the terminology.

Figure 1

1 Textbooks

2 Tutorials

3 Eulerian methods

3.1 Finite difference method

TBD

3.2 Finite Element method

TBD

3.3 Finite volume method

TBD

4 Lagrangian methods

4.1 Smoothed Particle Hydrodynamics

TBD

5 Other methods

5.1 Lattice Boltzmann methods

6 Tooling

There are many PDE solvers, but some claim special affordances for fluid flow.

Useful (i.e. cheap, free) ones for me are below.

6.1 Mantaflow

mantaflow: an extensible framework for fluid simulation

mantaflow is an open-source framework targeted at fluid simulation research in Computer Graphics and Machine Learning. Its parallelized C++ solver core, python scene definition interface and plugin system allow for quickly prototyping and testing new algorithms. A wide range of Navier-Stokes solver variants are included. It’s very versatile, and allows coupling and import/export with deep learning frameworks (e.g., tensorflow via numpy) or standalone compilation as matlab plugin. Mantaflow also serves as the simulation engine in Blender.

Feature list

The framework can be used with or without GUI on Linux, MacOS and Windows. An incomplete list of features implemented so far:

  • Eulerian simulation using MAC Grids, PCG pressure solver and MacCormack advection
  • Flexible particle systems
  • FLIP simulations for liquids
  • Surface mesh tracking
  • Free surface simulations with levelsets, fast marching
  • Wavelet and surface turbulence
  • K-epsilon turbulence modeling and synthesis
  • Maya and Blender export for rendering

Mantaflow is associated with some projects that examine neural PDE solutions, and also with producing stunning 3d animations as an output.

6.2 Dune/Dumux

A porous flow solver, useful in e.g. hydrology.

6.3 Clawpack

Clawpack documentation

Clawpack is a collection of finite volume methods for linear and nonlinear hyperbolic systems of conservation laws. Clawpack employs high-resolution Godunov-type methods with limiters in a general framework applicable to many kinds of waves. Clawpack is written in Fortran and Python.

There is a python… interface? Port?

6.4 PhiFlow

PhiFlow: A differentiable PDE solving framework for machine learning (Holl et al. 2020).

I use this a lot, so it has its own notebook.

6.5 jax-cfd

Unremarkable name, looks handy though. Implements both projection methods and spectral methods, and different variations of Crank-Nicholson for fluid-dynamical models. Seems to imply periodic boundary conditions?

Figure 2

6.6 DPFEHM

OrchardLANL/DPFEHM.jl: DPFEHM: A Differentiable Subsurface Flow Simulator

DPFEHM is a Julia module that includes differentiable numerical models with a focus on fluid flow and transport in the Earth’s subsurface. Currently it supports the groundwater flow equations (single phase flow), Richards equation (air/water), the advection-dispersion equation, and the 2d wave equation.

Does not seem to support CUDA well but is nifty. Use in e.g. Pachalieva et al. (2022). Inverse solver example. NN example.

6.7 OpenFOAM

OpenFOAM

OpenFOAM (for “Open-source Field Operation And Manipulation”) is a C++ toolbox for the development of customized numerical solvers, and pre-/post-processing utilities for the solution of continuum mechanics problems, most prominently including computational fluid dynamics (CFD).

The adjoint optimisation takes some digging to discover. Keyword: adjointOptimisationFoam (E. Papoutsis-Kiachagias et al. 2021).

6.8 JuliaFEM

Julaifem is an umbrella organisation supporting julia-backed FEM solvers. The documentation is tricksy, but check out the examples, Supported solvers listed here. I assume these are all differentiable, since that is a selling point of the SciML.jl ecosystem they spring from, but I have not checked. The emphasis seems to be upon cluster-distributed solutions at scale.

6.9 FEniCS

Also seems to be a friendly PDE solver, lacking in GPU support. However, it does have an interface to pytorch, barkm/torch-fenics on the CPU to provide differentiability with respect to parameters.

6.10 dolfin+ dolfin-adjoint

dolfin-adjoint (Mitusch, Funke, and Dokken 2019):

The dolfin-adjoint project automatically derives the discrete adjoint and tangent linear models from a forward model written in the Python interface to FEniCS and Firedrake

These adjoint and tangent linear models are key ingredients in many important algorithms, such as data assimilation, optimal control, sensitivity analysis, design optimisation, and error estimation. Such models have made an enormous impact in fields such as meteorology and oceanography, but their use in other scientific fields has been hampered by the great practical difficulty of their derivation and implementation. In his recent book Naumann (2011) states that

[T]he automatic generation of optimal (in terms of robustness and efficiency) adjoint versions of large-scale simulation code is one of the great open challenges in the field of High-Performance Scientific Computing.

The dolfin-adjoint project aims to solve this problem for the case where the model is implemented in the Python interface to FEniCS/Firedrake.

This provides the AD backend to barkm/torch-fenics which integrates with pytorch.

6.11 Engys Helyx

HELYX is a unified, off-the-shelf CFD software product compatible with most Linux and Windows platforms, including high-performance computing systems. In addition to the base software components delivered for installation (HELYX-GUI and HELYX-Core), the package also incorporates an extensive set of ancillary services to facilitate the deployment and usage of the software in any working environment.

HELYX features an advanced hex-dominant automatic mesh algorithm with polyhedra support which can run in parallel to generate large computational grids. The solver technology is based on the standard finite-volume approach, covering a wide range of physical models: single- and multi-phase turbulent flows (RANS, URANS, DES, LES), thermal flows with natural/forced convection, thermal/solar radiation, incompressible and compressible flow solutions, etc. In addition to these, we have developed a Generalised Internal Boundaries (GIB) method to support complex boundary motions inside the finite-volume mesh. The standard capabilities of HELYX can also be expanded with the HELYX-ADD-ONS extension modules to cover more specialised applications.

7 References

Anderson. 1995. Computational Fluid Dynamics.
Barba, and Forsyth. 2018. CFD Python: The 12 Steps to Navier-Stokes Equations.” Journal of Open Source Education.
Bezgin, Buhendwa, and Adams. 2022. JAX-FLUIDS: A Fully-Differentiable High-Order Computational Fluid Dynamics Solver for Compressible Two-Phase Flows.” arXiv:2203.13760 [Physics].
Brenner, Eldredge, and Freund. 2019. Perspective on Machine Learning for Advancing Fluid Mechanics.” Physical Review Fluids.
Bridson. 2016. Fluid Simulation for Computer Graphics.
Brunton, Noack, and Koumoutsakos. 2020. Machine Learning for Fluid Mechanics.” Annual Review of Fluid Mechanics.
Chu, Thuerey, Seidel, et al. 2021. Learning Meaningful Controls for Fluids.” ACM Transactions on Graphics.
Duraisamy, Iaccarino, and Xiao. 2019. Turbulence Modeling in the Age of Data.” Annual Review of Fluid Mechanics.
Ferziger, Perić, and Street. 2019. Computational Methods for Fluid Dynamics.
Holl, Koltun, Um, et al. 2020. Phiflow: A Differentiable PDE Solving Framework for Deep Learning via Physical Simulations.” In NeurIPS Workshop.
Hu, Anderson, Li, et al. 2020. DiffTaichi: Differentiable Programming for Physical Simulation.” In ICLR.
Kim. 2017. Fluid Engine Development.
Kitsios, Frederiksen, and O’Kane. 2023. Subgrid Parameterization of Eddy, Meanfield and Topographic Interactions in Simulations of an Idealized Antarctic Circumpolar Current.” Journal of Advances in Modeling Earth Systems.
Kochkov, Smith, Alieva, et al. 2021. Machine Learning–Accelerated Computational Fluid Dynamics.” Proceedings of the National Academy of Sciences.
Kuzmin. 2010. A Guide to Numerical Methods for Transport Equations.
Malosso, Zhang, Car, et al. 2022. Viscosity in Water from First-Principles and Deep-Neural-Network Simulations.” Npj Computational Materials.
Mitusch, Funke, and Dokken. 2019. Dolfin-Adjoint 2018.1: Automated Adjoints for FEniCS and Firedrake.” Journal of Open Source Software.
Naumann. 2011. The Art of Differentiating Computer Programs: An Introduction to Algorithmic Differentiation.
Pachalieva, O’Malley, Harp, et al. 2022. Physics-Informed Machine Learning with Differentiable Programming for Heterogeneous Underground Reservoir Pressure Management.”
Papoutsis-Kiachagias, E. M., and Giannakoglou. 2016. Continuous Adjoint Methods for Turbulent Flows, Applied to Shape and Topology Optimization: Industrial Applications.” Archives of Computational Methods in Engineering.
Papoutsis-Kiachagias, Evangelos, Gkaragkounis, Margetis, et al. 2021. adjointOptimisationFoam: An Openfoam-Based Framework for Adjoint-Assisted Optimisation.” In 14th International Conference on Evolutionary and Deterministic Methods for Design, Optimization and Control.
Pawar, and San. 2019. CFD Julia: A Learning Module Structuring an Introductory Course on Computational Fluid Dynamics.” Fluids.
Peshkov, and Romenski. 2016. A Hyperbolic Model for Viscous Newtonian Flows.” Continuum Mechanics and Thermodynamics.
Sharma. 2022. Introduction to Computational Fluid Dynamics: Development, Application and Analysis.
Tu, Yeoh, and Liu. 2018. Computational Fluid Dynamics: A Practical Approach.
Um, Brand, Fei, et al. 2021. Solver-in-the-Loop: Learning from Differentiable Physics to Interact with Iterative PDE-Solvers.” arXiv:2007.00016 [Physics].