Fluid Simulation http kucg korea ac kr Graphics

  • Slides: 42
Download presentation
Fluid Simulation http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Fluid Simulation http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Contents n n n KUCG Introduction Diffusion Semi-Lagrangian advection Poisson Equation Implementation http: //kucg.

Contents n n n KUCG Introduction Diffusion Semi-Lagrangian advection Poisson Equation Implementation http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Motivation KUCG Fedkiw et al. 2001 http: //kucg. korea. ac. kr Graphics Lab @

Motivation KUCG Fedkiw et al. 2001 http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Fluids in Computer Graphics KUCG Fast n Looks good n Easy to code n

Fluids in Computer Graphics KUCG Fast n Looks good n Easy to code n http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Fluid Mechanics n Natural framework for fluid modeling n n Full Navier-Stokes Equations Has

Fluid Mechanics n Natural framework for fluid modeling n n Full Navier-Stokes Equations Has a long history n n KUCG Reuse code/algorithms Equations are hard to solve n Non-linear http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Application n KUCG Use velocity to move densities http: //kucg. korea. ac. kr Graphics

Application n KUCG Use velocity to move densities http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Equations n Density field n Velocity field http: //kucg. korea. ac. kr KUCG Graphics

Equations n Density field n Velocity field http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Finite Difference Scheme http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Finite Difference Scheme http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Equations n KUCG Evolution of density (assume velocity known) Over a time step. .

Equations n KUCG Evolution of density (assume velocity known) Over a time step. . . http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Equations n KUCG Evolution of density (assume velocity known) Density changes in the direction

Equations n KUCG Evolution of density (assume velocity known) Density changes in the direction of the flow http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Equations n KUCG Evolution of density (assume velocity known) Density diffuses over time http:

Equations n KUCG Evolution of density (assume velocity known) Density diffuses over time http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Equations n KUCG Evolution of density (assume velocity known) Increases due to sources from

Equations n KUCG Evolution of density (assume velocity known) Increases due to sources from the UI http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Algorithm KUCG Subdivide space into voxels Velocity + density defined in the center of

Algorithm KUCG Subdivide space into voxels Velocity + density defined in the center of each voxel http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Algorithm add source http: //kucg. korea. ac. kr KUCG diffuse move Graphics Lab @

Algorithm add source http: //kucg. korea. ac. kr KUCG diffuse move Graphics Lab @ Korea University

Diffusing Densities KUCG dt Dn http: //kucg. korea. ac. kr Dn+1 Graphics Lab @

Diffusing Densities KUCG dt Dn http: //kucg. korea. ac. kr Dn+1 Graphics Lab @ Korea University

Diffusing Densities KUCG Exchange of density between neighbors http: //kucg. korea. ac. kr Graphics

Diffusing Densities KUCG Exchange of density between neighbors http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Diffusing Densities KUCG Exchange of density between neighbors http: //kucg. korea. ac. kr Graphics

Diffusing Densities KUCG Exchange of density between neighbors http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Diffusing Densities KUCG i, j+1 i-1, j i+1, j i, j-1 Dn+1 i, j

Diffusing Densities KUCG i, j+1 i-1, j i+1, j i, j-1 Dn+1 i, j = Dn i, j + k dt (Dn i-1, j + Dn i+1, j + Dn i, j-1 + Dn i, j+1 - 4 Dn i, j)/h 2 http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Algorithm add source http: //kucg. korea. ac. kr KUCG diffuse move Graphics Lab @

Algorithm add source http: //kucg. korea. ac. kr KUCG diffuse move Graphics Lab @ Korea University

Moving Densities KUCG dt Velocity known http: //kucg. korea. ac. kr Graphics Lab @

Moving Densities KUCG dt Velocity known http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Moving Densities n KUCG Finite differences Transfer only between neighbors n Unstable with large

Moving Densities n KUCG Finite differences Transfer only between neighbors n Unstable with large time steps n http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Semi-Lagrangian Advection http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Semi-Lagrangian Advection http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Semi-Lagrangian Advection http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Semi-Lagrangian Advection http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Semi-Lagrangian Advection http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Semi-Lagrangian Advection http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Semi-Lagrangian Advection KUCG Interpolate the density at new location http: //kucg. korea. ac. kr

