Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Compatible Particle-In-Cel (CPIC) Particle-Rigid-Body Coupling #3

Open
wants to merge 47 commits into
base: master
Choose a base branch
from

Conversation

kurtkuehnert
Copy link
Contributor

@kurtkuehnert kurtkuehnert commented Mar 14, 2023

This PR implements the CPIC algorithm of the "Moving Least Squares Material Point Method" paper.
Its purpose is to couple the GPU particle simulation (sparkl) with the CPU rigid body simulation (rapier).

Therefore we generate a set of evenly spaced rigid particles across the surface of all rigid bodies. These particles are then used to build the Colored Distance Field (CDF) stored as part of the simulation grid. The CDF is a convenient data structure for performing inside/outside queries against all colliders. It stores the adjacency information, a tag indicating, which side of the collider it is on, and the unsigned distance to the closest collider. This gird CDF is then interpolated using the robust MLS technique for each particle of the simulation. Subsequently, the CPIC algorithm partitions the grid nodes surrounding each particle into two sets (compatible/incompatible) based on their affinity and tag information. These sets are handled differently during particle-to-grid and grid-to-particle transfer. The compatible nodes (i.e. the nodes that the particle has not collided with) are the only ones that are influenced by the particle in the p2g phase.
For the g2p phase all compatible nodes are updated. The incompatible nodes (i.e. the node that the particle has collided with) are projected alongside the collider surface using the reconstructed CDF data. Thereby they apply an impulse on the rigid body and a penalty force onto themselves, to avoid penetrating the colliders.

Additionally, this PR updates the examples (and adds a couple of new ones) to showcase these new capabilities.
Finally, I have added a visualization UI to debug the state of the particles, the grid, and the rigid particles.

Todo:

  • Generate rigid particles
  • Visualize rigid particles
  • Write CDF update kernel (basic)
  • Visualize the grid
  • Visualize the CDF
  • Implement CDF triangle check
  • Improve the performance of the CDF generation (better threading)
  • Reconstruct particle CDF for a single collider
  • Visualize the particle CDF for a single collider
  • Reconstruct particle CDF for multiple colliders
  • Implement CPIC particle-to-grid
  • Implement CPIC grid-to-particle
  • Add a nice debug visualization UI
  • Add cutting example
  • Handle collisions with multiple colliders
  • Add 2D CDF generation
  • Update the 2D examples
  • Apply penalty force
  • Take collider velocity into account (proper one-way coupling)
  • Make CDF colliders optional
  • Clean up the examples
  • Apply impulse back to colliders (two-way coupling)
  • Add a waterwheel example
  • Update the PTX files before merging

Future Improvements:

  • Resolve all outstanding simulation issues (particle drifting, explosions, etc.)
  • Figure out a way to always use the CDF colliders instead of the grid-based ones
  • Sort rigid particles to avoid overwriting the tag during the CDF update (alternatively store signed distance per collider)

Copy link
Member

@sebcrozet sebcrozet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This approach is great. I think we can generalize it to 2D too.

src/cuda/generate_rigid_particles.rs Outdated Show resolved Hide resolved
@kurtkuehnert kurtkuehnert changed the title Generate CDF Implement Compatible Particle-In-Cel (CPIC) Particle-Rigid-Body Coupling Apr 7, 2023
@kurtkuehnert kurtkuehnert marked this pull request as ready for review April 11, 2023 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants