[ANN] WaterLily.jl: A differentiable fluid simulator with fast heterogeneous execution

WaterLily.jl v1.0 is out! :tada:

WaterLily is a simple and fast fluid simulator written in pure Julia. It solves the unsteady incompressible 2D or 3D Navier-Stokes equations on a Cartesian grid. The pressure Poisson equation is solved with a geometric multigrid method. Solid boundaries are modelled using the Boundary Data Immersion Method.

v1.0 has ported the solver from a serial CPU execution to a backend-agnostic execution including multi-threaded CPU and GPU from different vendors (NVIDIA and AMD tested so far) thanks to KernelAbstractions.jl. Compared to the previous serial version, we have benchmarked up to x182 speed-up on a GPU.

The most impressive fact is that the solver source code remains only around 800 LOC! We implement the @loop macro, which wraps @kernel from KernelAbstraction.jl and produces a kernel for an expression such as @loop <expr> over <I in R>, where I is a CartesianIndex and R is a CartesianIndices range. And just by changing the array type of our Simulation struct from Array to CuArray or ROCArray, we can run in CPU, NVIDIA GPUs, or AMD GPUs, respectively.

All this would not have been possible without CUDA.jl, AMDGPU.jl and KernelAbstractions.jl, so, again, thank you! :heart:

Feel free to ping @weymouth or myself for more info :smile:


The speed-up with GPUs enables impressive 3D flow simulations on a PC. This jelly fish simulation runs and visualizes real-time on my laptop:

And this 50 million degree-of-freedom turbulent flow simulation only took 30 minutes to run and render:


very impressive!


What mathematical shape was used for the jellyfish? What was the size of the spatial grid and the time step?

Spherical shell sliced below the equator. Then pumped wider/shorter and narrower/longer to preserve the solid volume. All of this, and the resolution, is variable. Take a look at the code. The time step is automatically set by the CFL condition.


Very impressive!

What do you use for differentiation of the kernels, Enzyme?

1 Like