1 / 11

Fluid Simulation using CUDA

Fluid Simulation using CUDA. Thomas Wambold taw38@drexel.edu CS680: GPU Program Optimization August 31, 2011. Looking at 2D and 3D fluid simulation techniques. Simulate fluid interactions with itself and its environment. I'm mostly looking at it for visual uses: Video games, movies, etc.

manju
Download Presentation

Fluid Simulation using CUDA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fluid Simulation using CUDA Thomas Wambold taw38@drexel.edu CS680: GPU Program Optimization August 31, 2011

  2. Looking at 2D and 3D fluid simulation techniques. Simulate fluid interactions with itself and its environment. I'm mostly looking at it for visual uses: Video games, movies, etc. More accurate simulations could be used for more scientific modeling. Overview/Usage From GPUGems 3

  3. Methods • Field-based systems • Volume is represented by a grid. • Each block in the gird contains properties such as velocity, density, temperature, and pressure. • Blocks do not move. • An Eulerian view. • I looked more at this system. • Particle-based systems • Fluid is represented by large quantities of particles. • Each particle has the same properties as before, but also position. • Particles can move. • A Lagrangian view.

  4. From Intel Article.  (a) Field-based (b) Particle-based

  5. Equations • Navier-Stokes equations for incompressable flow •  Assumes incompressable, homogeneous •  Invompressable - volume of any subregion is constant. •  Homogeneous - density of any subregion is constant. • Represents velocity field, pressure field. • Use numerical integration techniques to solve incrementally. • For each iteration of the simulation: • Update velocity with forces in the system. • Transfer velocity between grid cells (advection). • Diffuse velocity based on viscosity. • Update velocity for incompressible fluids. • So velocity field is non-divergent.

  6. 2D Fluid Simulator • Sample code from nVidia CUDA SDK. • Uses field-based system. • Currently 512x512 grid, split grid into 64x64 tiles. • Each tile has 64 threads, each processing 64x16 cells. • Uses texture memory. • Iterations: • Velocities are updated based on mouse movements • Grabs values stored in neighboring cells for advection • Diffusion uses a Fourier Transform (CUFFT) • Uses CUDA/OpenGL integration to avoid memory copies.

  7. Sequential Fluid Simulator • Modified example to not use CUDA • Computations are done on the CPU, copied to Vertex Buffer Object to display via OpenGL. • Attempted to replace cuFFT library with GSL FFT, but did not get far. • Was able to get particles to display on the screen, and they do move around, but very oddly.  Still many problems, but it doesn't crash. • Some of this could probably be blamed on the memory copies between the CPU and GPU, but not this much.

  8. CPU vs CUDA Fluid Simulations • Tested on my home machine (didn't want to forward X11 or something): • Intel Core 2 Quad @ 2.8GHz • nVidia GeForce GTX 460 • Compute Capability: 2.1 • CUDA Cores: 7 multiprocessors X 48 cores = 336 • CUDA version never went below 300 FPS • CPU version barely got above 5 FPS • This is without doing any FFT for force diffusion. • Slowness could probably be partially blamed on memory copies. 

  9. 2D Fluid Simulator

  10. Next Steps/Conclusions • Next steps: • Modify nVidia's sample to just use CPU (DONE) • Implement my own 2D simulator. • Explore 3D simulators. • Difficulties: • Probably was a bit too ambitious for the time constraints. • I don't have much experience in this, a lot to try to absorb. • Have to worry about rendering, example uses CUDA OpenGL integration. • Examples from various conferences show very impressive real-time simulations using the GPU.

  11. References • In-depth article from Intel with lots of math (both particle, and field-based):http://software.intel.com/en-us/articles/fluid-simulation-for-video-games-part-1/ • Good article explaining equations about field-based simulation:http://http.developer.nvidia.com/GPUGems/gpugems_ch38.html • 3D simulations:http://http.developer.nvidia.com/GPUGems3/gpugems3_ch30.html • Documentation for SDK example:http://new.math.uiuc.edu/MA198-2008/schaber2/fluidsGL.pdf • SDK Example:http://developer.nvidia.com/cuda-cc-sdk-code-samples#fluidsGL

More Related