Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Simulation of Fluids using the Navier-Stokes Equations Kartik Ramakrishnan 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 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 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 •Pressure term •Diffusion term •Force term 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 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 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 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 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 • Discrete NS algorithm - Assume a 2D 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: w1 = u + Force* timestep - Advect: w2 = w1(x – timestep*w1) - Diffuse term: del2 w3 = w2 - Pressure term: del2 p = w3 - Subtract pressure gradient: w4 = w3 – del p Adaptation to CPU and GPU • • • • • • void Fluids::Simulate() { //Advect Advect((); SwapVelocityGrid(); SwapColorGrid(); • • • //Add force AddForce(); SwapVelocityGrid(); • • • • • • • • • • • //Diffuse Diffuse(); SwapVelocityGrid(); • SetBounds(); • • timestep++; //Compute Pressure ComputePressure(); SwapPressureGrid(); //Project Project(); SwapVelocityGrid(); } Results • • • • AMD Athalon 3200+ 2.19 GHz, 2GB RAM AMD Radeon 4870 1GB Brook+ 64x64 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 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 DirectX 10 : dedicated texture hardware support available, bilinear interpolation available for free • Questions