Accelerating Fluids Simulation Using SPH and ...uu.diva- 885188/  · Accelerating Fluids

  • View
    215

  • Download
    0

Embed Size (px)

Text of Accelerating Fluids Simulation Using SPH and ...uu.diva- 885188/  · Accelerating Fluids

  • IT 15076

    Examensarbete 30 hpDecember 2015

    Accelerating Fluids Simulation Using SPH and Implementation on GPU

    Aditya Hendra

    Institutionen fr informationsteknologiDepartment of Information Technology

  • Teknisk- naturvetenskaplig fakultet UTH-enheten Besksadress: ngstrmlaboratoriet Lgerhyddsvgen 1 Hus 4, Plan 0 Postadress: Box 536 751 21 Uppsala Telefon: 018 471 30 03 Telefax: 018 471 30 00 Hemsida: http://www.teknat.uu.se/student

    Abstract

    Accelerating Fluids Simulation Using SPH andImplementation on GPU

    Aditya Hendra

    Fluids simulation is usually done with CFD methods which offers high precision butneeds days/weeks/months to compute on desktop CPUs which limits the practical usein industrial control systems. In order to reduce the computation time SmoothedParticle Hydrodynamics (SPH) method is used. SPH is commonly used to simulatefluids in computer graphics field, especially in gaming. It offers faster computation atthe cost of lesser accuracy. The goal of this work is to determine the feasibility ofusing SPH method with GPU parallel programming to provide fluids simulation whichis fast enough for real-time feedback control simulation. A previous master thesiswork about accelerating fluids simulation using SPH method was done by AnnJohansson at ABB. Her work in Matlab using intel i7 - 2.4Ghz needs 7089 seconds tocompute a water-jet simulation with 40000 particles and time-step of 0.006 second.Our work utilizes GPU parallel programs implemented in Fluidsv3, an open-sourcesoftware as the base code. With CUDA C/C++ and Nvidia GTX980, we need 18seconds to compute a water-jet simulation using 1000000 particles and time-step of0.0001 second. Currently, our work lacks of validation method to measure theaccuracy of the fluids simulation and more work needs to be done about this.However it only takes 80 msec to compute one iteration which opens an opportunityto be used together with any real-time systems, such as a feedback control system,that has a period of 100msec. This mean it could model industry processes that utilizewater such as the cooling process in a hot rolling mill. The next question, which is notaddressed in this study, would be how to satisfy application dependent needs such as:simulation accuracy, required parameters, simulations duration in real-time, etc.

    Tryckt av: Reprocentralen ITCIT 15076Examinator: Wang Yimnesgranskare: Stefan EngblomHandledare: Kateryna Mishchenko

  • AcknowledgementI would like to express my gratitude to ABBs project team, especially mythesis supervisor Kateryna Mishchenko, Markus Lindgren and Lokman Ho-sain for their trust and guidance from the start till the end of the thesis work.

    Furthermore, I would like to thank you Rama Hoetzlein for making hiswork of Fluidsv3 available freely on the web. I also want to thank you mythesis reviewer Stefan Engblom from Uppsala University for his beneficialhelp in writing.

    My sincere thanks also goes to my master program coordinator at UppsalaUniversity, Philipp Rmmer whom has helped me with many things duringmy education there.

    Last but not least, I am very grateful to Swedish Institute for providing mefull scholarship for my master education in Sweden. Without it, this workwould not be possible.

  • Contents

    Acknowledgement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v

    Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.1 Project Purpose and Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.2 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.1 Fluids Simulation with Smoothed-Particle Hydrodynamics . . . . . . . 14

    2.1.1 Navier-Stokes Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.1.2 Smoothed Particle Hydrodynamics (SPH) . . . . . . . . . . . . . . . . . . . . . 14

    2.2 GPU Parallel Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.2.1 General-Purpose computing on Graphics Processing

    Units (GPGPU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.2.2 CUDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    3 SPH for Fluids Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.1 Acceleration of MATLAB code using GPUs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.2 GPU Implementation of Fluids simulation using SPH Method . . 25

    3.2.1 SPH Implementation with Fluidsv3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.2.2 Alternative SPH Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    3.3 Other GPGPU Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    4 GPGPU Fluids (Water-Jet) Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.1 GPU Performance Benchmarking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.2 Water-Jet Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.3 Simulation Modification to Fluidsv3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.4 Visual Correctness Modification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    4.4.1 Fluidsv3 Original Boundary Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.4.2 Ihmsen et.al Boundary Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    4.5 Parallel Programming Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344.5.1 Reduce-Malloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344.5.2 Graphics-Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344.5.3 GPU Shared-Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    4.6 Predictive-Corrective Incompressible SPH (PCISPH) . . . . . . . . . . . . . . . . 384.7 Known Limitation of Water-Spray simulation SPH Method for

    Fluids Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394.7.1 Particles Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

  • 4.7.2 Incompressibility and Simulation Stability . . . . . . . . . . . . . . . . . . . . 394.7.3 Initial Speed vs. Time Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404.7.4 Obtaining Parameters Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404.7.5 Simulation Correctness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    5 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425.1 Performance Benchmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425.2 Unused Optimization Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435.3 Different Simulation Parameter to Simulation Speed . . . . . . . . . . . . . . . . . . 44

    6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456.1 Accelerated Fluids Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456.2 GPU shared-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466.3 PCISPH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476.4 Future Works . . . . . . . . . . . . . . . . . . . . .