Game Development Reference
In-Depth Information
locations. This general SPH equation is defined by
n
m j
ρ j A j W ( x
A ( x )=
x j ,h ) ,
(6.1)
j =1
where A ( x ) is an arbitrary quantity A evaluated at location x , A j is the same
quantity A evaluated at the location of a particle j ,and W ( r ,h ) is a smoothing
kernel. The smoothing kernel is a scalar-valued function that smoothes out as the
evaluation position r moves away from the origin. If r is within a distance h ,
called the smoothing radius, the function evaluates to a nonzero value, outside the
radius it evaluates to zero. There are many types of smoothing kernels, some of
which are mentioned in [Muller et al. 03]. We keep h fixed during our simulation.
One of the quantities that can be interpolated by Equation (6.1) in a straight-
forward manner is the density ρ i of a fluid particle i , as defined by the following:
n
n
m j
ρ j ρ j W ( x i
ρ i =
x j ,h )=
m j W ( x i
x j ,h ) ,
(6.2)
j =1
j =1
where we choose W to take the form of W ( r ,h )= 15
/h ) 3 , equal to
the “spiky” smoothing kernel in [Muller et al. 03]. Note that ρ i is never zero, as
the term of the summation where j = i always evaluates to the smoothing norm
15 /πh 3 .
A nice property of Equation (6.1) is that derivatives of the function A ( x ,h )
only affect the smoothing kernel, which makes it possible to evaluate derivatives
of any quantity A , as shown in Equation (6.3). The same also holds for higher
order derivatives, like the Laplacian
πh 3 (1
r
2 .
n
m j
ρ j A j
A ( x )=
W ( x i
x j ,h ) .
(6.3)
j =1
Using this property, it is possible to interpolate internal fluid forces anywhere
within the fluid. As in [Muller et al. 03], we split the force f i acting on particle i
into three components,
f i = f i
+ f i
+ f ext
i
,
(6.4)
where f i
is the pressure force, related to the pressure p ; f i
is the viscous force,
related to the velocity v ;and f ext
i
are external forces like gravity, which we will
not discuss in this chapter.
The equations for f p ( x ) and f v ( x )—the pressure and viscous forces at any
location in the fluid—are derived from the Navier-Stokes equations. Specifically,