12
Smoothed Particle Hydrodynamics Matthew Zhu

Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

Embed Size (px)

Citation preview

Page 1: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

Smoothed Particle Hydrodynamics

Matthew Zhu

Page 2: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid
Page 3: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid cell

Particles — Sequential Particle Interactions

Particle objects have data fields such as: Density, pressure, position, velocity, acceleration,

and force.

For each grid cell: Retrieve all particles in cell For each particle:

Find interacting particles within distance H Calculate inter-particle viscosity forces,

pressure forces, surface tension forces, external forces, properties, and acceleration

Account for each neighbor particle’s contribution to density

Calculate pressure from density

Page 4: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

Trivially Parallelizable SPH Simulation

Each thread accesses a particle, finds the particle’s neighbors, and computes their force contributions.

Simulation using four threads

Page 5: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

Symmetrizing Particle Interactions

Scalar Field Quantity

Derived Pressure

Symmetrized Pressure

Derived Viscosity

Symmetrized Viscosity

Density is averaged between particles for both symmetrized pressure and viscosity Symmetrized pressure force uses average pressure of two particles Symmetrized viscosity force uses the relative velocity of the particles

Page 6: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

Accounting for Symmetric Contributions

A data race occurs if two particles try to access each other simultaneously

Each thread accesses a particle, finds the particle’s neighbors, and applies forces to both the particle and its neighbors.

After a particle has been accounted for, it may be removed from the

current iteration

Page 7: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

Dividing Workload

Particles keep track of grid cells and z-index

Particle array sorted by z-indices

Thread 1 Thread 2 Thread 3 Thread 4

Apply cell-fitting procedure

Page 8: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

Two-dimensional Coloring Algorithm

Interaction PatternOn cell (0, 0)

Chromatic Number: 4

Interactions of a single color may be processed in parallel without data races

Four passes are required to process all interactions

Page 9: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

Generalization to Three Dimensions

(0,0,0)

(1,0,0)

(1,0,1)

(0,0,1)

(1,1,0)

(0,1,0)

(0,1,1)

(1,1,1)

3D Interaction Pattern

To determine the color of a cell:

Chromatic Number: 8

(x mod 2, y mod 2, z mod 2) yields one of eight possible colors

For example,the grid cell at (9, 9, 8) is assigned the color red

Page 10: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

Simulation Algorithm — Particle Interactions

(9,9,8)

(10,9,8)

(10,9,9)

(9,9,9)

(10,10,8)

(9,10,8)

(9,10,9)

(10,10,9)

Thread 1

Thread 2 Local Interaction ListColor Interaction List[red]

For each local cell: For each pair of cells in the interaction pattern:

(pattern includes interactions within a cell represented by dot)

(9,9,8) (9,9,8)

If cells are local to thread add pair to local interaction list

Otherwise add pair to interaction list of the cell’s color

(9,9,8) (9,9,9)(9,9,8) (10,9,9)(9,9,8) (10,10,9)(9,9,9) (9,10,8)(9,9,8) (10,9,8)(9,9,8) (9,10,9)(9,9,8) (9,10,8)(9,9,9) (10,10,8)(9,9,8) (10,10,8)(9,9,9) (10,9,8)(9,10,8) (10,9,9)(9,10,9) (10,9,8)(9,10,8) (10,9,8)

Page 11: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

Simulation Algorithm — Physics Computation

Each thread in parallel:for each interaction in localList

computeInteractions(interaction)barrierfor each color in colors

for each interaction in colorList[color]

computeInteractions(interaction)barrier

Local List Color List

(9,9,8) (9,9,8)

(9,9,8) (9,9,9)

(9,9,8) (10,9,9)

(9,9,8) (10,10,9)

(9,9,9) (9,10,8)

(9,9,8) (10,9,8)

(9,9,8) (9,10,9)

(9,9,8) (9,10,8) (9,9,9) (10,10,8)

(9,9,8) (10,10,8)

(9,9,9) (10,9,8)

(9,10,8) (10,9,9)

(9,10,9) (10,9,8)

(9,10,8) (10,9,8)

Page 12: Matthew Zhu. At each time step calculate each particle’s acceleration and use Verlet numerical integration to update its position, velocity, and grid

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.