Semi-Lagrangian Advection KUCG Interpolate the density at new location http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Semi-Lagrangian Advection KUCG Set interpolated density at grid location Requires two grids http: //kucg.

Semi-Lagrangian Advection KUCG Set interpolated density at grid location Requires two grids http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Computing Velocities KUCG Use same algorithms as for density Velocity is moved by itself

Computing Velocities KUCG Use same algorithms as for density Velocity is moved by itself http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Moving Velocity KUCG Trace particle backwards in time http: //kucg. korea. ac. kr Graphics

Moving Velocity KUCG Trace particle backwards in time http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Moving Velocity KUCG Interpolate the velocity at new location http: //kucg. korea. ac. kr

Moving Velocity KUCG Interpolate the velocity at new location http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Moving Velocity KUCG Set interpolated velocity at grid location Requires two grids http: //kucg.

Moving Velocity KUCG Set interpolated velocity at grid location Requires two grids http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Conservation of Mass KUCG Inflow = Outflow Ui+1, j - Ui-1, j + Vi,

Conservation of Mass KUCG Inflow = Outflow Ui+1, j - Ui-1, j + Vi, j+1 - Vi, j-1 = 0 http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Poisson Equation n KUCG Poisson Equation n Step 1 n Step 2 http: //kucg.

Poisson Equation n KUCG Poisson Equation n Step 1 n Step 2 http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Implementation KUCG /* Running */ while(simulating) { velocityfield. advect(dt); velocityfield += gravityfield*(densityfield*(dt*10. 0 f));

Implementation KUCG /* Running */ while(simulating) { velocityfield. advect(dt); velocityfield += gravityfield*(densityfield*(dt*10. 0 f)); fvelocityfield = velocityfield; fvelocityfield. remove. Divergence(); velocityfield = fvelocityfield; densityfield. advect(velocityfield, dt); } http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Implicit Diffusion http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Implicit Diffusion http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Implicit Diffusion n Explicit diffusion n n KUCG Dn+1 i, j = Dn i,

Implicit Diffusion n Explicit diffusion n n KUCG Dn+1 i, j = Dn i, j + k dt (Dn i-1, j + Dn i+1, j + Dn i, j-1 + Dn i, j+1 - 4 Dn i, j)/h 2 Implicit diffusion n Dn+1 i, j – k dt (Dn+1 i-1, j+Dn+1 i+1, j+Dn+1 i, j-1+Dn+1 i, j+1 -4 Dn+1 i, j)/h 2 = Dni, j Ax=b http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Diffusing Densities KUCG Linear solvers: Name Cost Comments Gaussian elimination N 3 Use only

Diffusing Densities KUCG Linear solvers: Name Cost Comments Gaussian elimination N 3 Use only for very small N (test code) Jacobi/SOR relaxation N 2 Easy to code but slow FFT/cyclical reduction N log. N Use when no internal boundaries Conjugate gradient N 1. 5 Use when internal boundaries Multi-grid N http: //kucg. korea. ac. kr Slower than FFT in practice. Hard to code when internal boundaries present Graphics Lab @ Korea University

Mass Conservation - Numerical Example- http: //kucg. korea. ac. kr Graphics Lab @ Korea

Mass Conservation - Numerical Example- http: //kucg. korea. ac. kr Graphics Lab @ Korea University

Given Velocity Field KUCG P 0 P 1 P 2 P 3 P 4

Given Velocity Field KUCG P 0 P 1 P 2 P 3 P 4 P 5 10. 0 f P 6 http: //kucg. korea. ac. kr P 7 P 8 Graphics Lab @ Korea University

Poisson Equation http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Poisson Equation http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Solution http: //kucg. korea. ac. kr KUCG 0. 0 0. 41 0. 0 -0.

Solution http: //kucg. korea. ac. kr KUCG 0. 0 0. 41 0. 0 -0. 41 1. 25 -0. 41 -2. 50 -4. 58 -2. 50 Graphics Lab @ Korea University

Superposition KUCG + 5. 83 http: //kucg. korea. ac. kr 10. 0 f Graphics

Superposition KUCG + 5. 83 http: //kucg. korea. ac. kr 10. 0 f Graphics Lab @ Korea University

Divergence-Free Velocity Field http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Divergence-Free Velocity Field http: //kucg. korea. ac. kr KUCG Graphics Lab @ Korea University