Fluid dynamics
Math background Physics Simulation Related phenomena Frontiers in graphics Rigid fluids
Fields Domain Ω R2 Scalar field f :Ω R Vector field f : Ω R2
Types of derivatives Derivatives measure how something changes due to its parameters Temporal derivatives Spatial derivatives gradient operator divergence operator Laplacian operator f t f = [ f x, f y ] T f = f x x + f y y 2 f = ( f) = 2 f x + 2 f y
Math background Physics Simulation Related phenomena Frontiers in graphics Rigid fluids
Representation Density ρ :Ω [0, 1] Domain Ω Velocity u :Ω R 3
Coffee cup equation Navier-Stokes Momentum equation u t = (u )u 1 ρ p + s 2 u + f Incompressibility condition u =0 u: velocity p: pressure s: kinematic viscosity f: body force ρ: fluid density
Momentum equation Each particle represents a little blob of fluid with mass m, a volume V, and a velocity u The acceleration of the particle a Du Dt The Newton s law m Du Dt = F
Forces acting on fluids Gravity: mg Pressure: - p Imbalance of higher pressure Viscosity: µ u Force that makes particle moves at average speed dynamic viscosity coefficient: µ
Momentum equation The movement of a blob of fluid m Du Dt Divide by volume ρ Du Dt = mg V p + Vµ u = ρg p + µ u Rearrange equation giving Navier-Stoke Du Dt + 1 p = g + s u ρ
Lagrangian v.s. Eulerian Lagrangian point of view describes motion as points travel around space over time Eulerian point of view describes motion as the change of velocity field in a stationary domain Lagrangian approach is conceptually easier, but Eulerian approach makes the spatial gradient easier to compute/approximate
Material derivative Dq Dt = q t + u q x + v q y + w q z d q(t, x) = q dt t = q t + q u = Dq Dt + q dx dt
Advection Advection describe how quantity, q, moves with the velocity field u Density Velocity Dρ Dt = ρ t + u ρ Du Dt = u t + u u
Advection momentum equation Du Dt + 1 p = g + s u ρ Advection Projection Diffusion Body force u t = (u )u 1 ρ p + s 2 u + f u =0
Density advection ρ t = (u )ρ
Velocity advection u t = (u )u 1 ρ p + s 2 u + f s.t. u =0
Projection Advection Projection Diffusion Body force u t = (u )u 1 ρ p + s 2 u + f u =0
Divergence free u > 0? u < 0?
Divergence free u = 0
Projection u t = (u )u 1 ρ p + s 2 u + f s.t. u =0
Diffusion Advection Projection Diffusion Body force u t = (u )u 1 ρ p + s 2 u + f u =0
High viscosity fluids
Dropping viscosity Viscosity plays a minor role in most fluids Numeric methods introduce errors which can be physically reinterpreted as viscosity Fluid with no viscosity is called inviscid
Body force Advection Projection Diffusion Body force u t = (u )u 1 ρ p + s 2 u + f u =0
External forces Gravity Heat Surface tension User-specified forces (stirring coffee)
Boundary conditions Solid walls The fluid cannot go in and out of it Control the normal velocity Free surfaces Air can be represented as a region where the pressure is zero Do not control the velocity at the surface
Solid boundary Velocity at the boundary u ˆn = u solid ˆn No-slip condition: u = u solid Pressure at the boundary Make the fluid incompressible AND enforce the solid boundary condition
Physics recap Physical quantity represented as fields Navier-Stokes PDE describes the dynamics
Math background Physics Simulation Related phenomena Frontiers in graphics Rigid fluids
Challenges What is the representation for fluids? represent velocity and pressure What is the equation of motion for fluids? approximate Navier-Stokes in a discrete domain compute Navier-Stokes efficiently
Grid structure p i,j+1 v i,j+1/2 p i 1,j u i 1/2,j p i,j u i+1/2,j p i+1,j v i,j 1/2 p i,j 1
Explicit integration Solving for the differential equation explicitly, namely u t = (u )u 1 ρ p + s 2 u + f u t+1 = u t + h u(t) You get this...
Explicit integration
Stable fluids Invented by Jos Stam Simple, fast, and unconditionally stable
Splitting methods Suppose we had a system x t = f(x) =g(x)+h(x) We define simulation function S f S f (x, t) :x(t) x(t)+ tf(x) Then we could define S f (x, t) :x(t + t) =S g (x, t) S h (x, t)
Splitting methods u t = (u )u 1 ρ p + s 2 u + f w 0 = u(x, t) add force Advect Diffuse Project w 0 (x) w 1 (x) w 2 (x) w 3 (x) w 4 (x) u(x, t+δt) = w 4
Splitting methods u t = (u )u 1 ρ p + s 2 u + f w 0 = u(x, t) add force Advect Diffuse Project w 0 (x) w 1 (x) w 2 (x) w 3 (x) w 4 (x) u(x, t+δt) = w 4
Body forces
Splitting methods u t = (u )u 1 ρ p + s 2 u + f w 0 = u(x, t) add force Advect Diffuse Project w 0 (x) w 1 (x) w 2 (x) w 3 (x) w 4 (x) u(x, t+δt) = w 4
Advection
Numerical dissipation Semi-Lagrangian advection tend to smooth out sharp features by averaging the velocity field The numerical errors result in a different advection equation solved by semi-largrangian q t + u q x = u x 2 q x 2 Smooth out small vortices in inviscid fluids
Splitting methods u t = (u )u 1 ρ p + s 2 u + f w 0 = u(x, t) add force Advect Diffuse Project w 0 (x) w 1 (x) w 2 (x) w 3 (x) w 4 (x) u(x, t+δt) = w 4
Diffusion Solve for the effect of viscosity w 2 t = ν 2 w 2 Use an implicit method for stable result (I ν t 2 )w 3 (x) =w 2 (x)
Splitting methods u t = (u )u 1 ρ p + s 2 u + f w 0 = u(x, t) add force Advect Diffuse Project w 0 (x) w 1 (x) w 2 (x) w 3 (x) w 4 (x) u(x, t+δt) = w 4
Projection P( )
Projection Projection step subtracts off the pressure from the intermediate velocity field w 3 w 4 = w 3 t 1 ρ p project(δt, u) must satisfies two conditions: divergence free: u t+1 =0 boundary velocity: u t+1 ˆn = u solid ˆn
Boundary conditions Dirichlet boundary condition for free surfaces Neumann boundary condition for solid walls u t+1 i+1/2,j = u i+1/2,j t 1 ρ since p i+1,j p i,j x u t+1 i+1/2,j = u solid p i,j u i+1/2,j p i+1,j p i+1,j = p i,j + ρ x t (u i+1/2,j u solid )
Divergence-free condition p i,j+1 u t+1 i+1/2,j ut+1 i 1/2,j x + vt+1 i,j+1/2 vt+1 i,j 1/2 x =0 replace u t+1 i+1/2,j (and other terms) v i,j+1/2 p i 1,j p i,j p i+1,j u i 1/2,j u i+1/2,j with u i+1/2,j t 1 ρ p i+1,j p i,j x v i,j 1/2 p i,j 1 result in a discrete Poisson equation t ρ ( ) ( 4pi,j p i+1,j p i,j+1 p i 1,j p i,j 1 ui+1/2,j u i 1/2,j x 2 = x + v i,j+1/2 v i,j 1/2 x )
The pressure equations If grid cell (i, j + 1) is in air and (i+1, j) is a solid p i,j+1 v i,j+1/2 replace p i,j+1 with zero p i 1,j u i 1/2,j p i,j u i+1/2,j p i+1,j t ρ replace p i+1,j with the value from Neumann condition p i,j + ρ x t (u i+1/2,j u solid ) 0 ( ) ( 4pi,j p i+1,j p i,j+1 p i 1,j p i,j 1 ui+1/2,j u i 1/2,j x 2 = x v i,j 1/2 p i,j 1 + v i,j+1/2 v i,j 1/2 x )
Solve a linear system Ap = b Construct matrix A: diagonal entry: # of non-solid neighbors off-diagonal: 0 if the neighbor is non-fluid cell and -1 if the neighbor is fluid cell A is symmetric positive definite Use preconditioned conjugate gradient