[This sponsored feature, part of Intel's Visual Computing site and written by Dr. Michael J. Gourlay of the University of Central Florida Interactive Entertainment Academy, begins a multi-part series that explains fluid dynamics and its simulation techniques.]
Introduction to Fluid Dynamics
Video games appeal to our desire to explore and interact with our environment, and adding real-world phenomena-such as fluid motion-allows game developers to create immersive and fun virtual worlds. Recently, physical simulations have become more realistic, but the simulations have largely been limited to rigid bodies.
Pervasive simulations of continuous media like cloth and fluids remain uncommon, largely because fluid dynamics entail conceptual and computational challenges that make simulating fluids difficult. This article begins a three-part series that explains fluid dynamics and its simulation techniques. The article culminates in an example of a fluid simulation algorithm suitable for use in a video game.
To get started in fluid simulations, you need to understand the fundamentals of fluid dynamics. Let's start by covering some of the basics.
What Is a Fluid?
A fluid is any substance that flows (in other words, a substance that can take the shape of its container) and does not resist deformation (meaning that it slides when dragged). People often use fluid and liquid interchangeable, but technically, the term fluid can refer to either a liquid or a gas. A gas fills its container completely, whereas a liquid has a distinct "free surface" whose shape does not depend on its container. (Often, when you use computer graphics to visualize a liquid, you render only its surface-for example, ripples on a pond or a stream of water.) The distinction between liquids and gasses can influence how you model the fluid, but both obey the same basic fluid formulae and share similar properties.
But what about smoke? Smoke seems to behave like a gas but also appears to have a kind of surface, although perhaps not as distinct as that of a liquid. The answer is that smoke is really a combination of a gas and tiny suspended particulates, and the combination of these particulates is called an aerosol. Those particulates follow the motion of the gas (and let game players see that motion) without necessarily influencing the motion. You can usually treat smoke as a kind of gas, where one of its properties-for example, density or composition-varies.
Varieties of Physical Simulation
Whereas fluid dynamics might not be as familiar to most video game programmers, some forms of physical simulation have become commonplace. For the sake of context, let's see where fluid simulations fit into the spectrum of physical phenomena:
Particles are points that have position, mass, and velocity but (in principle) no size or shape, as Figure 1(a) shows. The relationship between forces and motion is linear. Particles are easy to simulate but rather uninteresting.
Rigid bodies have shape and orientation in addition to position, mass, and velocity-for example, blocks and balls. If you add the notion of "shape" to a particle, you get a rigid body, as Figure 1(b) shows. Rigid bodies are still easy to simulate: Most of the difficulty comes from detecting and responding to collisions. Stacks of bodies are usually the most difficult to solve, because everything in the stack continuously collides with everything else in the stack-even if nothing moves.
Articulated bodies, shown in Figure 1(c), are connected networks of rigid bodies-for example, character models. These bodies behave identically to rigid bodies that are continuously involved in a form of collision where the points of contact have a limited variety of ways in which they can move (called constraints).
Figure 1. Simple physical phenomena: (a) particles, (b) rigid bodies, and (c) articulated bodies
Deformable bodies can change shape but retain their connectedness and adjacency of various points on the body. Think of this as a model where the edges between vertices never change which vertices they connect, but the locations of the vertices can move. Their type depends on their dimensionality:
- 1D. Thread, string, rope, chain, hair, and so on, shown in Figure2(a)
- 2D. Cloth, as shown in Figure2(b)
- 3D. Soft bodies, like the jiggly bits of a character model, as shown in Figure2(c)
Figure 2. Deformable bodies: (a) thread, (b) cloth and (c) soft bodies.
Fluids have lots of freedom of motion. The motion is nonlinear (more on that later), and their shape and topology can change, as shown in Figure 3. Fluids require specialized simulation techniques: Because fluids take the shape of their container, they are always in collision with everything around them, including the fluid itself. So a collision with one part of the fluid effectively means that the whole body of fluid must respond.
Figure 3. Fluids: (a) liquid and (b) smoke.