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.
1 Textbooks
- Abridged CFD textbook reviews : r/CFD
- Anderson (1995) seems to be everyone’s favourite casual intro
- (Bridson 2016; Kim 2017) seem popular for graphics engines
- (Ferziger, Perić, and Street 2019; Kuzmin 2010; Sharma 2022; Tu, Yeoh, and Liu 2018) have all been recommended by various people
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 that I have attempted to use are below. There is a much more comprehensive list at * thw1021/Code4CFD “A curated list of repositories related to fluid dynamics.”
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 parallelised 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 modelling 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 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?
6.6 OpenFOAM
OpenFOAM (for “Open-source Field Operation And Manipulation”) is a C++ toolbox for the development of customised 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.7 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.8 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.9 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.10 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.