Real-Time Fluid Dynamics

Fluids are found in a multitude of different places: In the water of a river, in the cigar's smoke, in the water vapor that creates clouds... There is an increasing need for realistically representing these phenomena in all kinds of graphics applications (e.g. in a video game).

In this website, the reader will be introduced to basic fluid concepts and formulae in order to code a CPU implementation. After we are comfortable with fluid basics and the coding scheme for our first implementation, we can try to parallelize the code to obtain higher performance. This improvement can be achieved using CUDA, a GPU solution.

The author has ported the CUDA/OpenGL Fluid Simulation nVIDIA demo to a CPU version and then compared the performance of both implementations. However, for educational and logical purposes, the documentation explain the whole process as if the implementations would have been developed from scratch.

Documentation

Real-Time CPU Fluid Dynamics Here is explained how to implement a 2D CPU fluid simulation and interactively display the results. In order to implement a fluid simulation, first, the mathematical foundations of the equations involved in fluids are reviewed.
Real-Time GPU Fluid Dynamics Here is explained how a CPU fluid simulation can have its performance increased by using CUDA, a GPU solution. Before presenting any implementation details we will review some of the CUDA key-points.

CPU vs GPU

The best visual way to compare a CPU, real-time fluid simulation, against the GPU counterpart, is to run a benchmark for both at the same time, and perceive how much faster the GPU simulation outruns the CPU counterpart. This is what is done at the Real-Time Fluid Dynamics: CPU vs GPU demonstrative video.

Downloads

Below, the visitor can find both the NVidia demo as well as the project for ported CPU version. The NVidia demo is a GPU modified version where a benchmark can be executed in order to estimate the fps average.

FluidsGL_CPU.zip CPU port of fluidsGL. Contains source code, profiling results, fps results, and the binaries commented in the documentation results.
FluidsGL_GPU.zip Modified CUDA fluidsGL demo.

Code Repository

If someone wants to improve or fork the CPU code, it is hosted on GitHub. The code is released under the nVIDIA license, as it's a modification of their original CUDA demo.