Your SlideShare is downloading. ×
0
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Basic fluids
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Basic fluids

583

Published on

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total Views
583
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
35
Comments
1
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. F LUID S IMULATION Robert Bridson, UBC Matthias Müller-Fischer, AGEIA Inc.
  • 2. Course Details <ul><li>www.cs.ubc.ca/~rbridson/fluidsimulation </li></ul><ul><li>Schedule: </li></ul><ul><ul><li>1:45 - 3:30 Basics [Bridson] </li></ul></ul><ul><ul><li>3:30 - 3:45 Break </li></ul></ul><ul><ul><li>3:45 - 4:45 Real-Time [M-F] </li></ul></ul><ul><ul><li>4:45 - 5:30 Extras [Bridson] </li></ul></ul>
  • 3. The Basic Equations
  • 4. Symbols <ul><li>: velocity with components (u,v,w) </li></ul><ul><li> : fluid density </li></ul><ul><li>p: pressure </li></ul><ul><li>: acceleration due to gravity or animator </li></ul><ul><li> : dynamic viscosity </li></ul>
  • 5. The Equations <ul><li>Incompressible Navier-Stokes: </li></ul><ul><ul><li>“ Momentum Equation” </li></ul></ul><ul><ul><li>“ Incompressibility condition” </li></ul></ul>
  • 6. The Momentum Equation
  • 7. The Momentum Equation <ul><li>Just a specialized version of F=ma </li></ul><ul><li>Let’s build it up intuitively </li></ul><ul><li>Imagine modeling a fluid with a bunch of particles (e.g. blobs of water) </li></ul><ul><ul><li>A blob has a mass m, a volume V, velocity u </li></ul></ul><ul><ul><li>We’ll write the acceleration as Du/Dt (“material derivative”) </li></ul></ul><ul><ul><li>What forces act on the blob? </li></ul></ul>
  • 8. Forces on Fluids <ul><li>Gravity: mg </li></ul><ul><ul><li>or other “body forces” designed by animator </li></ul></ul><ul><li>And a blob of fluid also exerts contact forces on its neighbouring blobs… </li></ul>
  • 9. Pressure <ul><li>The “normal” contact force is pressure (force/area) </li></ul><ul><ul><li>How blobs push against each other, and how they stick together </li></ul></ul><ul><li>If pressure is equal in every direction, net force is zero… Important quantity is pressure gradient : </li></ul><ul><ul><li>We integrate over the blob’s volume (equivalent to integrating -pn over blob’s surface) </li></ul></ul><ul><li>What is the pressure? Coming soon… </li></ul>
  • 10. Viscosity <ul><li>Think of it as frictional part of contact force: a sticky (viscous) fluid blob resists other blobs moving past it </li></ul><ul><li>For now, simple model is that we want velocity to be blurred/diffused/… </li></ul><ul><li>Blurring in PDE form comes from the Laplacian: </li></ul>
  • 11. The Continuum Limit (1) <ul><li>Model the world as a continuum: </li></ul><ul><ul><li># particles  Mass and volume  0 </li></ul></ul><ul><li>We want F=ma to be more than 0=0: </li></ul><ul><ul><li>Divide by mass </li></ul></ul>
  • 12. The Continuum Limit (2) <ul><li>The fluid density is  =m/V: </li></ul><ul><li>This is almost the same as the stanford eq’n (in fact, the form we mostly use!) </li></ul><ul><li>The only weird thing is Du/Dt… </li></ul>
  • 13. Lagrangian vs. Eulerian <ul><li>Lagrangian viewpoint: </li></ul><ul><ul><li>Treat the world like a particle system </li></ul></ul><ul><ul><li>Label each speck of matter, track where it goes (how fast, acceleration, etc.) </li></ul></ul><ul><li>Eulerian viewpoint: </li></ul><ul><ul><li>Fix your point in space </li></ul></ul><ul><ul><li>Measure stuff as it flows past </li></ul></ul><ul><li>Think of measuring the temperature: </li></ul><ul><ul><li>Lagrangian: in a balloon, floating with the wind </li></ul></ul><ul><ul><li>Eulerian: on the ground, wind blows past </li></ul></ul>
  • 14. The Material Derivative (1) <ul><li>We have fluid moving in a velocity field u </li></ul><ul><li>It possesses some quality q </li></ul><ul><li>At an instant in time t and a position in space x, the fluid at x has q(x,t) </li></ul><ul><ul><li>q(x,t) is an Eulerian field </li></ul></ul><ul><li>How fast is that blob of fluid’s q changing? </li></ul><ul><ul><li>A Lagrangian question </li></ul></ul><ul><li>Answer: the material derivative Dq/Dt </li></ul>
  • 15. The Material Derivative (2) <ul><li>It all boils down to the chain rule: </li></ul><ul><li>We usually rearrange it: </li></ul>
  • 16. Turning Dq/Dt Around <ul><li>For a thought experiment, turn it around: </li></ul><ul><li>That is, how fast q is changing at a fixed point in space (∂q/∂t) comes from two things: </li></ul><ul><ul><li>How fast q is changing for the blob of fluid at x </li></ul></ul><ul><ul><li>How fast fluid with different values of q is flowing past </li></ul></ul>
  • 17. Writing D/Dt Out <ul><li>We can explicitly write it out from components: </li></ul>
  • 18. D/Dt For Vector Fields <ul><li>Say our fluid has a colour variable (RGB vector) C </li></ul><ul><li>We still write </li></ul><ul><ul><li>The dot-product and gradient confusing? </li></ul></ul><ul><ul><li>Just do it component-by-component: </li></ul></ul>
  • 19. Du/Dt <ul><li>This holds even if the vector field is velocity itself: </li></ul><ul><li>Nothing different about this, just that the fluid blobs are moving at the velocity they’re carrying. </li></ul>
  • 20. The Incompressibility Condition
  • 21. Compressibility <ul><li>Real fluids are compressible </li></ul><ul><li>Shock waves, acoustic waves, pistons… </li></ul><ul><ul><li>Note: liquids change their volume as well as gases, otherwise there would be no sound underwater </li></ul></ul><ul><li>But this is nearly irrelevant for animation </li></ul><ul><ul><li>Shocks move too fast to normally be seen (easier/better to hack in their effects) </li></ul></ul><ul><ul><li>Acoustic waves usually have little effect on visible fluid motion </li></ul></ul><ul><ul><li>Pistons are boring </li></ul></ul>
  • 22. Incompressibility <ul><li>Rather than having to simulate acoustic and shock waves, eliminate them from our model: assume fluid is incompressible </li></ul><ul><ul><li>Turn stiff system into a constraint, just like rigid bodies! </li></ul></ul><ul><li>If you fix your eyes on any volume of space, volume of fluid in = volume of fluid out: </li></ul>
  • 23. Divergence <ul><li>Let’s use the divergence theorem: </li></ul><ul><li>So for any region, the integral of is zero </li></ul><ul><li>Thus it’s zero everywhere: </li></ul>
  • 24. Pressure <ul><li>Pressure p: whatever it takes to make the velocity field divergence free </li></ul><ul><li>If you know constrained dynamics, is a constraint, and pressure is the matching Lagrange multiplier </li></ul><ul><li>Our simulator will follow this approach: </li></ul><ul><ul><li>solve for a pressure that makes our fluid incompressible at each time step. </li></ul></ul>
  • 25. Alternative <ul><li>To avoid having to solve linear systems, can turn this into a soft-constraint </li></ul><ul><ul><li>Track density, make pressure proportional to density variation </li></ul></ul><ul><ul><li>Called “artificial compressibility” </li></ul></ul><ul><li>However, easier to accelerate a linear solver… if the linear system is well-posed </li></ul>
  • 26. Inviscid Fluids
  • 27. Dropping Viscosity <ul><li>In most scenarios, viscosity term is much smaller </li></ul><ul><li>Convenient to drop it from the equations: </li></ul><ul><ul><li>Zero viscosity = “inviscid” </li></ul></ul><ul><ul><li>Inviscid Navier-Stokes = “Euler equations” </li></ul></ul><ul><li>Numerical simulation typically makes errors that resemble physical viscosity, so we have the visual effect of it anyway </li></ul><ul><ul><li>Called “numerical dissipation” </li></ul></ul><ul><ul><li>For animation: often numerical dissipation is larger than the true physical viscosity! </li></ul></ul>
  • 28. Aside: A Few Figures <ul><li>Dynamic viscosity of air: </li></ul><ul><li>Density of air: </li></ul><ul><li>Dynamic viscosity of water: </li></ul><ul><li>Density of water: </li></ul><ul><li>The ratio,  /  (“kinematic viscosity”) is what’s important for the motion of the fluid… … air is 10 times more viscous than water! </li></ul>
  • 29. The inviscid equations <ul><li>A.k.a. the incompressible Euler equations: </li></ul>
  • 30. Boundary Conditions
  • 31. Boundary Conditions <ul><li>We know what’s going on inside the fluid: what about at the surface? </li></ul><ul><li>Three types of surface </li></ul><ul><ul><li>Solid wall: fluid is adjacent to a solid body </li></ul></ul><ul><ul><li>Free surface: fluid is adjacent to nothing (e.g. water is so much denser than air, might as well forget about the air) </li></ul></ul><ul><ul><li>Other fluid: possibly discontinuous jump in quantities (density, …) </li></ul></ul>
  • 32. Solid Wall Boundaries <ul><li>No fluid can enter or come out of a solid wall: </li></ul><ul><li>For common case of u solid =0: </li></ul><ul><li>Sometimes called the “no-stick” condition, since we let fluid slip past tangentially </li></ul><ul><ul><li>For viscous fluids, can additionally impose “no-slip” condition: </li></ul></ul>
  • 33. Free Surface <ul><li>Neglecting the other fluid, we model it simply as pressure=constant </li></ul><ul><ul><li>Since only pressure gradient is important, we can choose the constant to be zero: </li></ul></ul><ul><li>If surface tension is important (not covered today), pressure is instead related to mean curvature of surface </li></ul>
  • 34. Multiple Fluids <ul><li>At fluid-fluid boundaries, the trick is to determine “jump conditions” </li></ul><ul><ul><li>For a fluid quantity q, [q]=q 1 -q 2 </li></ul></ul><ul><li>Density jump [  ] is known </li></ul><ul><li>Normal velocity jump must be zero: </li></ul><ul><li>For inviscid flow, tangential velocities may be unrelated (jump is unknown) </li></ul><ul><li>With no surface tension, pressure jump [p]=0 </li></ul>
  • 35. Numerical Simulation Overview
  • 36. Splitting <ul><li>We have lots of terms in the momentum equation: a pain to handle them all simultaneously </li></ul><ul><li>Instead we split up the equation into its terms, and integrate them one after the other </li></ul><ul><ul><li>Makes for easier software design too: a separate solution module for each term </li></ul></ul><ul><li>First order accurate in time </li></ul><ul><ul><li>Can be made more accurate, not covered today. </li></ul></ul>
  • 37. A Splitting Example <ul><li>Say we have a differential equation </li></ul><ul><li>And we can solve the component parts: </li></ul><ul><ul><li>SolveF(q,∆t) solves dq/dt=f(q) for time ∆t </li></ul></ul><ul><ul><li>SolveG(q,∆t) solves dq/dt=g(q) for time ∆t </li></ul></ul><ul><li>Put them together to solve the full thing: </li></ul><ul><ul><li>q* = SolveF(q n , ∆t) </li></ul></ul><ul><ul><li>q n+1 = SolveG(q*, ∆t) </li></ul></ul>
  • 38. Does it Work? <ul><li>Up to O(∆t): </li></ul>
  • 39. Splitting Momentum <ul><li>We have three terms: </li></ul><ul><li>First term: advection </li></ul><ul><ul><li>Move the fluid through its velocity field (Du/Dt=0) </li></ul></ul><ul><li>Second term: gravity </li></ul><ul><li>Final term: pressure update </li></ul><ul><ul><li>How we’ll make the fluid incompressible: </li></ul></ul>
  • 40. Space <ul><li>That’s our general strategy in time; what about space? </li></ul><ul><li>We’ll begin with a fixed Eulerian grid </li></ul><ul><ul><li>Trivial to set up </li></ul></ul><ul><ul><li>Easy to approximate spatial derivatives </li></ul></ul><ul><ul><li>Particularly good for the effect of pressure </li></ul></ul><ul><li>Disadvantage: advection doesn’t work so well </li></ul><ul><ul><li>Later: particle methods that fix this </li></ul></ul>
  • 41. A Simple Grid <ul><li>We could put all our fluid variables at the nodes of a regular grid </li></ul><ul><li>But this causes some major problems </li></ul><ul><li>In 1D: incompressibility means </li></ul><ul><li>Approximate at a grid point: </li></ul><ul><li>Note the velocity at the grid point isn’t involved! </li></ul>
  • 42. A Simple Grid Disaster <ul><li>The only solutions to are u=constant </li></ul><ul><li>But our numerical version has other solutions: </li></ul>u x
  • 43. Staggered Grids <ul><li>Problem is solved if we don’t skip over grid points </li></ul><ul><li>To make it unbiased, we stagger the grid: put velocities halfway between grid points </li></ul><ul><li>In 1D, we estimate divergence at a grid point as: </li></ul><ul><li>Problem solved! </li></ul>
  • 44. The MAC Grid <ul><li>From the Marker-and-Cell (MAC) method [Harlow&Welch’65] </li></ul><ul><li>A particular staggering of variables in 2D/3D that works well for incompressible fluids: </li></ul><ul><ul><li>Grid cell (i,j,k) has pressure p i,j,k at its center </li></ul></ul><ul><ul><li>x-part of velocity u i+1/2,jk in middle of x-face between grid cells (i,j,k) and (i+1,j,k) </li></ul></ul><ul><ul><li>y-part of velocity v i,j+1/2,k in middle of y-face </li></ul></ul><ul><ul><li>z-part of velocity w i,j,k+1/2 in middle of z-face </li></ul></ul>
  • 45. MAC Grid in 2D
  • 46. Array storage <ul><li>Then for a nx  ny  nz grid, we store them as 3D arrays: </li></ul><ul><ul><li>p[nx, ny, nz] </li></ul></ul><ul><ul><li>u[nx+1, ny, nz] </li></ul></ul><ul><ul><li>v[nx, ny+1, nz] </li></ul></ul><ul><ul><li>w[nx, ny, nz+1] </li></ul></ul><ul><li>And translate indices in code, e.g. </li></ul>
  • 47. The downside <ul><li>Not having all quantities at the same spot makes some algorithms a pain </li></ul><ul><ul><li>Even interpolation of velocities for pushing particles is annoying </li></ul></ul><ul><li>One strategy: switch back and forth (colocated/staggered) by averaging </li></ul><ul><li>My philosophy: avoid averaging as much as possible! </li></ul>
  • 48. Advection Algorithms
  • 49. Advecting Quantities <ul><li>The goal is to solve “the advection equation” for any grid quantity q </li></ul><ul><ul><li>in particular, the components of velocity </li></ul></ul><ul><li>Rather than directly approximate spatial term, we’ll use the Lagrangian notion of advection directly </li></ul><ul><li>We’re on an Eulerian grid, though, so the result will be called “semi-Lagrangian” </li></ul><ul><ul><li>Introduced to graphics by [Stam’99] </li></ul></ul>
  • 50. Semi-Lagrangian Advection <ul><li>Dq/Dt=0 says q doesn’t change as you follow the fluid. </li></ul><ul><li>So </li></ul><ul><li>We want to know q at each grid point at t new (that is, we’re interested in x new =x ijk ) </li></ul><ul><li>So we just need to figure out x old (where fluid at x ijk came from) and q(x old ) (what value of q was there before) </li></ul>
  • 51. Finding x old <ul><li>We need to trace backwards through the velocity field. </li></ul><ul><li>Up to O(∆t) we can assume velocity field constant over the time step </li></ul><ul><li>The simplest estimate is then </li></ul><ul><ul><li>I.e. tracing through the time-reversed flow with one step of Forward Euler </li></ul></ul><ul><ul><li>Other ODE methods can (and should ) be used </li></ul></ul>
  • 52. Aside: ODE methods <ul><li>Chief interesting aspect of fluid motion is vortices: rotation </li></ul><ul><li>Any ODE integrator we use should handle rotation reasonably well </li></ul><ul><li>Forward Euler does not </li></ul><ul><ul><li>Instability, obvious spiral artifacts </li></ul></ul><ul><li>Runge-Kutta 2 is simplest half-decent method </li></ul>
  • 53. Details of x old <ul><li>We need for a quantity stored at (i,j,k) </li></ul><ul><ul><li>For staggered quantities, say u, we need it at the staggered location: e.g. </li></ul></ul><ul><li>We can get the velocity there by averaging the appropriate staggered components: e.g. </li></ul>
  • 54. Which u to Use? <ul><li>Note that we only want to advect quantities in an incompressible velocity field </li></ul><ul><ul><li>Otherwise the quantity gets compressed (often an obvious unphysical artifact) </li></ul></ul><ul><li>For example, when we advect u, v, and w themselves, we use the old incompressible values stored in the grid </li></ul><ul><ul><li>Do not update as you go! </li></ul></ul>
  • 55. Finding q(x old ) <ul><li>Odds are when we trace back from a grid point to x old we won’t land on a grid point </li></ul><ul><ul><li>So we don’t have an old value of q there </li></ul></ul><ul><li>Solution: interpolate from nearby grid points </li></ul><ul><ul><li>Simplest method: bi/trilinear interpolation </li></ul></ul><ul><ul><li>Know your grid: be careful to get it right for staggered quantities! </li></ul></ul>
  • 56. Boundary Conditions <ul><li>What if x old isn’t in the fluid? (or a nearest grid point we’re interpolating from is not in the fluid?) </li></ul><ul><li>Solution: extrapolate from boundary of fluid </li></ul><ul><ul><li>Extrapolate before advection, to all grid points in the domain that aren’t fluid </li></ul></ul><ul><li>ALSO: if fluid can move to a grid point that isn’t fluid now, make sure to do semi-Lagrangian advection there </li></ul><ul><ul><li>Use the extrapolated velocity </li></ul></ul>
  • 57. Extrapolating u Into Solids <ul><li>Note that the inviscid “no-stick” boundary condition just says </li></ul><ul><ul><li>The tangential component of velocity doesn’t have to be equal! </li></ul></ul><ul><ul><li>So we need to extrapolate into solids, and can’t use the solid’s own velocity (result would be bad numerical viscosity) </li></ul></ul>
  • 58. Extrapolation <ul><li>One of the trickiest bits of code to get right </li></ul><ul><li>For sanity check, be careful about what’s known and unknown on the grid </li></ul><ul><ul><li>Replace all unknowns with linear combinations of knowns </li></ul></ul><ul><li>More on this later (level sets) </li></ul>
  • 59. Body Forces
  • 60. Integrating Body Forces <ul><li>Gravity vector or volumetric animator forces: </li></ul><ul><li>Simplest scheme: at every grid point just add </li></ul>
  • 61. Making Fluids Incompressible
  • 62. The Continuous Version <ul><li>We want to find a pressure p so that the updated velocity: is divergence free: while respecting the boundary conditions: </li></ul>
  • 63. The Poisson Problem <ul><li>Plug in the pressure update formula into incompressibility: </li></ul><ul><li>Turns into a “Poisson equation” for pressure: </li></ul>
  • 64. Discrete Pressure Update <ul><li>The discrete pressure update on the MAC grid: </li></ul>
  • 65. Discrete Divergence <ul><li>The discretized incompressibility condition on the new velocity (estimated at i,j,k): </li></ul>
  • 66. Discrete Boundaries <ul><li>For now, let’s voxelize the geometry: each grid cell is either fluid, solid, or empty </li></ul>S S S E S S F S S E E F F F F F F F
  • 67. What’s Active? <ul><li>Pressure: we’ll only solve for p in Fluid cells </li></ul><ul><li>Velocity: anything bordering a Fluid cell is good </li></ul><ul><li>Boundary conditions: </li></ul><ul><ul><li>p=0 in Empty cells (free surface) </li></ul></ul><ul><ul><li>p=? whatever is needed in Solid cells so that the pressure update makes (Note normal is to grid cell!) (Also note: different implied pressures for each active face of a solid cell - we don’t store p there…) </li></ul></ul>
  • 68. Example Solid Wall <ul><li>(i-1,j,k) is solid, (i,j,k) is fluid </li></ul><ul><li>Normal is n=(1,0,0) </li></ul><ul><li>Want </li></ul><ul><li>The pressure update formula is: </li></ul><ul><li>So the “ghost” solid pressure is: </li></ul>S F
  • 69. Discrete Pressure Equations <ul><li>Substitute in pressure update formula to discrete divergence </li></ul><ul><li>In each fluid cell (i,j,k) get an equation: </li></ul>
  • 70. Simplified <ul><li>Collecting terms: </li></ul><ul><li>Empty neighbors: drop zero pressures </li></ul><ul><li>Solid neighbors: e.g. ( i-1, j, k) is solid </li></ul><ul><ul><li>Drop p i-1jk - reduce coeff of p ijk by 1 (to 5…) </li></ul></ul><ul><ul><li>Replace u i-1/2jk in right-hand side with u solid </li></ul></ul>
  • 71. Linear Equations <ul><li>End up with a sparse set of linear equations to solve for pressure </li></ul><ul><ul><li>Matrix is symmetric positive (semi-)definite </li></ul></ul><ul><li>In 3D on large grids, direct methods unsatisfactory </li></ul><ul><li>Instead use Preconditioned Conjugate Gradient, with Incomplete Cholesky preconditioner </li></ul><ul><li>See course notes for full details (pseudo-code) </li></ul><ul><li>Residual is how much divergence there is in u n+1 </li></ul><ul><ul><li>Iterate until satisfied it’s small enough </li></ul></ul>
  • 72. Voxelization is Suboptimal <ul><li>Free surface artifacts: </li></ul><ul><ul><li>Waves less than a grid cell high aren’t “seen” by the fluid solver – thus they don’t behave right </li></ul></ul><ul><ul><li>Left with strangely textured surface </li></ul></ul><ul><li>Solid wall artifacts: </li></ul><ul><ul><li>If boundary not grid-aligned, O(1) error – it doesn’t even go away as you refine! </li></ul></ul><ul><ul><li>Slopes are turned into stairs, water will pool on artificial steps. </li></ul></ul><ul><li>More on this later… </li></ul>
  • 73. Smoke As per [Fedkiw et al.’01]
  • 74. Soot <ul><li>Smoke is composed of soot particles suspended in air </li></ul><ul><li>For simulation, need to track concentration of soot on the grid: s(x,t) </li></ul><ul><li>Evolution equation: </li></ul><ul><ul><li>Extra term is diffusion (if k≠0) </li></ul></ul><ul><ul><li>Simplest implementation: Gaussian blur </li></ul></ul><ul><li>Boundary conditions: </li></ul><ul><ul><li>At solid wall: ds/dn=0 (extrapolate from fluid) </li></ul></ul><ul><ul><li>At smoke source: s=s source </li></ul></ul><ul><li>Note: lots of particles may be better for rendering… </li></ul>
  • 75. Heat <ul><li>Usually smoke is moving because the air is hot </li></ul><ul><ul><li>Hot air is less dense; pressure vs. gravity ends up in buoyancy (hot air rising) </li></ul></ul><ul><li>Need to track temperature T(x,t) </li></ul><ul><li>Evolution equation (neglecting conduction) </li></ul><ul><li>Boundary conditions: conduction of heat between solids and fluids </li></ul><ul><ul><li>Extrapolate T from fluid, add source term… </li></ul></ul>
  • 76. Boussinesq and Buoyancy <ul><li>Density variation due to temperature or soot concentration is very small </li></ul><ul><li>Use the “Boussinesq approximation”: fix density=constant, but replace gravity in momentum equation with a buoyancy force: </li></ul><ul><li>Constants  and  can be tuned </li></ul>
  • 77. Open Boundaries <ul><li>If open air extends beyond the grid, what boundary condition? </li></ul><ul><li>After making the Boussinesq approximation, simplest thing is to say the open air is a free surface (p=0) </li></ul><ul><ul><li>We let air blow in or out as it wants </li></ul></ul><ul><li>May want to explicitly zero velocity on far boundaries to avoid large currents developing </li></ul>
  • 78. Water
  • 79. Where is the Water? <ul><li>Water is often modeled as a fluid with a free surface </li></ul><ul><li>The only thing we’re missing so far is how to track where the water is </li></ul><ul><ul><li>Voxelized: which cells are fluid vs. empty? </li></ul></ul><ul><ul><li>Better: where does air/water interface cut through grid lines? </li></ul></ul>
  • 80. Marker Particles <ul><li>Simplest approach is to use marker particles </li></ul><ul><li>Sample fluid volume with particles {x p } </li></ul><ul><li>At each time step, mark grid cells containing any marker particles as Fluid, rest as Empty or Solid </li></ul><ul><li>Move particles in incompressible grid velocity field (interpolating as needed): </li></ul>
  • 81. Rendering Marker Particles <ul><li>Need to wrap a surface around the particles </li></ul><ul><ul><li>E.g. blobbies, or Zhu & Bridson ‘05 </li></ul></ul><ul><li>Problem: rendered surface has bumpy detail that the fluid solver doesn’t have access to </li></ul><ul><ul><li>The simulation can’t animate that detail properly if it can’t “see” it. </li></ul></ul><ul><li>Result: looks fine for splashy, noisy surfaces, but fails on smooth, glassy surfaces. </li></ul>
  • 82. Improvement <ul><li>Sample implicit surface function on simulation grid </li></ul><ul><ul><li>Even just union of spheres is reasonable if we smooth and render from the grid </li></ul></ul><ul><li>Note: make sure that a single particle always shows up on grid (e.g. radius ≥ ∆x) or droplets can flicker in and out of existence… </li></ul><ul><ul><li>If not: you must delete stray particles </li></ul></ul><ul><li>But still not perfect for flat fluid surfaces. </li></ul>
  • 83. Level Sets <ul><li>Idea: drop the particles all together, and just sample the implicit surface function on the grid </li></ul><ul><li>In particular, best behaved type of implicit surface function is signed distance: </li></ul><ul><li>Surface is exactly where  =0 </li></ul><ul><li>See e.g. the book [Osher&Fedkiw’02] </li></ul>
  • 84. Surface Capturing <ul><li>We need to evolve  on the grid </li></ul><ul><li>The surface (  =0) moves at the velocity of the fluid (any fluid particle with  =0 should continue with  =0) </li></ul><ul><li>We can use same equation for rest of volume (doesn’t really matter what we do as long as sign stays the same – at least in continuous variables!) </li></ul>
  • 85. Reinitializing <ul><li>One problem is that advecting  this way doesn’t preserve signed distance property </li></ul><ul><ul><li>Eventually gets badly distorted </li></ul></ul><ul><ul><li>Causes problems particularly for extrapolation, also for accuracy in general </li></ul></ul><ul><li>Reinitialize: recompute distance to surface </li></ul><ul><ul><li>Ideally shouldn’t change surface at all, just values in the volume </li></ul></ul>
  • 86. Computing Signed Distance <ul><li>Many algorithms exist </li></ul><ul><li>Simplest and most robust (and accurate enough for animation) are geometric in nature </li></ul><ul><li>Our example algorithm is based on a Fast Sweeping method [Tsai’02] </li></ul>
  • 87. Set Up <ul><li>Start by identifying grid cells where  old changes sign (where the surface is) </li></ul><ul><li>Determine points and/or mesh elements to approximate surface </li></ul><ul><ul><li>Set nearby grid values to exact distance to closest surface element </li></ul></ul><ul><ul><li>Also store index of closest surface element </li></ul></ul><ul><li>Every other grid point is reset to  = ±L and index of closest surface element = UNKNOWN </li></ul><ul><li>We then propagate information out to these points </li></ul>
  • 88. Fast Sweeping <ul><li>One sweep: loop i,j,k through the grid: </li></ul><ul><ul><li>Check neighbors for their closest surface element </li></ul></ul><ul><ul><li>If the closest of those is closer than |  ijk | then update  ijk and set its index to that point </li></ul></ul><ul><li>Idea: keep sweeping in different directions </li></ul><ul><ul><li>++i, ++j, ++k </li></ul></ul><ul><ul><li>--i, ++j, ++k </li></ul></ul><ul><ul><li>++i, --j, ++k </li></ul></ul><ul><ul><li>--i, --j, ++k </li></ul></ul><ul><ul><li>++i, ++j, --k </li></ul></ul><ul><ul><li>etc … </li></ul></ul>
  • 89. Extrapolation <ul><li>We often need fluid values extrapolated outside of the fluid </li></ul><ul><ul><li>e.g. velocity must be extrapolated out from free surface and into solid </li></ul></ul><ul><li>With signed distance this is much simpler </li></ul>
  • 90. Extrapolation (1) <ul><li>Interpolate fluid quantities onto stored surface points (generated in redistancing) </li></ul><ul><ul><li>Make sure to only use known quantities, not values outside the fluid that the physics doesn’t touch </li></ul></ul><ul><li>Then use index-of-closest-element to copy values everywhere needed </li></ul>
  • 91. Extrapolation (2) <ul><li>Gradient of distance points parallel to ray to closest surface point </li></ul><ul><li>Phrase extrapolation as a PDE: </li></ul><ul><li>Then solve the PDE with finite differences </li></ul><ul><ul><li>Careful “upwind” scheme needed (want to get information from points with smaller distance, not bigger) </li></ul></ul>

×