Neighborhood grid: A novel data structure for fluids animation with GPU computing
Introduction
Realism in real-time graphical simulations includes the search for real behaviors and physics. Due to the graphics technology improvements, simulation of natural phenomena, such as water flows or smoke, has become possible to be performed in real time and interactive environments, like scientific applications and digital games. In fact, this kind of simulation is now quite popular in computer games, digital movies and animations. It is important to state that in real-time simulations, there is a trade-off between realism and interactivity, and most of the times the realistic behavior is put aside in order to have interactive frame rates.
Many non-graphics algorithms traditionally executed on the CPU are often suitable for parallel execution, which makes them appropriate to be implemented on GPUs (graphics processing units). Fluid animation that explores this programming model on the GPU is a promising line of research, since it can drastically speedup the computation cost of the fluids’ behavior [4]. This work presents a new data structure for speeding up the neighborhood gathering which can be applied in fluid simulation. The concepts of the proposed architecture could also be applied to other multi-core processors like multi-core CPUs, the Playstation 4, Xbox One, and clusters.
GPUs are a collection of SIMD (single instruction, multiple data) processors designed to run a streamed graphics pipeline. It is a computational model where the processing of each pixel is independent of the others and usually requires localized memory reads (texture fetching). There are rules of thumb to create efficient streamed applications, where the most important one is to organize the data streams in order to maximize memory read performance based on locality. These rules tend to result in a more efficient usage of available cache memory and read ahead mechanisms of these devices. The proposed simulation system makes use of such strategies.
The SPH (smoothed particle hydrodynamics) method simulates the fluid as a set of discrete elements, referred as particles. In order to process the interaction between the particles using the Lagrangian approach, a neighborhood-gathering algorithm is needed in order to process the forces among the particles. The naive approach of such algorithm has complexity of , since it has to process each particle against all the other particles. Most of the research on parallel and distributed SPH fluid simulation tries to avoid the high complexity of proximity queries by applying some form of spatial subdivision to the environment and by classifying particles among the cells based on their position. To accelerate data fetching in a parallel hardware (such as GPUs) the particles listed must be sorted in a way that all particles on the same cells are grouped together. This approach helps decrease the number of proximity queries, but it is very sensible to the maximum number of particles that can fit in a single cell. In this work, instead of using a similar approach, it is proposed a novel data structure which maintains particles into another kind of proximity based data structure. In this data structure, called neighborhood grid, each cell stores only one particle and does not directly represent a discrete spatial subdivision. The neighborhood grid is an approximated representation of the system of neighbors of the environment that maps the -dimensional environment to a discrete map (lattice) with dimensions. Hence, particles that are close in a neighborhood sense appear close to each other in the map. Another approach is to think of it as a multi-dimensional compression of the simulated environment that still stores the original position information of all particles.
Contributions: This work presents a novel parallel data structure for graphical real-time fluid animation based on the SPH method. This solution uses a novel data structure, called neighborhood grid, in order to gather the neighborhoods of the particles in an optimized manner. By doing so, this proposal fills the lack of GPU bounded architectures that usually process all elements in the scene at each frame, thus being an efficient solution for other parallel and distributed solutions of fluid simulations.
Paper summary: This work is organized as follows. After referring to the SPH method in Section 2 and the related works of fluid simulation in Section 3, the neighborhood grid data structure is introduced in Section 4. In Section 5 the architecture environment on GPUs and the acceleration data structures employed in the simulations are described. In Section 6 some results are shown and, in Section 7, the conclusions are presented.
Section snippets
SPH model
In order to perform fluid simulations, the following equations need to be solved: which are known as Navier–Stokes equations for modeling the flow of incompressible Newtonian fluids. In these equations, represents the density of the fluid, is the velocity field, is the pressure field, represents the viscosity of the fluid and corresponds to the resultant of external forces.
Eq. (1) is known as the equation of motion and states that the changes in
Related work
Physical simulations using Eulerian grid-based approach can be seen in Foster and Metaxas [9], who were the first to solve the full 3D Navier–Stokes equations in order to re-create visual properties of fluid dynamics. Stam [35] simulated gases employing a semi-Lagrangian integration scheme that achieves stability using artificial viscosity and rotational damping. Foster and Fedkiw [8] extended this technique to liquids using a level-set method. Latter, Enright et al. [6] added free surface
Neighborhood grid
The computation of the particles’ physical attributes in a meshless fluid simulation depends on observing the surrounding neighbors of each particle. It is known that the naive straightforward implementation of the neighborhood gathering algorithm has complexity , where is the number of particles, since it performs at least one proximity query for each particle pair in the simulation. Moreover, since particles are autonomous and can move each frame, the neighborhood maintenance is a very
Architecture environment
The proposed architecture implements fluid simulations using a novel GPU computing solution, based on the neighborhood grid data structure. Our solution allows a high performance increase during simulation. This architecture environment is explained in the following subsections.
Results
This section presents the results obtained from the proposed data structure. A series of screenshots of a fluid animation with 65k particles, built with the presented architecture, can be seen in Fig. 4.
In order to evaluate our proposed data structure for SPH particle simulation, this work has implemented the traditional uniform grid with an index sort method in the GPU with the use of CUDA, which is the same implementation proposed at [33], [18]. This implementation uses a uniform grid to
Conclusion and future work
We have presented a novel data structure (neighborhood grid) which can be employed for real-time SPH fluid simulations on GPUs. With the proposed data structure we are able to simulate and render up to 1 million fluid particles in real-time frame rate, while the uniform grid with index sort method and most works in the literature barely maintains interactivity in the simulation. Moreover, with the neighborhood grid and bitonic sort, configured with a radius of 4, a visual simulation similar to
Mark Joselli is the Chief-Developer-Officer of Nullpointer, a Brazilian Software Development Company. He teaches game development and mobile development at PUC-PR. He is also a Game Developer, mobile developer and a Researcher in GPGPU. He also created the first Framework for GPGPU games.
He is a Doctor (2013) and a Master (2007) in Computer Science from Federal Fluminense University. He is an Industrial Electronic Engineer by the Federal Center for Technological Education Celso Suckow da
References (40)
- et al.
Realistic animation of liquids
Graph. Models Image Process.
(1996) Simulating free surface flows with SPH
J. Comput. Phys.
(1994)- et al.
Modeling low Reynolds number incompressible flows using SPH
J. Comput. Phys.
(1997) - et al.
Adaptively sampled particle fluids
ACM Trans. Graph.
(2007) - et al.
GPU-based neighbor-search algorithm for particle simulations
J. Graph. GPU Game Tool.
(2009) - et al.
An experimental analysis of parallel sorting algorithms
Theory Comput. Syst.
(1998) - et al.
Interactive fluid-particle simulation using translating Eulerian grids
- et al.
Smoothed particles: a new paradigm for animating highly deformable bodies
- et al.
Animation and rendering of complex water surfaces
ACM Trans. Graph.
(2002) - et al.
How GPUs can outperform ASICs for fast LDPC decoding
Practical animation of liquids
Alternative ways of coupling particle behaviour with fluid dynamics in mineral processing
Int. J. Comput. Fluid Dyn.
Smoothed particle hydrodynamics-theory and application to non-spherical stars
Mon. Not. R. Astron. Soc.
Interactive SPH simulation and rendering on the GPU
A parallel SPH implementation on multi-core cpus
Comput. Graph. Forum
Cited by (11)
On the Monotonic Lagrangian Grid as Antecedent to the Neighborhood Grid
2020, Journal of Parallel and Distributed ComputingCitation Excerpt :In 2009 the basic MLG data structure was rediscovered under the name Neighborhood Grid (NG) in the context of an application involving large-scale crowd simulation [4]. Interestingly, it was later successfully applied to the animation of fluids [5], which brings the original motivation for the MLG – fluid dynamics simulation – full circle. The purpose of this paper is to draw attention to the equivalence of the MLG and NG so that the insights and applications of each can be jointly leveraged in future works.
Improved GPU near neighbours performance for multi-agent simulations
2020, Journal of Parallel and Distributed ComputingCitation Excerpt :This limits the applicability of verlet lists to systems of both low entropy and scale [31]. Joselli et al. described a novel data structure they called neighbourhood grid, inspired by USP [14]. Their data structure, designed for SPH, instead assigns each particle to a unique bin, rather than allowing multiple particles to share each bin.
Spatial sorting: An efficient strategy for approximate nearest neighbor searching
2016, Computers and Graphics (Pergamon)Citation Excerpt :As a final demand, we also sought for an approach that is simple to parallelize on current GPUs. The neighborhood grid was proposed by Joselli et al. [11], following early work in 2D [24] and 3D [25]. The main idea is to organize points into a matrix or tridimensional array, to accelerate the location of nearest neighbors.
Parallel Algorithms of Well-Balanced and Weighted Average Flux for Shallow Water Model Using CUDA
2021, Modelling and Simulation in EngineeringA general novel parallel framework for SPH-centric algorithms
2019, Proceedings of the ACM on Computer Graphics and Interactive TechniquesA survey of physically-based ocean scene simulation
2019, Dalian Haishi Daxue Xuebao/Journal of Dalian Maritime University
Mark Joselli is the Chief-Developer-Officer of Nullpointer, a Brazilian Software Development Company. He teaches game development and mobile development at PUC-PR. He is also a Game Developer, mobile developer and a Researcher in GPGPU. He also created the first Framework for GPGPU games.
He is a Doctor (2013) and a Master (2007) in Computer Science from Federal Fluminense University. He is an Industrial Electronic Engineer by the Federal Center for Technological Education Celso Suckow da Fonseca (CEFET-RJ—2005) and also a bachelor in philosophy by Unisul (2013).
José Ricardo da S. Junior is B.Sc. in Systems Analysis at Estacio de Sa University (2005), M.Sc. in Computer Science at Fluminense Federal University (2010), master-vocational Game Development and 3D applications by the Veiga de Almeida University (2007) and teaching-medio-second-degree flame by the College (1998).
Acting on the following topics: Computational Fluid Dynamics, Fluid Simulation, Load Balancing GPU/CPU, Smoothed Particle Hydrodynamics.
Esteban W. Clua has M.Sc. and Ph.D. in Computer Science. He is currently a professor at the Computing Institute at Federal Fluminense University (UFF) and general coordinator of MediaLab—UFF. He is one of the founders of Brazilian Simposium in Games and Digital Entertainment (SBGames) by Brazilian Computer Society (SBC), council member of the special committee of the SBC games and entertainment and a pioneer in the area scientific research in games and digital entertainment. In 2007 he received the prize as the largest contributor ABRAGAMES academy for digital games industry in Brazil.
Anselmo Montenegro has B.Sc. degree in Computer Science at Federal Fluminense University (UFF—1995), M.Sc. (1997) and Ph.D. in Computer Science at PUC-Rio (Catholic University of Rio de Janeiro—2003). He is currently Associate Professor of UFF.
He has experience in Computer Science, with emphasis on graphics processing, acting on the following topics: models of global illumination in GPU, visualization, image-based, mathematical morphology, space carving, photography and 3d information visualization.
Marcos Lage has B.Sc. in Mathematics at Universidade do Estado do Rio de Janeiro (2004), M.Sc. (2006) and Ph.D. (2009) in Applied Mathematics at PUC-Rio de Janeiro. He is currently professor of at Universidade Federal Fluminense. His main research area is the numerical simulation of fluids. He is also interested in topological data structures, vector field’s reconstruction and geometric modeling.
Paulo Pagliosa has Ph.D. in Structural Engineering from the School of Engineering of São Carlos at Universidade de São Paulo (1998). He is currently an associate professor of Computer Science in the College of Computing at Universidade Federal de Mato Grosso do Sul, and has experience in visualization and simulation, acting on the following topics: GPGPU, computational mechanics, geometric processing, and physics for games.