Graphics Reference
In-Depth Information
-3-
Advection Algorithms
In the previous chapter we saw that a crucial step of the fluid simulation
is solving the advection equation
Dq/Dt
=0
.
We will encapsulate this in a numerical routine
q
n
+1
=
advect
(
u,
Δ
t, q
n
)
,
which given a velocity field
u
(discretized on a MAC grid), a time step
size Δ
t
, and the current field quantity
q
n
returns an approximation to the
result of advecting
q
through the velocity field over that duration of time.
It bears repeating here: advection should only be called with a
divergence-free velocity field
u
, i.e., one meeting the incompressibility con-
straint. Failure to do so can result in peculiar artifacts.
3.1 Semi-Lagrangian Advection
The obvious approach to solving
Dq/Dt
for a time step is to simply write
out the PDE, e.g., in one dimension:
∂q
∂t
+
u
∂q
∂x
=0
and then replace the derivatives with finite differences. For example, if we
use forward Euler for the time derivative and an accurate central difference
for the spatial derivative we get
q
n
+1
i
q
i
+1
−
q
i−
1
2Δ
x
q
i
−
+
u
i
=0
,
Δ
t
which can be arranged into an explicit formula for the new values of
q
:
q
i
+1
−
q
i−
1
2Δ
x
q
n
+1
i
=
q
i
−
Δ
tu
i
.
27