Advanced Automatic Code Generation for Multiple Relaxation-Time Lattice Boltzmann Methods

Hennig F, Holzer M, Rüde U (2023)

Publication Type: Journal article

Publication year: 2023


Book Volume: 45

Pages Range: C233-C254

Issue: 4

DOI: 10.1137/22M1531348


The scientific code generation package lbmpy supports the automated design and the efficient implementation of lattice Boltzmann method (LBM) through metaprogramming. It is based on a new, concise calculus for describing multiple relaxation-time LBMs, including techniques that enable the numerically advantageous subtraction of the constant background component from the populations. These techniques are generalized to a wide range of collision spaces and equilibrium distributions. The article contains an overview of lbmpy’s frontend and its code generation pipeline, which implements the new LBM calculus by means of symbolic formula manipulation tools and object-oriented programming. The generated codes have only a minimal number of arithmetic operations. Their automatic derivation rests on two novel chimera transforms that have been specifically developed for efficiently computing raw and central moments. Information contained in the symbolic representation of the methods is further exploited in a customized sequence of algebraic simplifications, further reducing computational cost. When combined, these algebraic transformations lead to concise and compact numerical kernels. Specifically, with these optimizations, the advanced central moment- and cumulant-based methods can be realized with only little additional cost as when compared with the simple Bhatnagar–Gross–Krook method. The effectiveness and flexibility of the new lbmpy code generation system is demonstrated in simulating Taylor–Green vortex decay and the automatic derivation of an LBM algorithm to solve the shallow water equations.

Authors with CRIS profile

Additional Organisation(s)

How to cite


Hennig, F., Holzer, M., & Rüde, U. (2023). Advanced Automatic Code Generation for Multiple Relaxation-Time Lattice Boltzmann Methods. SIAM Journal on Scientific Computing, 45, C233-C254.


Hennig, Frederik, Markus Holzer, and Ulrich Rüde. "Advanced Automatic Code Generation for Multiple Relaxation-Time Lattice Boltzmann Methods." SIAM Journal on Scientific Computing 45 (2023): C233-C254.

BibTeX: Download