Graphics Reference
In-Depth Information
8.2.3
Grid-based approach
The basic process for computing fluid dynamics using a grid-based (Eulerian) approach is to do the
following:
Discretize the fluid continuum by constructing a grid of cells that, collectively, cover the space
occupied by the fluid and at each node (cell), the fluid variables (e.g., density and velocity) are
approximated and used to initialize the grid cells.
Create the discrete equations using the approximate values at the element.
Numerically solve the system of equations to compute new values at the cells using a Newton-like
method for the large, sparse system of equations at each time step.
Before solving these equations, boundary conditions must be set up to handle the cells at the limits of
the domain. For example, the
Dirichlet boundary condition
, which sets solution values at the boundary
cells, is commonly used. The CFD equations, set up for each cell of the grid, produce a sparse set of
matrix equations. There are various ways to solve such systems. For example, LU and Conjugate Gra-
dient solvers are often used. Efficient, accurate methods of solving symmetric and asymmetric sparse
matrices, such as these, are the topic of ongoing research. Thankfully, in computer animation believ-
ability is more of a concern than accuracy, so approximate techniques typically suffice.
Stable fluids
Stam presents a method that solves the full NS equations that is easy to implement and allows real-time
user interaction [
17
]
. Although too inaccurate for engineering, it is useful in computer graphics appli-
cations. In particular, the procedures are designed to be stable more than accurate while still producing
interesting visuals. The procedures operate on a velocity vector field and density field. The velocity
field moves the density values around.
Density update
Density values are moved through the density grid assuming a fixed velocity field over the time step.
The density equation
(Eq. 8.40)
states that density (
r
) changes over time according to density sources
(
s
), the diffusion of the density at some specified rate (
k
), and advection of the density according to the
velocity field (u).
@r
2
@t
¼ s ¼ kr
r
ð
u
r
Þr
(8.40)
In implementing stable fluids, density is kept in an array of scalars. The first term,
s
, is an array of
density sources set by user interaction or by the environment. These are used to initialize the new den-
sity grid at each time step. The second term diffuses the density from each cell to its adjacent cells. The
diffusion of the grid can be solved by relaxation. The third term advects the density according to the
velocity field.
To diffuse, each cell is updated by a weighted average of its four neighbors added to the original
value. Each neighboring value is multiplied by
a
where
a¼dt
*
diff
*
N
*
N
, where
diff
is a user-supplied
parameter, and
N
is the resolution of the grid. This sum is added to the cell's original value and then this
sum is divided by 1
þ 4
*
a
.
To advect, the position is interpolated backward according to the velocity field. In the simplest case,
the velocity vector at the particle position is accessed and linearly stepping backward according to the
Search WWH ::
Custom Search