ParticleCollision

SmoothParticleNets

Description

The ParticleCollision layer pre-computes neighbor lists (i.e., “colliding” particles) for each given particle. That is, given a list of particle positions and a fixed radius, this layer returns a short list for each particle with the index of all other particles that are within that radius of it. To do this, internally the ParticleCollision layer creates a hashgrid and performs lookups based on that grid. The resulting neighbor list is designed to be used by the ConvSP layer to compute particle-particle interactions.

An important operation that this layer does alongside computing collisions is to reorder the particle list. The reordering places particles falling in the same grid cell in the hash grid next to each other in memory. By doing so, cache hits are increased dramatically during the computation of particle-particle interactions in ConvSP, resulting in a large speedup. Due to this reordering, the returned list of colliding neighbor indices are indices in the reordered list, not in the original. The standard use of this layer is to compute collisions, make as many calls to ConvSP as are desired, then use the ReorderData layer to return the particle list to its original order. It is important to emphasize that reordering the data according to the hash grid is critical for perfomance of the ConvSP layer.

ParticleCollision is implemented as a subclass of torch.nn.Module. This allows it to be used in the same manner as any other PyTorch layer (e.g., conv2d). There are no gradients to compute for this layer, so it simply passes them through when calling backward.

Example

Assume locs is a BxNxD tensor containing the locations of N D-dimensional particles across B batches and vel is a same size tensor containing the particle’s velocities.

coll = ParticleCollision(ndim, radius)
# PartileCollision reorders locs and vel.
locs, vel, idxs, neighbors = coll(locs, vel)

Documentation

ParticleCollision provides two functions: a constructor and forward. Forward is called by calling the layer object itself (in the same manner as any standard PyTorch layer).