Docstoc

Fluid Simulation 101

Document Sample
Fluid Simulation 101 Powered By Docstoc
					By Michael Su
   04/16/2009
   Introduction
   Fluid characteristics
   Navier-Stokes equation
   Eulerian vs. Lagrangian approach
   Dive into the glory detail (A case study of the 2d fluid
    simulation)
     Advection
     Diffusion
     Pressure solve
   Fluid object couple
     One-way and two-way coupling
   Real-time fluids
   Broad view of the fluid simulation in graphics
    community and its potential applications
   Basic knowledge about the grid-based fluid
    simulation
   Understanding the challenges of the existing
    methods
   Foundation for the following two fluids-
    related lectures (smoke & granular material).
   Applications
     Games (Half Life, Crysis)
     Scientific visualization (Water sewage system, dam
      construction)
     Movie special effects (Finding Nemo, Pirates of Caribbean)
     Medical simulation (Blood flow)
   What can we achieve so far?                       [Goktekin, Bargteil,
                                                      [Fedkiw, Stam, Turk]
                                                      [Wang, Mucha,
                                                         [Tessendorf]
                                                      [Zhu, Bridson]
     Smoke                                           O'Brien] Visual
                                                      Jensen] A Method for
                                                      Water Drops on
                                                         Simulating Ocean
                                                      Animating Sand as a
                                                      Surfaces, SIGGRAPH
                                                      Simulation of Smoke,
                                                         Water,
     Granular flow (Sand)                            Fluid, SIGGRAPH 05
                                                      Viscoelastic Fluids,
                                                      SIGGRAPH 01  05
                                                         01
                                                      SIGGRAPH 04
     Newtonian fluid (Water, ocean)
     Non-Newtonian fluid (Blood, honey, goop (viscoelaticity
      flow))
     Microscopic phenomena
   Basic properties
       Pressure
       Density
       Viscosity (subject to shear stress)
       Surface tension
   Different types of fluids:
     Incompressible (divergence-free) fluids: Fluids doesn’t
      change volume (very much).
     Compressible fluids: Fluids change their
      volume significantly.
     Viscous fluids: Fluids tend to resist a
      certain degrees of deformation
 Inviscid (Ideal) fluids: Fluids don’t have resistance
  to the shear stress
 Turbulent flow: Flow that appears to have chaotic
  and random changes
 Laminar (streamline) flow: Flow that has
  smooth behavior
 Newtonian fluids: Fluids continue
  to flow, regardless of the force
  acting on it
 Non-Newtonian fluids: Fluids that have non-
  constant viscosity
 Phase Transition: Fluids may change
  physical behavior under different
  environmental conditions.
   Modeling continuum fluids on discrete
    systems – It’s all about approximations
   Topological variations and different kinds of
    behaviors with interacting subjects
   Numerical stabilities, accuracy and
    convergence issues
   Performance
   User control
By Michael Su
   04/20/2009
Calculus Review (1)

   Gradient (): A vector pointing
    in the direction of the greatest
                                                         u u u 
    rate of increment                              u   , , 
                                                         x y z 
                                                                  
              u u u  u can be a scalar or a
        u   , , 
              x y z  vector
                       
   Divergence ( ): Measure how the
    vectors are converging or diverging
    at a given location (volume
    density of the outward flux)
                                                      Source,          Sink,
            u u u
      u         u can only be a vector           Div(u) > 0       Div(u) < 0
            x y z
Calculus Review (2)

   Laplacian (∆ or  2 ): Divergence of the gradient
           2u  2u  2u      u can be a scalar or a
       u 2  2  2
        2

          x   y   z        vector


   Finite Difference: Derivative approximation

            u ui 1  ui
              
            x xi 1  xi
     Momentum equation
   ut = k2u –(u)u – p + f

Change in Diffusion/Vi Advection Pressure Body
velocity  scosity                         Forces

                                                   Claude-Louis Navier George Gabriel
     Incompressibility                            (1785~1836)         Stokes
                                                                       (1819~1903)

             u=0
                                                      u: the velocity field
                                                      k: kinematic viscosity
   Borrowed from CFD (Computational Fluid
    Dynamics)
   Common techniques for solving Navier
    Stoke’s equation:
     Eulerian approach (grid-based)
     Lagrangian approach (particle-based)
     Spectral method                        [Stam] Stable Fluids,
                                             [Mueller, Charypar,
     Lattice Boltzmann method               SIGGRAPH 99
                                             Gross] Particle-Based
                                             Fluid Simulation for
                                             Interactive
                                             Applications, SCA03
   Discretize the domain using finite differences
   Define scalar & vector fields on the grid
   Use the operator splitting
    technique to solve each
    term separately
   Evaluation:
      Derivative approximation
      Adaptive time step/solver
      Memory usage & speed
      Grid artifact/resolution limitation
   Treat the fluid as discrete particles
   Apply interaction forces (i.e.
    pressure/viscosity) according to certain
    pre-defined smoothing kernels
   Evaluations:
     Mass / Momentum conservation
     More intuitive
     Fast, no linear system solving
     Connectivity information/Surface reconstruction
Case Study: A 2D Fluid Simulator

   We focus exclusively on incompressible,
    viscous fluid
   Assuming the gravity is the only external
    force
   No inflow or outflow
   Constant viscosity, constant density
    everywhere in the fluid
                    Advection      Body Force     Diffusion



Scalar/Vector
fields defined
on the grid                                     Pressure Solve




                 ut = k2u –(u)u – p + f
                 u=0
The Power of Operator Splitting

   n
                             One complicated Multi-
  U +A+B+D+P                  dimensional operator => A
       *                      series of simple, lower
   U
                              dimensional operators
           **                Each operator can have its
           U
                              own integration scheme
                ***           and different time step
                U
                              sizes
                      n+1
                      U      High modularity and easy
                              to debug
 Sometimes called “Convection” or “Transport”
 Define how a quantity moves with the underlying
  velocity field
 This term ensures the conservation of momentum
 Advection equation:
                             ut  (u  u )
   Approaches:
     Forward Euler (unstable)
     Semi-Lagragian advection (stable for large time steps, but
      suffers from the dissipation issue)
Forward Euler Advection   Semi-Lagragian Advection
 Define how a quantity in a cell inter-changes with
  its neighbors
 Diffusion = Blurring
 The viscous fluid can be achieved by applying
  diffusion to the velocity field
    Low Viscosity                             High Viscosity




                                  Figures from [Carlson, Mucha, Turk]
                                      Melting and Flowing, SCA 02
   Diffusion equation:
                                                      ut  k   u                2


   Approaches:
                                                                                                         1
     Explicit formulation
         ut  k  t  (ui 1, j  ui 1, j  ui , j 1  ui , j 1  4  ui , j )              1       -4       1

     Implicit formulation                                                                               1
       (for high viscosity)
u n i , j  u n 1i , j  k  t  (u n 1i 1, j  u n 1i 1, j  u n 1i , j 1  u n 1i , j 1  4  u n 1i , j )

                                                       Unknowns
    0     0   0                0   2.5 0

0   0     5    0    0      0   2.5 -10 2.5    0

    0     0    0               0   2.5

          0




    Before the diffusion       After the diffusion
                               (k = 0.5, time step
                               size =1)
    It’s sometimes called “Pressure Projection”
    What does the pressure do?
      Keep the fluid at constant volume
       (incompressible, conservation of mass).
      Make sure the velocity field stays divergence-free

             flux  0
          all _ faces


                           Incompressible    Compressible



   Equation to solve:
                                                   n 1
        u   n 1
                   u 
                     n    1
                              p
                                     s.t.    u          0   • • • (1)

                                 Unknowns
   How to solve for pressure:
     Taking divergence of both sides of (1), we will
      have 1  p    u (Poisson Equation)
                     2        n

              
     Build a system of equations and solve Ap = d using
      an iterative method such as Conjugate Gradient
     Update the velocity field from the pressure
      gradient
   What about the pressure on boundary nodes?
     Free surface: The fluid can     Free surface

      evolve freely (p = 0)
     Solid wall: The fluid can’t
       penetrate the wall but can
       flow freely in tangential
      directions (Neumann BC)

         uboundary  n  usolid  n

                                        Solid wall
   Possible reasons why your simulation doesn’t
    look right:
     CFL condition violation   t  u  C  x
        => Smaller time steps / Implicit solver
       Flux conservation => BCs may not be set correctly
                    
        Grid resolution/ Memory => Adaptive grids
       Numerical dissipation => Back and Forth Error Compensation
        and Correction [4] / Vorticity confinement [5]
       Handle the interface and complex topological changes =>
        Level set method [6]
       Volume loss => Particle level set [7]
   One-way coupling:
     Solid-Fluid interaction: The fluid has no influence
      on the solid
     Fluid-Solid interaction: The solid has no influence
      on the fluid
   Two-way coupling:
     Manipulate the boundary conditions
     Finite Element techniques: ALE & DLM
     Rigid Fluid: Treat the solid as fluids and enforce
     the rigidity constraint [8]
   Principles:
     Cheap to compute
     Low memory consumption
     Stability
     Plausibility
     Interactivity
   Common techniques:
     Procedural water: Superimpose sine waves of a
      variety of amplitudes and directions. [9]
 Real-time Fluids (2)

      Heightfield approximations: If the surface is the
      only interest, it can be represented using a 2d
      heightfield and animated by 2d wave equations
      with interaction forces.
                                           
                                k1       k2  x i  x j    H(x,
         f (x i , x j )                    
                           x  x m x  x n  x i  x j   y)
                           i     j   i   j 



      Particle systems: This approach is
    good at simulating a small amount of
      water such as a puddle, a bubble,
      or splashing fluids
   [1] R. Bridson and M. Müller-Fischer. Fluid Simulation. SIGGRAPH 07
    Course Notes
   [2] R. Bridson. Fluid Simulation for Computer Graphics. A K Peters,
    2008
   [3] J. Stam. Real-Time Fluid Dynamics for Games. GDC 2003
   [4] B. Kim, Y. Liu, I. Llamas, and J. Rossignac. FlowFixer: Using BFECC
    for Fluid Simulation. EGWNP 05
   [5] R. Fedkiw, J. Stam, and H.W. Jenson. Visual Simulation of Smoke.
    SIGGRAPH 01
   [6] N. Foster, R. Fedkiw, Practical Animation of Liquids. SIGGRAPH 01
   [7] D. Enright, S. Marschner, R. Fedkiw. Animation and Rendering of
    Complex Water Surfaces. SIGGRAPH 02
   [8] M. Carlson, P. J. Mucha, G. Turk. Rigid Fluid: Animating the
    Interplay Between Rigid Bodies and Fluid. SIGGRAPH 04
References (2)
   [9] D. Hinsinger, F. Neyret, M. Cani. Interactive Animation of Ocean
    Waves. SCA 02

				
DOCUMENT INFO