Vulkan Fluid Dynamics - Week 4

I’m about halfway done integrating a fluid dynamics simulation implementation from Dr Michael Gourlay’s great article series.


Update history:



Learning about the algorithms and reading the source code behind simulating fluid dynamics has been a challenging and rewarding part of this weeks’ work. I’m going to share what I’ve learned in my own words (visit the source for more):

1. Fluids are not always liquid


Fluid dynamics is the interaction of a fluid substance with itself and the environment. Fluid substances are not all liquid; a fluid is considered to be any substance that flows (it can take the shape of its container) and does not resist deformation (it slides when dragged). In the image above, both the liquid in the glass (a) and the smoke (b) are considered fluid.

2. There are two major ways of approximating fluid dynamics


Mathmatical representations of fluid dynamics simulations are much more complex than something like rigid body physics, so various approximation models have been developed. The two primary categories are:

  1. Field (a): for every point in a static (non-moving) field or grid containing fluid, properties like density, temperature, and pressure are stored. Objects being influenced by fluid dynamics then pass through the grid and are influenced based on their distance to the points in the grid.

  2. Particle (b): a fluid can be thought of as a collection of particles that move around. These particles have fluid properties in addition to position.

Vorticity is the characteristic that gives fluid dynamics its classic motion


Vorticity is a property of fluid dynamics that describes how the fluid rotates. Examples of this are how tornadoes spin or how water flows down a drain. In the image above, (a) represents a line vortex (the purple line) and the flow around it (the black lines), while (b) represents a ring vortex (the purple line) and the “jet” flow through it (black lines).


Dr. Gourlay uses a hybrid approach of field and particle approximations for his simulation. When considering vortexes, vorticity, and vortons (vortex particles), a particle or mesh-free approach is used. For computing velocity and searching for nearest neighbors, a grid-based approach is used.




When considering fields, the importants of a grid structure is very important. For example, consider the following image:


In (a), the flow of a vortex field is represented using a uniform grid. For some parts of the simulation, uniform grids work perfectly fine, but for store potentially hundreds of thousands of vortex particles, the memory usage becomes a problem. This necessitates the need for a spatial partitioning system. Dr. Gourlay uses the concept of a nested grid, where each grid can be subdivided into smaller grids. In practice, it acts similar to image (b). See below for a more accurate visualization of nested grids.


In the image at the top of the page, I have a simple output of a 2d grid system.


There is more work to be done. For the next update, I’d like to have the full grid system and vortex fluid dynamics implemented. The image below is a sample of what kind of simulation I’d like to have done. The code is still a work in progress, but as always, you can find the source on GitHub.


Update history: