Back to main page

Eulerian fluid in a MAC grid

C++ - [2024]

Introduction

Since I was a child I have always been very attracted to the fluids in video games. Especially the most interactive part of the mimes (When an object falls, it splashes, or moves in ways similar to how they do in reality).

That's why I took the master's degree I did, to be able to get some day how these effects are composed and program them. That's why I decided to expand the class material and create this little demo that simulates an eulerian icompressible fluid.

Results

Below you can see a small demo of a smoke emitter that varies the direction in which it emits smoke. Because this code is parallelized it is possible to obtain real time executions.

In this simulation, RGB dye emission, advection (transport) of the different fluid properties, viscosity, gravity and calculation of pressures are implemented to project the fluid to an incompressible state. Additionally, demos have been designed to get the most out of the technology, like this demo that I think catches the viewer's attention.

Advection

Different techniques are used to simulate advection, in the world of computer graphics we usually use simplex Euler integration, Runge Kutta 4, or even substeps.

Euler symplectic Runge-Kutta 4 Euler substeps

As an extra, and in order to find out how, and how much, it affected using one or the other technique, I decided to implement all 3 and check the results.

At a first glance we can see how the choice of one integration method or another has an immediate impact on the final appearance of the integration. So it is convenient to choose more elaborate methods than Euler simplex, if we don't want to get too much error in our simulations.

Download

GitHub Source Code.

Back to main page