Graphics Reference
In-Depth Information
That is, we'll work out methods for solving these simpler equations:
Dq
Dt
= 0
(advection)
,
(2.8)
∂u
∂t
=
g
(body forces)
,
(2.9)
∂u
∂t
+
1
ρ
∇
p
=0
such that
∇·
u
=0
.
(pressure/incompressibility)
(2.10)
We used the generic quantity
q
in the advection equation because we may
be interested in advecting other things, not just velocity
v
.
Let's call our algorithm for solving the advection, Equation (2.8),
advect
(
u,
Δ
t, q
): it advects quantity
q
through the velocity field
u
for
atimeintervalΔ
t
. Chapter 3 will cover how to do this.
For the body force, Equation (2.9), we'll just use forward Euler:
u
←
u
+Δ
tg
.
For the pressure/incompressibility part, Equation (2.10), we'll develop
an algorithm called
project
(Δ
t, u
) that calculates and applies just the
right pressure to make
u
divergence-free and also enforces the solid wall
boundary conditions. Chapter 4 deals with this part (and explains the odd
choice of word, “project”).
The important precondition/guarantee issue we mentioned in the pre-
vious section is that advection should only be done in a divergence-free
velocity field. When we move fluid around, if it's going to conserve volume,
then the velocity field that we are moving it in must be divergence-free:
we covered that already in Chapter 1. So we want to make sure we only
run
advect
() with the output of
project
(): the sequence of our splitting
matters a lot!
Putting it together, here is our basic fluid algorithm:
Start with an initial divergence-free velocity field
u
0
.
•
•
For time step
n
=0
,
1
,
2
,...
•
Determine a good time step Δ
t
to go from time
t
n
to time
t
n
+1
.
Set
u
A
=
advect
(
u
n
,
Δ
t, u
n
).
•
Add
u
B
=
u
A
+Δ
tg
.
•
Set
u
n
+1
=
project
(Δ
t, u
B
).
•