Professional Documents
Culture Documents
www.matthiasmueller.info/tenMinutePhysics
a few remarks…
Fluid =
or
liquid gas
Swiss Italian
• We assume incompressibility
inviscid viscous
→ viscous simulation in upcoming tutorial
the method…
Fluid as a Velocity Field on a Grid
𝑢𝑢
• Velocity is a 2d vector 𝐯𝐯 = (vectors are written in boldface)
𝑣𝑣
𝐯𝐯𝑖𝑖,𝑗𝑗
𝑣𝑣𝑖𝑖,𝑗𝑗
ℎ
𝑢𝑢𝑖𝑖,𝑗𝑗 𝑢𝑢𝑖𝑖,𝑗𝑗
𝑣𝑣𝑖𝑖,𝑗𝑗
ℎ
collocated grid staggered grid
Fluid Simulation
𝑣𝑣𝑖𝑖,𝑗𝑗+1
𝑢𝑢𝑖𝑖𝑖𝑖 𝑢𝑢𝑖𝑖+1,𝑗𝑗
𝑣𝑣𝑖𝑖𝑖𝑖
Too much inflow Changing one velocity Push all velocities outward
A fluid cannot do that! by the same amount
Forcing Incompressibility
𝑣𝑣𝑖𝑖,𝑗𝑗+1
𝒅𝒅 ← 𝒖𝒖𝒊𝒊+𝟏𝟏,𝒋𝒋 − 𝒖𝒖𝒊𝒊,𝒋𝒋 + 𝒗𝒗𝒊𝒊,𝒋𝒋+𝟏𝟏 − 𝒗𝒗𝒊𝒊,𝒋𝒋
𝑢𝑢𝑖𝑖,𝑗𝑗 ≠ 0
• Moving object
• Turbine pushing fluid (e. g. wind tunnel)
General Case
𝐯𝐯𝑡𝑡 𝐯𝐯𝑡𝑡+∆𝑡𝑡
𝑝𝑝𝑖𝑖 𝑢𝑢𝑖𝑖,𝑗𝑗
𝑝𝑝𝑖𝑖
moving particle
𝑣𝑣𝑖𝑖,𝑗𝑗
𝑢𝑢𝑡𝑡+∆𝑡𝑡 ← 𝑢𝑢𝑡𝑡
𝑢𝑢𝑡𝑡
𝐱𝐱 − ∆𝑡𝑡 � 𝐯𝐯(𝐱𝐱)
𝑣𝑣𝑖𝑖−1,𝑗𝑗 𝑣𝑣𝑖𝑖,𝑗𝑗
𝑣𝑣̅ = 𝑤𝑤00 𝑤𝑤10 𝑣𝑣𝑖𝑖,𝑗𝑗 + 𝑤𝑤01 𝑤𝑤10 𝑣𝑣𝑖𝑖+1,𝑗𝑗 + 𝑤𝑤01 𝑤𝑤11 𝑣𝑣𝑖𝑖,𝑗𝑗+1 + 𝑤𝑤00 𝑤𝑤11 𝑣𝑣𝑖𝑖+1,𝑗𝑗+1
Smoke Advection
𝐱𝐱 ← start position
𝑠𝑠 ← step size 𝑠𝑠 � 𝐯𝐯(𝐱𝐱 𝟐𝟐 )
𝐱𝐱 𝟑𝟑
𝐱𝐱 𝟐𝟐
for 𝒏𝒏 steps
𝑠𝑠 � 𝐯𝐯(𝐱𝐱 𝟏𝟏 )
𝐯𝐯 ← sampleV(𝐱𝐱)
𝐱𝐱 𝟏𝟏
𝐱𝐱 ← 𝐱𝐱 + 𝑠𝑠𝐯𝐯
Let’s look into the code…