Presentation is loading. Please wait.

Presentation is loading. Please wait.

Smoothed Particle Hydrodynamics Matthew Zhu CSCI 5551 — Fall 2015.

Similar presentations


Presentation on theme: "Smoothed Particle Hydrodynamics Matthew Zhu CSCI 5551 — Fall 2015."— Presentation transcript:

1 Smoothed Particle Hydrodynamics Matthew Zhu CSCI 5551 — Fall 2015

2 Smoothed-particle hydrodynamics, or SPH, is used to simulate fluid flows in various fields such as oceanography, volcanology, astrophysics, computer graphics, and aerospace. Purpose Theoretical astrophysicists use SPH to simulate galaxy formation, star formation, and stellar collisions SPH is used by aerospace engineers to model a bird flying into the leading edge of an aircraft wing

3 Hydrodynamics is the study of forces acting upon or exerted by fluids and the resulting motion For SPH, fluids are modeled as a set of discrete particles SPH Theory Smoothing refers to the modeling of particle properties by kernel functions such as a cubic spline or the Gaussian function Particle properties are smoothed over a predefined distance

4 Navier-Stokes Conservation of Momentum Physics Acceleration of Each Particle Forces Color Function

5 Scalar Quantity Smoothing Kernels

6 The space of the simulation is divided into grid cells with sides of length H (the smoothing length) H is the maximum possible distance between interacting particles Particles in the center cell may only interact with particles in their own cell or one of the neighboring 26 cells Grid H H

7 Particle objects have data fields such as: Density, pressure, position, velocity, acceleration, and force. Particles — Sequential SPH Iteration At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid cell For each grid cell: Retrieve all particles in cell For each particle: Find interacting particles within distance H Account for each neighbor particle’s contribution to density Calculate pressure from density Calculate inter-particle viscosity forces, pressure forces, surface tension forces, external forces, properties, and acceleration

8 Simplest, most naïve way is to assign threads to calculate particle properties independently However, certain interactions are symmetric and only need to be calculated once for a pair of particles If symmetry of interactions are exploited, the number of computations can be nearly halved to achieve a speedup of 1.6 Data races must be prevented using synchronization Density contributions and force due to pressure are symmetric Surface tension and viscosity forces are not symmetric because they depend on density, which varies for particles There are data dependencies in the algorithm which can be solved by thread synchronization with barriers Flow dependence (true dependence) of pressure on density Force due to pressure exhibits true dependence on pressure calculations Parallelization Parallel Optimizations and Data Dependencies

9 Memory Management Parallelization of SPH is usually implemented on highly parallel systems such as computer clusters and GPUs Compucter Clusters and GPUsShared Memory Architectures Limited research has been done on shared memory architectures Shared memory systems are gaining in computation power NUMA Memory Considerations Cores may have individual caches and share higher level caches Spatial/temporal locality reduces prefetching from higher levels Hardware is responsible for moving data between levels Accessing memory of other NUMA nodes is slower

10 Data Locality Z-indexing is used to index grid cells and particles are sorted according to the index Indexing with the Z-order curve ensures that neighboring cells and particle data are close in memory Z-indexing maps 3-D coordinate to 1-D The Z-index of a particle is calculated using bit interleaving (x,y,z) = (4,9,2) = (0100,1001,0010) Z-index: 010001100010 Z-Indexing Particle Sorting Introsort first time (quicksort/heapsort hybrid) Insertion sort thereafter Outperforms radix sort because it does not swap sorted particles Efficient for nearly sorted arrays (particles move short distances)

11 Memory is allocated locally relative to the thread that first accesses it Data Placement and Load Balancing Load Balancing Implicit Data Placement Threads are assigned subdomains with approximately the same number of particles Particles within a subdomain can be safely processes in parallel Particles at subdomain boundaries require synchronization Given an array of N particles and P threads, subdomains are of size N/P + k p where k p are particles of the same grid cell but initially assigned to different partitions

12 At subdomain boundaries, symmetric particle interactions may cause data races Grid cells at subdomain boundaries are colored based on their coordinate Four colors are used, determined by (i mod 2, j mod 2) Synchronization Coloring Algorithm The dot represents intra-cell particle interactions and the arrows represent inter-cell particle interactions Intra-cell particle interactions may be computed in parallel without data races Particle interactions of a single color may be processed in parallel without data races Global synchronization barriers are required after all interactions local to a thread and after each set of interactions of a single color

13

14 References [1] P. Goswami et al., “Interactive SPH Simulation and Rendering on the GPU,” in ACM SIGGRAPH Symposium on Computer Animation., 2010, pp. 1-10. [2] Y. R. López and D. Roose, “A Parallel SPH Implementation on Shared Memory Systems,” in 9th International SPHERIC Workshop., Paris, France, 2014, pp. 1-8. [3] M. Müller et al., “Particle-Based Fluid Simulation for Interactive Applications,” in SIGGRAPH Symposium on Computer Animation., 2003, pp. 1-7.


Download ppt "Smoothed Particle Hydrodynamics Matthew Zhu CSCI 5551 — Fall 2015."

Similar presentations


Ads by Google