Professional Documents
Culture Documents
GPU Fluid PDF
GPU Fluid PDF
GPU Fluid PDF
Outline
Navier-Stokes Equations
p +{
2u + f{ (2)
(
)
u
u
24
3
t 14
advection
123 diffuse external
force
pressure
u(x, t ) : velocity of fluid (vector field);
: density of fluid (constant); p (x, t ) : pressure (scalar field);
v ( x, t )
y
NotationVector Calculus
d
m(t ) = acting forces
dt
11 12 13
where n : surface normal; = 21 22 23 for 3D cases.
31 32 33
Transport theorem
For a differentiable scalar field f : t [0, tend ] ,
d
f
(
x
,
t
)
d
x
f
(
x
,
t
)
div
(
f
(
x
,
t
)
u
)
+
dx
dt t
t
u) f div( ) = 0
( u) + u (u) + u(
{
t
0
1
u = u (u) + div( ) +
f{
1424
3
t
advection
1
424
3 external force
pressure, diffuse
u
1
= (u )u p + {
2u + f{
24
3
t 14
advection
123 diffuse external
pressure
The velocity of
the fluid carries
itself along
Pressure in the
fluid leads to
acceleration
force
Internal friction
results in diffusion
in the momentum
Helmholtz-Hodge Decomposition
w = u + q, where u = 0
w = q
2
u = P( w ) = w q
(3)
Helmholtz-Hodge Decomposition
u
2
= P( (u )u + u + f )
t
(4)
Outline of Solution
y
v ( x, t )
force
w 0 (x) add
w1 (x) advect
w 2 (x) diffuse
w 3 (x) project
w 4 (x)
Storage
2D example:
External Force
u
=f
t
w1 (x) = w 0 (x) + tf (x, t )
w 2 (x) = w1 (p(x, t ))
p(x,t ) : the location of x a time t ago,
according to the velocity field
Advection
w1 as input texture
Compute p(x, t) in fragment
shader
Perform 4 texture look-ups on
w1 and interpolate
v = f (x),
2
where 2 =
q = w3
2
w 4 = w 3 q
vN vb
v( x)
= f ( x), 0 x 1, v(0) = va , v(1) = vb
N/(N+1) 1
0 1/(N+1)
x 2
v v
v v
1
h=
, let vn = v(nh). vi i i 1 ; vi +1 i +1 i .
x
x
N +1
h
h
f1
2 1 0 L 0 v1 va
1 2 1 O M 0
2
2vi + vi 1 + vi +1
2
Therefore 2 vi
, and 0 O O O 0 M M h M .
x
h2
0
M
O
O
O
1
f N
0 L 0 1 2 v N vb
{
1444424444
3
TN
It can be extended to 2D or 3D
(TN )
4( N + 1) 2
Boundary Conditions
Boundary Conditions
u 0, j + u1, j
u 0, j
=0
2
= u1, j
Boundary Conditions
1024x1024,
13 fps
Performance
ReferenceNavier-Stokes Equations
Lattice GeometryD3Q19
ei, i = 0, 1, , M
ni(x, t), i = 0, 1, , M
x: location of the node; t: time
true iff there is a particle moving in this direction
collision
fi = <ni>
The density of particles that have a given velocity
i = 0, 1, ..., M
collision
= fi ,
i =1
u = f i ei
i =1
i =1
= 0,
e
i =1
i i
=0
new
(x, t ) = f i (x, t ) + i
Collision
f i eq +
{
equilibrium
M
= fi ,
eq
i =1
0 = fi
i =1
neq
f i neg
{
nonequilibrium
M
u = f i eqe i
i =1
M
0 = f i neq ei
i =1
Collision
i = ( f i (x, t ) f i eq ( , u))
Boundary Condition
x f xw
x f xb
Constant
determining
viscosity
Velocity of
the wall
Flow chart
GPU ImplementationStorage
GPU ImplementationStorage
new
fi (x)= fi(x-ei)
new
For example, f (1, -1, 0)(x) = f(1, -1, 0)(x-(1, -1, 0))
GPU ImplementationBoundary
GPU ImplementationBoundary
We still need =
x f xw
x f xb
Boundary
Define
flag1 = ( pos x , pos y , pos z ,1) ( A, B, C , D ) (distance to the boundary surface)
flag 2 = ( A, B, C ) ei
Boundary
Boundary
Note that each pass will check for all four textures f0~f4
Boundary
Outside voxels moves
inward in passes 2 & 3
Flag1 < 0
Flag2 > 0
ei
Flag1 > 0
ej
Flag1 < 0
ei
Flag2 > 0
Inside voxels moves
outward in passes 2 & 3
Flag2 < 0
ej
Ax+By+Cz+D=0
Flag1 > 0
Flag2 < 0
Boundary
Direction of
(A, B, C)
x w xb
x
xf
xw
xb
flag1
=
flag 2
x f xb
x w xb
flag2
flag1
In triangle x b x w x' ,
flag1
= 1
= 1
flag 2
x f xb
Ax+By+Cz+D=0
Li, W., Fan, Z., Wei, X., and Kaufman, A. GPU-Based Flow
Simulation with Complex Boundaries. Technical Report 031105,
Computer Science Department, SUNY at Stony Brook. Nov 2003.
Chen, S. and Doolean, G. D. Lattice Boltzmann Method for Fluid
Flows. Annu. Rev. Fluid Mech. 30, 329-364. 1998.
Wolf-Gladrow, D. A. Lattice-Gas Cellular Automata and Lattice
Boltzmann Models: An Introduction. Springer-Verlag. 2000.
Mei, R., Shyy, W., Yu, D., and Luo, L.-S. Lattice Boltzmann Method
for 3-D Flows with Curved Boundary. Journal of Comp. Phys. 161,
680-699. 2000.
Future Work