Fluid Simulation on the GPU with Complex Obstacles Using the Lattice Boltzmann Method

Fluid Simulation on the GPU with Complex Obstacles Using the Lattice Boltzmann Method

Fluid Simulation on the GPU with Complex Obstacles Using the Lattice Boltzmann Method DIPLOMARBEIT zur Erlangung des akademischen Grades Diplom-Ingenieur im Rahmen des Studiums Computergraphik und Digitale Bildverarbeitung ausgef¨uhrtvon Andreas Monitzer Matrikelnummer 0225165 am: Institut f¨urComputergraphik und Algorithmen und VRVis Zentrum f¨urVirtual Reality und Visualisierung Forschungs-GmbH Betreuung: Betreuer: Ao. Univ.-Prof. Dipl.-Ing. Dr.techn. Eduard Gr¨oller Mitwirkung: Dipl.-Inf. Raphael Fuchs Wien, 17.07.2008 (Unterschrift Verfasser) (Unterschrift Betreuer) Technische Universit¨atWien A-1040 Wien Karlsplatz 13 Tel. +43/(0)1/58801-0 http://www.tuwien.ac.at Fluid Simulation on the GPU with Complex Obstacles Using the Lattice Boltzmann Method Andreas Monitzer mailto:[email protected] http://www.monitzer.com Abstract [English] Real-time computer graphics and simulation has advanced to a level of realism that was regarded as unthinkable a few decades ago. However, fluid simulations are still in an infant state for applications that require interactivity. Recent developments in programmability of graphics processing units on current graphics cards have enabled researchers to treat these cards as stream co-processors. This class of processors are designed for parallelizable algorithms that do not make heavy use of branching. Algorithms having these properties can be accelerated significantly compared to implementations on current central processing units. Since grid-based fluid simulations fit perfectly into this scheme, this has become a hot topic in research. Various approaches will be presented in order to determine a combination of algorithms that can easily be parallelized and allow integrating rigid objects with complex boundaries into a fluid simulation at interactive rates. Additionally, the usage of fluid simulations in computer games will be discussed. An underwater pinball game will be introduced as a practical example, highlighting the considerations that have to be taken into account when adding this game element that was previously impossible to use. [German] Die Echtzeit-Computergrafik und -Simulation haben sich zu einem Niveau entwickelt, das vor wenigen Jahrzehnten noch als undenkbar galt. Ungeachtet dessen stecken Fl¨ussigkeitssimulationen f¨urinteraktive Anwendungen immer noch in den Kinderschuhen. Die progressive Weiterentwicklung der Graphikkarten- prozessoren hat in letzter Zeit dazu gef¨uhrt,dass Forscher die Karten als Stream-Koprozessoren behandeln k¨onnen. Diese Klasse von Prozessoren wurde entwickelt, um parallelisierbare Algorithmen mit wenigen Sprungbefehlen zu verarbeiten. Die Laufzeit von Algorithmen, die diese Eigenschaften besitzen, kann auf einen Bruchteil der auf herk¨ommlichenProzessoren ben¨otigtenverk¨urztwerden. Da rasterbasierte Fl¨ussigkeitssimulation perfekt in dieses Schema passt, ist es zu einem sehr aktiven Forschungsgebiet geworden. Es werden einige Ans¨atzepr¨asentiertwerden, um eine gute Algorithmen-Kombination zu finden, die einfach parallelisiert werden kann und gleichzeitig Objekte mit komplexen Oberfl¨achener- lauben. Zus¨atzlichwird die Verwendung von Fl¨ussigkeitssimulationen in Computerspielen betrachtet. Ein Unterwasser-Flipper wird als praktisches Beispiel vorgestellt, um die Uberlegungen¨ hervorzuheben, die notwendig sind, um eine solche fr¨uhernicht verwendbare Simulation effektiv einzusetzen. Contents 1 Nomenclature iii 2 Introduction 1 2.1 Previous Work........................................ 3 2.2 The Navier-Stokes Equations................................ 4 2.2.1 Euler's Simplified Equations............................. 5 2.2.2 Boundary Conditions................................ 6 2.2.3 Implementations................................... 6 3 Fluid Simulation Using the Lattice Boltzmann Method8 3.1 The Lattice Gas Cell Automata............................... 8 3.2 The Lattice Boltzmann Method............................... 9 3.2.1 Lattice Geometry.................................. 9 3.2.2 The Macroscopic Properties of a Lattice Cell................... 10 3.3 Gravity............................................ 13 3.4 Initial Conditions...................................... 13 3.5 Boundary Conditions.................................... 13 3.6 Physical Correspondency.................................. 14 4 General Purpose-Programming on Graphics Hardware 16 4.1 Bitonic Sort......................................... 16 4.2 Shader Programming.................................... 20 4.3 CUDA............................................ 22 4.3.1 Architecture..................................... 22 4.3.2 CUDA's Programming Language.......................... 25 4.3.3 Optimization Strategies............................... 27 4.4 Adapting CFD to the GPU Using CUDA.......................... 30 4.4.1 Visualizing the Flow................................. 31 5 Complex Obstacles in Fluid Simulations 35 5.1 Voxelization on the GPU.................................. 35 5.2 Integrating a Physics Engine into a Fluid Simulation.................... 39 5.2.1 Rigid Body Simulation using the Bullet Physics Library.............. 39 i 5.3 Solid-Fluid Coupling..................................... 40 5.3.1 Mei et al.'s Extrapolation Method......................... 40 5.3.2 Noble's Method for Partially Saturated Cells.................... 42 5.4 Fluid-Solid Coupling..................................... 45 5.5 Two-Way Coupling..................................... 46 6 Game Design with Fluid Simulations and Their Implementation 48 6.1 The Fluid Pinball...................................... 49 6.1.1 The Pinball Game.................................. 49 6.1.2 Adapting the LBM Implementation to a Game................... 51 6.1.3 Ogre......................................... 52 6.1.4 Pinball Game Elements............................... 53 6.1.5 Implementation................................... 55 7 Results 67 7.1 The Basic Application.................................... 67 7.2 The Game-like Application................................. 68 7.3 Analysis of the Performance Measurement Results..................... 68 8 Conclusion 71 ii Chapter 1 Nomenclature i index over the lattice directions fi(x; t) particle distribution at position x and time t in direction i eq fi equilibrium distribution function in direction i τ fluid viscousity ρ fluid density p fluid pressure u fluid velocity us solid velocity ρs solid density Ωi fluid collision operator in direction i s Ωi solid collision operator in direction i ∆x grid spacing on the x-axis ∆y grid spacing on the y-axis ∆z grid spacing on the z-axis ∆t the amount of time requred for calculating one iteration of the simulation (might vary on every iteration) iii Chapter 2 Introduction Real-time computer graphics have advanced to a level of realism that was regarded as impossible a few decades ago. However, fluid simulations are still in an infant state for applications that require interactivity, due to performance issues. Graphics processing units (GPUs) on current graphics cards can be treated as stream co-processors. This class of processors is designed for parallelizable algorithms that do not make heavy use of branching. Algorithms having these properties can be accelerated significantly compared to implementations on current central processing units (CPUs). Additionally, GPUs do not suffer from caching issues, since they have very closely defined input and output streams and are optimized at the hardware level for this configuration. Grid-based fluid simulations are an obvious choice for GPU-based calculation, since operating on the cells of a grid is easily parallelizable. However, care has to be taken to avoid slowdowns caused by making inefficient use of the card's features. In previous work, a fluid animation using LBM took 244 seconds per frame to calculate [Th¨urey et al., 2006]. In this thesis, we introduce a method for bringing similar animations to interactive rates, including complex objects immersed in the fluid. As a test case, a computer game was implemented, which uses fluid behavior as the primary game element in a pinball-like simulation (see Figure 2.1). Even though the animation has to be believable by the user, it does not have to be physically correct. In addition, a visualization of the fluid is required, which does not have to be physics-based, but allows the player to see motion in the game world. Since today's computational power is thought to be inadequate for real-time fluid animations, realistic 3 dimensional fluids are not used in current games on the market, missing an important element that can enhance the immersion into the virtual world. In the future, many types of games can benefit from adding these capabilities, like puzzle, role-playing or action games or in the edutainment sector. A complete implementation for a game requires the consideration of multiple aspects with competing solutions, not all equal for the task at hand. Section 2.2 outlines the classic approach to basic fluid sim- ulation using the Navier-Stokes equations, while Chapter3 describes the Lattice Boltzmann approach, 2 Figure 2.1: A real-world implementation of the fluid pinball concept from TOMY, 1977, a tank filled with water. There are two pumps at the bottom, each to be controlled by a player by pressing the big orange buttons. A point is scored when the ball is sent through the opponent's goal. When the orange button is pressed, the water pressure also elevates the footballer's foot at the bottom and the goalkeeper, allowing the player to parry an incoming ball. 2.1. PREVIOUS

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    84 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us