Fluid flow is represented with the Navier–Stokes equations. We are trying to simulate the momentum equation. Very often, we assume the fluid is both incompressible and inviscid, allowing us to use the much simpler Euler Equations.

  • Extremely complicated, can only be solved analytically in very simple cases, is difficult to implement, and is computationally intensive
  • We don’t want simulation to become unstable over time

There are many terms in the momentum equation. It’s a pain to handle them all simultaneously. Instead, one strategy is to split up the equation into its terms, and integrate them one after the other. First order accurate in time

Translates to better software design as well, as it naturally leads to separate solution modules for each term.

  1. Resolve advect velocities
  2. Add viscosity
  3. Add gravity
  4. Project velocities to be incompressible
  5. Repeat above steps

Implementations

Height fields

Represents water surface as a continuous 2D function . Discretize surface into grids, apply force to each cell, and the effect of force on the height propagates to neighboring cells using a damped kernel function

Since it’s discrete cells, we might want to use a smooth surface for actual rendering to get rid of the “blocky” appearance

Extremely easy to implement and set up and works well enough for simple use cases

Eulerian grid

In practice, the Eulerian approach discretizes the domain using a grid, defining scalar and vector fields in a grid. On the other hand, the Lagrangian approach treats the fluid as discrete particles, tracks the velocity and acceleration for each individual particle, and applies interaction forces to each

Where to put fluid variables, at the centers of each cell in the grid, or at the corners? Instead, we stagger the grid, placing velocities halfway between grid points

  • Marker-and-cell (MAC) grid is a particular staggering of variables in 2D/3D that works well for incompressible fluids

Lagrangian particle simulation

Lagrangian treats the world like a particle system and the frame of reference changes as the particle moves, while Eulerian “stands still” and measures flow as it goes through the stationary point

Treats fluid as discrete particles, one approach is spherical particle hydrodynamics (SPH) where we consider acceleration from pressure, viscosity, gravity, and external forces for each particle in the fluid

Something about kernel functions what the fuck: one kernel commonly used is the Gaussian kernel. Can be used to determine the “sphere of influence” around the particle, helps with implementations:

  • How close does a particle have to be to be considered a neighbor?
  • Dividing the simulation space into grids to reduce time spent on neighbor space

Has to consider interactions with neighboring particles, there are many approaches to make this computationally efficient like dividing simulation space into 2D/3D grid cells

Hybrid methods

Uses both Lagrangian and Eulerian approaches simultaneously. Two common approaches are particle-in-cell (PIC) and fluid-implicit-particle (FLIP). Allows for fast simulation speed and acceptable accuracy for visual effects

PIC

Transfers particle masses and velocities to a grid, updates grid velocities using grid-based pressure and force values, and then transfers grid velocities back to the particles

  • Calculates kinematics on the particles and dynamics on the grid
  • Major issue is that over time this method develops noise, may dissipate out

FLIP

Follows a very similar approach to PIC but instead of transferring the actual grid velocity back to the particle, we instead transfer the change in updated grid velocity

  • Treats grid as auxiliary step to increment particle variables according to the change computed
  • Achieves almost total absence of numerical dissipation

Surface tracking

At this point we have a simulation, but we haven’t really considered how to render this out. Ideally we want an efficient, accurate representation that:

  • Handles merging/splitting (topology changes)
  • Conserves volume
  • Smooth surface for prettier rendering
  • Provides convenient geometric operations

This is very hard, impossible to do all at once. Some approaches: marker particles, level sets, triangle meshes, and a hybrid of all of these.