Gamasutra is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Sponsored Feature: Fluid Simulation for Video Games (Part 2)
July 24, 2021
July 24, 2021
Press Releases
July 24, 2021
Games Press

If you enjoy reading this site, you might also want to check out these UBM Tech sites:

Sponsored Feature: Fluid Simulation for Video Games (Part 2)

October 28, 2009 Page 5 of 5

Interactions with Bodies: Boundary Conditions

Solving PDE's also entails satisfying boundary conditions, meaning that the flow must obey certain rules at boundaries. The previous article described canonical cases, and Figure 10 catalogs various boundary conditions.

Figure 10: Boundary conditions. (a) No-through, (b) no-slip, (c) free-slip, and (d) periodic.

Simulations can satisfy boundary conditions either explicitly or implicitly. A simulation can explicitly satisfy boundary conditions either by incorporating them into the system of linear algebraic equations resulting from the discretization or by applying a post-process each step. The advection step can result in a preliminary solution that violates boundary conditions(for example, can have flow through or across a rigid body, which is physically impossible). Various techniques exist to resolve that problem. The simplest is to overwrite the fluid values at the boundaries and let the subsequent evolution steps propagate that change away. That treatment is not accurate but can suffice for visual effects. Be aware, though, that such abrupt changes can introduce instability to the simulation.

Alternatively, simulations can represent the solution in a way that it always satisfies boundary conditions. This can usually only be done in special cases -- for example, by using spectral methods where the interpolating functions have the desired values at boundaries. Such schemes are probably too restrictive for use in video games, which likely have objects with arbitrary (possibly changing) shape moving through the fluid.

Satisfying boundary conditions is, in principle, a two-way interaction. Bodies in the fluid affect the flow, and the flow also affects the bodies. In practice, this two-way coupling occurs in separate steps. The fluid simulation provides forces applied to rigid bodies immersed in the fluid either by computing the pressure gradient at the body surface or by using conservation of linear and angular momentum to compute impulses applied by fluid particles. Then, a separate rigid body simulator can apply those forces or impulses to the bodies and proceed as usual.

Parallelization

Using a localized physical model expedites parallelizing fluid simulation; any aspects of the simulation that require global solutions (that is, solutions that affect the entire simulation domain simultaneously) will impede parallelization. Sharing memory across threads simplifies parallelization. Distributed memory systems (such as the IBM CELL architecture) require more sophistication.

Particle-based methods readily parallelize, because you can update the motion of each particle independently from the others. Each particle could, in principle, run in its own thread. For vorton methods, this assumes that the interaction tree contains all the information needed from the original particles before updating any particles, which you can readily arrange.

Mesh-based methods readily parallelize for the same reason particle-based methods do: The simulation algorithm can update each cell independently. In practice, this entails using a numerical linear algebraic solver that stores the output in a different vector than the input, effectively double-buffering the data. Although this requires more memory, it makes parallelization easier. Note that this imposes some prejudice against the Gauss-Seidel method, which uses partially updated information during the solver; although that improves convergence speeds in a serial process, it creates contention in parallel processes.

Summary

Simulating fluid motion entails converting continuous equations into simpler discrete equations and using numerical techniques to solve the discretized equations. Spatial discretizations include grid-based and mesh-free methods. Simulations employ techniques for interpolating values between nodes, approximating spatial derivatives and evolving the simulation forward in time, meanwhile satisfying boundary conditions. Fluid simulations also provide the means to provide forces acting on bodies embedded in the fluid, which a separate rigid body simulator can apply.

The next article in this series presents a mesh-free vortex particle fluid simulation suitable for use in a video game.

Stam, J. (1999): "Stable Fluids", SIGGRAPH 99 Conference Proceedings, Annual Conference Series, August.

Cottet & Koumoutsakos (2000): Vortex Methods: Theory and Practice. Cambridge University Press.

Li & Liu (2004): Meshfree Particle Methods. Springer-Verlag.

Bridson (2008): Fluid Simulation for Computer Graphics.  A.K. Peters.

Page 5 of 5

Related Jobs

Insomniac Games — Burbank, California, United States
[07.23.21]

Technical Artist - Pipeline
Insomniac Games — Burbank, California, United States
[07.23.21]

Engine Programmer
Insomniac Games — Burbank, California, United States
[07.23.21]

Character TD
Legends of Learning — Baltimore, Maryland, United States
[07.23.21]

Senior Gameplay Engineer - \$160k - Remote OK