Simulation of Fluids using the NavierStokes Equations Kartik

  • Slides: 18
Download presentation
Simulation of Fluids using the Navier-Stokes Equations Kartik Ramakrishnan

Simulation of Fluids using the Navier-Stokes Equations Kartik Ramakrishnan

Presentation Scope • • • Introduction Theory Adaptation to CPU and GPU Results Optimizations

Presentation Scope • • • Introduction Theory Adaptation to CPU and GPU Results Optimizations and Future Work

Introduction • Physically based simulation of fluids produces very good visual effects • Computationally

Introduction • Physically based simulation of fluids produces very good visual effects • Computationally expensive process • In the past, usually done offline and not in real time • Real time fluid simulation was done using particle systems • Current hardware makes physically based fluid simulation possible in real time

Navier-Stokes Theory • The fluid being rendered is assumed to be incompressible (fluid volume

Navier-Stokes Theory • The fluid being rendered is assumed to be incompressible (fluid volume remains constant over time) • The fluid being rendered is assumed to be homogeneous (fluid density remains constant in space)

Navier-Stokes Theory RHS of the equation, proceeding left to right, • Advection/velocity term •

Navier-Stokes Theory RHS of the equation, proceeding left to right, • Advection/velocity term • Pressure term • Diffusion term • Force term

Navier-Stokes Theory • Advection - Describes the transport mechanism of the fluid - Also

Navier-Stokes Theory • Advection - Describes the transport mechanism of the fluid - Also describes the transport mechanism of any material the fluid may be carrying - For example , ink in water, the advection term describes the movement of both the water and the ink

Navier-Stokes Theory Diffusion Describes the resistance of the fluid to flow Viscosity of the

Navier-Stokes Theory Diffusion Describes the resistance of the fluid to flow Viscosity of the fluid is a factor in this term More viscous the fluid, the more resistant it is to flow - Impedes the velocity of the fluid • -

Navier-Stokes Theory • Pressure - Describes the behavior of the fluid due to pressure

Navier-Stokes Theory • Pressure - Describes the behavior of the fluid due to pressure induced among fluid particles - Think fluid particles squished against each other due to the application of force - Pressure leads to increase in the velocity

Navier-Stokes Theory • Force - Describes the behavior the fluid due to any externally

Navier-Stokes Theory • Force - Describes the behavior the fluid due to any externally applied force or any bodily force (gravity) - Application of force causes an increase in the fluid velocity

Adaptation to CPU and GPU • The NS equation is not in a finite

Adaptation to CPU and GPU • The NS equation is not in a finite form • Need to reduce each of the above RHS terms to a discrete representation that can be implemented on the CPU and the GPU

Adaptation to CPU and GPU • Finite representation of the NS Equation

Adaptation to CPU and GPU • Finite representation of the NS Equation

Adaptation to CPU and GPU • Discrete NS algorithm - Assume a 2 D

Adaptation to CPU and GPU • Discrete NS algorithm - Assume a 2 D bounding grid for the fluid - Assume one such grid for each fluid property of interest (velocity, pressure, force, dye etc. ) - Assume that velocity and pressure are 0 at time t = 0 - Assume that velocity is negative and that pressure is 0 at the grid boundaries

Adaptation to CPU and GPU • Algorithm steps - Apply force: w 1 =

Adaptation to CPU and GPU • Algorithm steps - Apply force: w 1 = u + Force* timestep - Advect: w 2 = w 1(x – timestep*w 1) - Diffuse term: del 2 w 3 = w 2 - Pressure term: del 2 p = w 3 - Subtract pressure gradient: w 4 = w 3 – del p

Adaptation to CPU and GPU • • • void Fluids: : Simulate() { //Advect(();

Adaptation to CPU and GPU • • • void Fluids: : Simulate() { //Advect((); Swap. Velocity. Grid(); Swap. Color. Grid(); • • • //Add force Add. Force(); Swap. Velocity. Grid(); • • • //Diffuse(); Swap. Velocity. Grid(); • Set. Bounds(); • • timestep++; //Compute Pressure Compute. Pressure(); Swap. Pressure. Grid(); //Project(); Swap. Velocity. Grid(); }

Results AMD Athalon 3200+ 2. 19 GHz, 2 GB RAM AMD Radeon 4870 1

Results AMD Athalon 3200+ 2. 19 GHz, 2 GB RAM AMD Radeon 4870 1 GB Brook+ 64 x 64 fluid grid, 50 frames and 70 jacobian iterations • CPU (averaged over 50 frames) = 0. 83 sec • GPU (averaged over 50 frames) = 0. 035 sec • •

Optimizations and Future Work • Use float 4 for the pressure computation instead of

Optimizations and Future Work • Use float 4 for the pressure computation instead of float • Pinned memory, new to Brook+1. 4 • Shared memory, supposed to be implemented, but think its not • GPU version still glitchy – needs a few tweaks • Other fluid grid sizes

Distant future • Better visuals • Port to Direct. X 10 : dedicated texture

Distant future • Better visuals • Port to Direct. X 10 : dedicated texture hardware support available, bilinear interpolation available for free

 • Questions

• Questions