Graphics Reference
In-Depth Information
4.1 The Discrete Pressure Gradient
The raison d'etre of the MAC grid, as we briefly discussed before, is that the
staggering makes accurate central differences robust. For example, where
we need to subtract the ∂/∂x -component of the pressure gradient from the
u -component of velocity, there are two pressure values lined up perfectly on
either side of the u -component just waiting to be differenced. You might
want to keep referring back to Figure 2.1 to see how this works.
So without further ado, here are the formulas for the pressure update
in two dimensions, using the central difference approximations for ∂p/∂x
and ∂p/∂y :
Δ t 1
ρ
p i +1 ,j
p i,j
u n +1
i +1 / 2 ,j = u i +1 / 2 ,j
,
(4.1)
Δ x
Δ t 1
ρ
p i,j +1
p i,j
v n +1
i,j +1 / 2 = v i,j +1 / 2
,
(4.2)
Δ x
and in three dimensions, including ∂p/∂z too:
Δ t 1
ρ
p i +1 ,j,k
p i,j,k
u n +1
i +1 / 2 ,j,k = u i +1 / 2 ,j,k
,
(4.3)
Δ x
Δ t 1
ρ
p i,j +1 ,k
p i,j,k
v n +1
i,j +1 / 2 ,k = v i,j +1 / 2 ,k
,
(4.4)
Δ x
Δ t 1
ρ
p i,j,k +1
p i,j,k
w n +1
i,j,k +1 / 2 = w i,j,k +1 / 2
.
(4.5)
Δ x
Note that these pressure updates apply to every velocity component that
borders a grid cell that contains fluid. One of the trickiest parts of making
the pressure solve is keeping track of which velocity and pressure samples
are “active,” so it's good to keep this in mind or perhaps keep a diagram
near you when you program.
In later sections we'll work out how to determine the pressure in the
grid cells that contain fluid. However, we immediately have a problem with
the formulas above. On boundary faces of the fluid region, they involve
pressures in grid cells that lie outside of the fluid region. Thus, we need to
specify our pressure boundary conditions. We will for now assume that grid
cells can be simply classified as fluid cells (ones that contain fluid), solid
cells (ones that are fully occupied by a solid), or air cells (ones that have
nothing in them—as in free surface water simulations). We'll postpone
dealing with cells that are only partially filled with solid and/or fluid: for
now we'll assume our solids line up with the grid perfectly, and we ignore
the exact mix of air and water in grid cells at the free surface and just label
them as fluid cells.
Search WWH ::




Custom Search