Interactive 2D Particle-based Fluid Simulation for Mobile ... 676516/FULLTEXT01.pdf ·...
date post
10-Jul-2019Category
Documents
view
215download
0
Embed Size (px)
Transcript of Interactive 2D Particle-based Fluid Simulation for Mobile ... 676516/FULLTEXT01.pdf ·...
Interactive 2D Particle-based Fluid Simulation
for Mobile Devices
Daniel Mnsson
073 508 1234
dmans@kth.se
Bachelor's Thesis at NADA
Course: DD143X
Supervisor: Pawel Herman
Examiner: Mrten Bjrkman
Stockholm, Sweden 2013
AbstractThis report presents an implementation of a uid simulation algorithm,
capable of running at 60 frames per second on a modern handheld tablet
device. The goal was to create an interactive application, usable for
helping students understand and visualize some fundamental uid be-
haviours.
The algorithm was based on previous research for an algorithm,
targeted to run on a desktop PC at 10 frames per seconds for 1000
particles. This algorithm was reduced by removing the capability to
simulate complex elastic uid properties and made run faster.
The resulting implementation is capable of simulating and visual-
izing: waves, splashes, uid level equalization in a series of tubes and
simple uid ow through pipes. The implementation is capable of sim-
ulating 3000 particles at a steady 60 frames per second on the target
hardware.
ReferatInteraktiv partikelbaserad vtskesimulation i 2D fr
mobila enheter
Den hr rapporten presenterar en implementation av en vtskesimule-
ringsalgoritm, kapabel att simulera i 60 bilder per sekund p en modern
surfplatta. Mlet var att skapa en interaktiv applikations som r anvnd-
bar fr att hjlpa studenter frst och visualisera ngra grundlggande
vtskeegenskaper.
Algoritmen var baserat p tidigare forskning, som var riktad mot att
fungera p en stationr PC med en uppdateringsfrekvens p 10 bilder
per sekund fr 1000 partiklar. Denna algoritm reducerades genom att
ta bort mjligheten att simulera komplexa elastiska vtskor och kunde
drmed fungera snabbare.
Den resulterande implementationen klarar av att simulera och visu-
alisera: vgor, stnk, en vtskeniv som jmnar ut sig och enklare den
genom rr. Implementationen har kapacitet att simulera 3000 partiklar
i 60 bilder per sekund p mlhrdvaran.
Contents
1 Introduction 1
1.1 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Problem statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Background 3
2.1 Basic uid simulation . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.1 Eulerian grids . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.1.2 Lagrangian particles . . . . . . . . . . . . . . . . . . . . . . . 4
3 Implementation 5
3.1 Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.1.1 Numerical integration . . . . . . . . . . . . . . . . . . . . . . 63.1.2 Pseudo code clarication . . . . . . . . . . . . . . . . . . . . . 63.1.3 Algorithm overview . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 Neighbor search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3 Threading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.4 World collision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.5 User interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.6 Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.7 Testing method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4 Results 19
4.1 Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.2 Fluid behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.2.1 Waves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.2.2 Pressure equalization in an U-tube . . . . . . . . . . . . . . . 214.2.3 Splash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.2.4 Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244.3.1 Impact from threading . . . . . . . . . . . . . . . . . . . . . . 244.3.2 Particle count . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.4 Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5 Conclusion 27
5.1 Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Bibliography 29
Chapter 1
Introduction
Computational uid dynamics is an interesting and well researched eld. Thereexists many algorithms for simulating and visualizing the motion of uids for arange of dierent applications, especially in the eld of special eects for movies andcomputer games. However, the calculations required for uid simulations has alwaysbeen computational expensive. Therefore, most algorithms either focus on oinerendering or require some kind of high power device, such as a GPU1, for makingthe simulation run in real time.
In recent years, the power of mobile devices have increased enough to make thema viable choice for simulating uids. Naturally, their computational power is stillnot on par with regular desktop computers, since they are required to run from alimited power source and have a greater size constraint. This puts an interestingconstraint on the available previous research since the research to date has tendedto focus either on algorithms for real-time simulation on the GPU, or algorithms forlarge scale oine simulations.
The target processing unit for this prototype will be the Tegra 3 mobile processor,released in 2011. It is a common high end processing unit that has been used inmany devices. With the constant increase of processing power in mobile devices,the Tegra 3 should provide a good baseline for the performance benchmark. TheTegra 3 has got a quad- core processor and a GPU with 12 pixel shader units. Thetest device will be a Microsoft Surface RT tablet, using the Tegra 3 T30L(1.2 GHz)with 2 GB of RAM.
While the Tegra 3 is powerful by mobile standards, it does not compare to theperformance of a desktop computer. This is extra noticeable when comparing theGPUs, where the Tegra 3 is noticeably weaker than a high end GPU. This willmake the previous research using the GPU less suitable for this simulation, sincethey usually uses a high end desktop GPU. The Tegra 3 GPU will not have enoughperformance to perform a complex simulation on top of rendering the scene.
1GPU - Graphics Processing Unit. Specialized hardware used to perform graphics calculations
with high performance. Since those calculations basically are oating point operations this kind of
hardware can be used for other kind of calculations as well, such as uid simulation.
1
1.1 PurposeThe purpose of this prototype is to explore the capability of running uid simulationon mobile devices and to use the prototype to visualize some interesting uid prop-erties. The goal of the visualization is to make this prototype usable for educationalpurposes, where people getting started in uid dynamics can get an idea of howuids behave.
1.2 Problem statementPerformance is one of the main issues with simulating uids on mobile devices. To geta usable simulation a high number of particles is needed, but increasing the numberof particles also increases the computational load. This article aim to explore whichparts of a existing algorithm can be left out, in order to increase performance, aswell as the eect of threading on the Tegra 3 device.
Another issue to take into consideration is the actual uid behaviour. Whileit is important that some of the most basic uid dynamics features are plausiblyreproduced, the simulation does not need to perfectly physically accurate. The goalis only to use this project as a visual aid and not to be used for actual measurementscorresponding to the real world.
Chapter 2
Background
This chapter aims to give a brief introduction to computational uid dynamics.There will not be an in-depth discussion of uid simulation techniques, since thefocus of this work is mainly implementation based and educational. The literatureused in this chapter provides a good source for a more in-depth discussion.
2.1 Basic fluid simulation
There are many dierent variations of computational particle based uid simula-tion algorithms available in literature. However, little work has been done on uidsimulation on lower power devices, since uid dynamics is inherently computationalexpensive.
[HKK07] and [WLL04] describes two algorithms using the GPU for doing thecomputational work. In a few years, it is possible that mobile GPUs becomes pow-erful enough to simulate uids and still being able to render a scene. This is not thecase on the target device, which needs the GPU to work on rendering the frame.
Many of the CPU based algorithms are not designed to run in real time on adesktop computer. Even if they claim to be interactive, the frame rates usually endsup being 10-20 frames per seconds. This is not an acceptable frame rate for thisimplementation's target application, which requires a steady 60 frames per second.
The implementation described in this report will be based on an algorithm aimingto simulate viscoelastic uids, written by Clavet, Beaudoin and Poulin [CBP05]. Oneproblem with this algorithm is that it only runs at 10 frames per second on theirtarget hardware and has support for much more complex uid behavior than isneeded for our implementation. Therefore, a reduced version of their algorithm willbe used, avoiding the computationally expensive part which managed the elasticity.However, the algorithm is both robust and relatively simple to implement, makingit suitible for the scale of this project.
The algorithm described in [CBP05] aims to solve the Navier- Stokes equationof uid motion, which is t