Problemcore
Fluid simulation for animation
Also called fluid animation.
Produce plausible, controllable motion of smoke, fire and liquids from a domain, sources and boundaries, stable at the large time steps of animation, rather than accurate motion.
Fluid simulation for animation is the problem of making smoke, fire, water and other fluids move on screen. The input is a scene: a domain, the solids in it, the sources of fluid, smoke or heat, and forces such as gravity. The output is the state of the fluid at each frame, which a renderer turns into images. The motion should follow the Navier-Stokes equations closely enough to look like a fluid. But the goals differ from those of computational fluid dynamics in science and engineering. A solver for animation must stay stable at the large time steps that a frame rate allows, must run on grids that are coarse for the detail on screen, and must let an artist steer the result. It is not judged by its error against the true flow. This page defines the problem, lists the methods for it, and gives the costs that limit them.
In plain words
A film needs smoke that curls, water that splashes and fire that flickers. Drawing them by hand is slow, so the computer computes them from the laws of fluids.
The computer cuts space into small cells, or fills the fluid with many particles. Each step it moves the fluid along its own velocity, adds forces such as gravity, and then fixes the velocity so that the fluid does not squeeze into a smaller volume.
An engineer who designs a wing wants the right numbers. An animator wants a result that looks right, does not blow up, and can be changed. So the methods for animation accept large errors in exchange for speed, stability and control. They also add back by hand some of the detail that the coarse grid loses.
Definition
Input.
- A domain with or , and the solids in it, each with a given motion or with a mass that the fluid can push.
- For smoke and fire, the fluid fills . For a liquid, the initial liquid region ; the rest is air, which is usually left out of the solve.
- The initial velocity on the fluid, and fields that the fluid carries, such as a smoke density and a temperature .
- Sources: regions where fluid, smoke or heat enter with a given velocity, and external forces such as gravity, buoyancy or forces that an artist adds.
- The density , the viscosity (often 0 for gases), the frame times and a budget of computing time per frame.
Output. At each frame time , the velocity , the carried fields, and for a liquid the region , given by a surface that a renderer can draw.
Relation. The output should approximately satisfy the incompressible Navier-Stokes equations on the fluid region,
with for each carried field , the condition on solid walls, and for a liquid on the free surface, which moves with the fluid. The equations are in the Eulerian view; particle methods use the same equations in the Lagrangian view.
The requirements are not an error bound. A method should:
- stay bounded for any time step that the user picks, at least as large as one frame, such as s, and often larger than the CFL condition of explicit schemes allows;
- keep the fluid incompressible to a tolerance, so that a liquid keeps its volume;
- be controllable, by parameters with a visible effect and by forces or targets;
- give plausible motion, with the swirls and splashes that a viewer expects.
Cost model. The cost is the time per frame, counted as arithmetic operations on a grid of cells or a set of particles, and the memory. Each step costs at least to touch every cell or particle. The number of steps per frame depends on the time step that stability or accuracy allows.
Against computational fluid dynamics. A finite volume code in engineering solves the same equations, but its goal is a converged and validated answer. It refines the grid until the result stops changing, conserves mass and momentum exactly through the fluxes between cells, chooses the time step for accuracy, and compares with experiments. A solver for animation runs on a fixed coarse grid, takes the largest step that stays stable, uses advection schemes such as semi-Lagrangian tracing that are stable but neither conservative nor accurate, and then adds detail back with terms such as vorticity confinement that change the equations. The smoke solver of Fedkiw, Stam and Jensen (2001) is built on this trade: it accepts a coarse grid and adds vorticity confinement to restore the small swirls that the grid loses.
Variants
- Smoke and gases. The fluid fills the domain; the visible part is a carried density. Buoyancy drives the flow. The main methods are stable fluids and its successors.
- Liquids with a free surface. The fluid region changes, and the method must track the surface between water and air, keep its volume and draw it. Tools are the level set method, the particle level set method, the volume of fluid method and particles.
- Fire and explosions. A reaction front, heat and expansion. See fire simulation.
- Coupling with solids. Solids that move the fluid and are moved by it, as in variational solid-fluid coupling.
- Large water surfaces. Oceans and ponds where only the surface matters: height field water, the shallow water equations and FFT ocean synthesis replace the full 3D problem by a 2D one.
- Real time against offline. Games fix the time per frame and accept small grids. Film work fixes the look and accepts hours per frame.
Examples
A projection by hand. Take two fluid cells side by side in a closed box, with m, kg/m³ and s. The faces on the outer walls have , and the face between the cells has m/s. The left cell has the divergence and the right cell : fluid leaves the first and piles up in the second. The pressure equation for the left cell gives Pa. The update . In a closed box of two cells in a row, the fluid has nowhere to go, and the Chorin projection stops it.
How many steps per frame. Smoke moves at up to 3 m/s on a grid with m, and the frame lasts s. In one frame the fluid crosses cells. An explicit upwind scheme needs a CFL number of at most 1, so it needs 3 steps per frame. Semi-Lagrangian advection stays stable with 1 step, at the price of more smoothing.
A pool at rest. Water 0.5 m deep in a tank, with kg/m³ and m/s², must stay at rest. The projection must return the pressure , which is Pa at the bottom, and zero velocity. A solver that sets a resting pool in motion fails the simplest check.
Known algorithms
- Grids and projection. The marker and cell method of Harlow and Welch (1965) introduced the staggered MAC grid and marker particles. Foster and Metaxas (1996) brought it to graphics, with explicit steps limited by the CFL condition. Stable fluids (Stam 1999) made the step stable for any with semi-Lagrangian advection along the method of characteristics and a pressure projection.
- The projection. The Chorin projection method removes the gradient part of the velocity, by the Helmholtz-Hodge decomposition. It solves a Poisson equation for the pressure, usually with the conjugate gradient method and a preconditioner, or with the multigrid method.
- Less dissipative advection. BFECC, the MacCormack method and the unconditionally stable MacCormack method.
- Detail and forces. Vorticity confinement, Boussinesq buoyancy and the vortex particle method.
- Free surfaces. The level set method with redistancing by the fast marching method, the particle level set method, the ghost fluid method for the pressure at the surface and at other jumps, and marching cubes to extract a mesh for rendering.
- Particles and hybrids. Smoothed particle hydrodynamics with its variants WCSPH, PCISPH, IISPH and DFSPH, position based fluids, and the hybrids PIC, FLIP, APIC and the material point method. Particle surfaces are built by particle fluid surfacing.
- Special cases. Fire, solid-fluid coupling, height field water and FFT oceans.
| Algorithm | Time | Space | Properties | Code |
|---|---|---|---|---|
| Affine particle-in-cell | O(n + k c) step | O(n + c) extra | conserves angular momentumconserves linear momentumdeterministicnot exactkeeps affine fields | 1 language |
| Back and forth error compensation and correction | Θ(g) limiter · step | Θ(g) extra | not conservativedeterministicnot exactunconditionally stable | 1 language |
| Divergence-free SPH | O(n + q) iteration | O(n + q) extra | conserves angular momentumconserves linear momentumdeterministicnot exactiterative | 1 language |
| Tessendorf FFT ocean synthesis | O(N^2 log N) frame | O(N^2) extra | deterministicnot exactnot needs simulationperiodicreal output | 1 language |
| Nguyen-Fedkiw-Jensen fire | Θ(s n) level_set | Θ(n) extra | not conservativedeterministicnot exactnot unconditionally stable | 1 language |
| Fluid-implicit-particle method | O(n + k c) step | O(n + c) extra | not conserves angular momentumconserves linear momentumdeterministicnot dissipativenot exact | 1 language |
| Foster-Metaxas liquid animation | Θ(m) markers | Θ(g + m) extra | deterministicnot exactexplicitnot unconditionally stable | 1 language |
| Height field water | O(c) step | O(c) extra | conserves volumedeterministicnot exactnot overhanging surfacesunconditionally stable | 1 language |
| Implicit incompressible SPH | O(n + q) iteration | O(n + q) extra | conserves angular momentumconserves linear momentumdeterministicnot exactiterative | 1 language |
| Particle-in-cell method | O(n + k c) step | O(n + c) extra | not conserves angular momentumconserves linear momentumdeterministicdissipativenot exact | 1 language |
| Particle level set method | Θ(n + p) advect · correct | Θ(n + p) extra | not conservativerandomizednot exact | 1 language |
| Predictive-corrective incompressible SPH | O(n + q) iteration | O(n + q) extra | conserves angular momentumconserves linear momentumdeterministicnot exactiterative | 1 language |
| Position based fluids | O(n + q) pass | O(n + q) extra | not conserves angular momentumconserves linear momentumdeterministicnot exactiterative | 1 language |
| Stable fluids | Θ(g) advect | Θ(g) extra | not conservativedeterministicnot exactunconditionally stable | 1 language |
| Unconditionally stable MacCormack method | Θ(g) limiter · step | Θ(g) extra | not conservativedeterministicnot exactunconditionally stable | 1 language |
| Variational solid-fluid coupling | Θ(n + m) matvec | Θ(n) extra | deterministicnot exact | 1 language |
| Weakly compressible SPH | O(n + q) step | O(n + q) extra | conserves angular momentumconserves linear momentumdeterministicnot exactnot implicit | 1 language |
Bounds
All bounds are in the RAM model with real arithmetic, for one time step on a grid of cells in dimensions, or particles.
- Lower bound. Every method reads and writes each cell or particle, so a step costs .
- Advection and forces. Semi-Lagrangian advection and the force terms cost per step.
- The pressure solve. The 5-point (7-point in 3D) Poisson matrix has a condition number of order . Unpreconditioned conjugate gradients then need iterations for a fixed reduction of the error, so a solve costs . Multigrid solves the model Poisson problem to a fixed accuracy in , which meets the lower bound. In practice the projection is the most expensive part of a grid step.
- Steps per frame. An explicit scheme needs at least steps per frame for stability. Semi-Lagrangian advection needs one step for stability, but the error grows with the step.
- Particles. With a uniform grid for the neighbor search and a bounded number of neighbors per particle, a step of SPH costs expected time, plus the cost of the pressure iterations.
There is no lower bound on plausibility: the requirements are visual, and no theorem measures them.
Reductions
- Incompressibility to a linear system. The projection reduces to the Poisson equation for the pressure, a sparse symmetric positive semidefinite system, definite when some cell borders air.
- Surface tracking to advection. A free surface is the zero set of a level set, which is moved by the advection equation and kept a signed distance function by solving an Eikonal equation.
- Rendering to isosurfaces. Drawing a liquid reduces to extracting an isosurface, for example with marching cubes.
Applications
Visual effects for film and television use offline solvers on large grids or particle sets for smoke, explosions, fire and water. Games and interactive tools use small grids, particles or height fields at a fixed time per frame. The same solvers drive the motion of other phenomena that act like fluids, such as clouds, sand with the material point method, and crowds of particles in particle systems.
References
- Robert Bridson, Fluid Simulation for Computer Graphics, second edition, CRC Press, 2015, the chapters The Equations of Fluids and Overview of Numerical Simulation (the equations, the splitting into advection, forces and projection, and the time step), and the later chapters on smoke, water and fire
- Nick Foster and Dimitri Metaxas, Realistic animation of liquids, Graphical Models and Image Processing 58(5), 471-483, 1996, the first full 3D Navier-Stokes liquids in graphics, with explicit steps limited by the CFL condition
- Jos Stam, Stable fluids, Proceedings of SIGGRAPH 1999, 121-128, the goal of stability at any time step, and the semi-Lagrangian advection with a pressure projection
- Ronald Fedkiw, Jos Stam and Henrik Wann Jensen, Visual simulation of smoke, Proceedings of SIGGRAPH 2001, 15-22, the introduction and the section on vorticity confinement (a coarse grid with the lost swirls added back)
- Douglas Enright, Stephen Marschner and Ronald Fedkiw, Animation and rendering of complex water surfaces, ACM Transactions on Graphics 21(3), 736-744, 2002 (SIGGRAPH 2002), liquids with a free surface tracked by the particle level set method
- Francis H. Harlow and J. Eddie Welch, Numerical calculation of time-dependent viscous incompressible flow of fluid with free surface, The Physics of Fluids 8(12), 2182-2189, 1965, the staggered grid and the marker particles that most grid solvers for animation still use
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 8ERT4C Edit this page History Report an error Markdown