Graphics Reference
In-Depth Information
method we've been using so far:
u
A
= advect(
u
n
,
Δ
t, u
n
)
,
w
A
= advect(
u
n
,
Δ
t, w
n
)
,
d
A
= advect(
u
n
,
Δ
t, d
n
)
.
We then compute the intermediate height field
h
A
=
b
+
d
A
and extrapolate
it to non-fluid cells, i.e., setting
h
equal to the value in the nearest fluid
cell. Note that it is important to extrapolate height
h
, not depth
d
,aswe
want to make sure water sitting still on a sloped beach, for example, will
remain still. We then update the velocities with the pressure acceleration:
Δ
tg
h
i
+1
,k
−
h
i,k
u
n
+1
i
+1
/
2
,k
=
u
i
+1
/
2
,k
−
,
Δ
x
Δ
tg
h
i,k
+1
−
h
i,k
w
n
+1
i,k
+1
/
2
=
w
i,k
+1
/
2
−
.
Δ
x
We extrapolate these velocities to non-fluid cells as usual and finally update
the depth with the divergence term:
u
n
+1
.
u
n
+1
i−
1
/
2
,k
w
n
+1
w
n
+1
i,k−
1
/
2
i
+1
/
2
,k
−
i,k
+1
/
2
−
d
n
+1
i,k
=
d
i,k
−
Δ
td
i,k
+
Δ
x
Δ
x
That's all there is to it!
There is a stability time-step restriction here, however. A simple anal-
ysis in the same vein as the approximations made in Section 12.2 to get to
the wave equation can be made, showing that for stability we require
Δ
x
√
gD
,
Δ
t
where
D
is the maximum depth value in the simulation.
For safety a
fraction of this quantity, such as 0
.
2, should be used.