Abstract
This model description paper introduces a new finite element model for the simulation of non-linear shallow water flows, called Firedrake-Fluids. Unlike traditional models that are written by hand in static, low-level programming languages such as Fortran or C, Firedrake-Fluids uses the Firedrake framework to automatically generate the model's code from a high-level abstract language called Unified Form Language (UFL). By coupling to the PyOP2 parallel unstructured mesh framework, Firedrake can then target the code towards a desired hardware architecture to enable the efficient parallel execution of the model over an arbitrary computational mesh. The description of the model includes the governing equations, the methods employed to discretise and solve the governing equations, and an outline of the automated solution process. The verification and validation of the model, performed using a set of well-defined test cases, is also presented along with a road map for future developments and the solution of more complex fluid dynamical systems.
The Sustainability Crisis in CFD
In Computational Fluid Dynamics (CFD), researchers face a growing "sustainability crisis." Traditional models often comprise hundreds of thousands of lines of hand-crafted Fortran or C code. While these "hand-rolled" implementations are highly optimized for specific systems, they are notoriously difficult to maintain, prone to human error, and challenging to port to emerging hardware architectures like GPUs or many-core CPUs. As hardware evolves, scientists often find themselves spending more time debugging parallel infrastructure than advancing physical science.
Firedrake-Fluids v0.1 addresses this by decoupling the mathematical specification of a model from its computational implementation. This allows researchers to focus on the physics while the software framework handles the underlying optimization and hardware targeting.
Methods: Automated Code Generation
The core innovation of Firedrake-Fluids is its use of the Firedrake framework and the Unified Form Language (UFL). Instead of manually writing loops over mesh elements, developers define the governing equations in UFL—a high-level language that mirrors mathematical notation.
As shown in the framework architecture, Firedrake takes this high-level description and compiles it into optimized C code at runtime. This process involves the FEniCS Form Compiler (FFC) and PyOP2, a framework for unstructured mesh kernels. Because code is generated on the fly, it can be optimized for specific hardware instruction sets without altering the model's source code. This approach allows Firedrake-Fluids to perform complex simulations with only approximately 400 lines of code, compared to the tens of thousands required by traditional models.
Governing Equations and Numerical Schemes
The model is designed to solve the non-linear shallow water equations, which describe the flow of a fluid layer where the horizontal scale is much larger than the vertical depth.
Firedrake-Fluids employs the Galerkin finite element method, supporting various element pairs such as P2–P1 (continuous quadratic velocity and linear pressure) and P0–P1 (discontinuous velocity). Time integration is performed via an implicit backward Euler scheme, and non-linearities are resolved using Newton iterations through the PETSc library.
Verification and Performance Results
The model underwent a rigorous suite of benchmarks to ensure mathematical and physical accuracy:
- Mathematical Correctness: Using the Method of Manufactured Solutions (MMS), the model confirmed 2nd-order spatial convergence for the free surface and nearly 3rd-order for velocity when using P2–P1 elements.
- Physical Accuracy: In 1D and 2D dam break tests and tidal flow benchmarks, the model successfully handled discontinuities and complex topography. Notably, in flow past a square cylinder, it captured the "vortex street" (turbulent shedding) behind the object, matching experimental velocity profiles.
- Scalability: The solver demonstrated strong scaling on the ARCHER supercomputer (a Cray XC30), maintaining high efficiency while scaling up to nearly 1,000 MPI processes for a 2D simulation with over 800,000 vertices.
Limitations and Future Outlook
While Firedrake-Fluids v0.1 represents a significant step forward, several areas for development remain. Initial hardware restrictions meant that GPU execution for non-linear problems was not fully supported at launch. Furthermore, while the model includes Smagorinsky Large-Eddy Simulation (LES), wake recovery behind objects requires more sophisticated turbulence closures. Future iterations aim to extend the framework to full 3D Navier-Stokes equations and incorporate higher-order temporal schemes like Crank-Nicolson.
Summary updated