Real-Time Fluid Dynamics Simulation
Find out more at: github
This is a C++ implementation of Jos Stam’s “Real-Time Fluid Dynamics for Games” algorithm, paired with an OpenGL renderer for interactive visualization. As the simulation runs, users can click and drag to add forces or introduce more fluid, instantly altering the flow and density fields.
The core logic is a grid-based solver for the Navier–Stokes equations, designed for real-time performance. Each time step updates velocity and density through advection (moving existing fluid quantities), diffusion (simulating viscosity or natural spreading), and projection (maintaining incompressibility).
This simulation provides features such as adjustable viscosity and flow strength, letting you observe how changes in parameters create different fluid behaviors. The OpenGL-based rendering ensures that changes are visible immediately, while the C++ implementation is optimized to keep frame rates high even under continuous user interaction.
To add forces, click and drag with the left mouse button. To inject extra fluid density, right-click in the simulation window. These interactions update the solver in real time, producing a dynamic and visually engaging flow.
Below is a quick demonstration of the simulation in action:

For more details on the algorithm, refer to Jos Stam’s original paper .
This project is licensed under the MIT License. See the LICENSE file for details.