-
Notifications
You must be signed in to change notification settings - Fork 391
Description
Description
Suggestion: Implement native, efficient support within Warp for managing persistent neighbor relationships, specifically tailored for bonded particle contacts in Discrete Element Method (DEM) simulations.
Context
Motivation:
Warp's current hash grid implementation (wp.hash_grid and wp.hash_grid_query) is exceptionally fast and efficient for simulating granular materials (non-bonded particles) where contacts are transient and primarily based on spatial proximity each timestep.
However, many critical engineering and scientific applications involve cohesive or bonded materials. Examples include:
- Geomechanics: Rock masses, cohesive soils, cemented sands.
- Materials Science: Sintered powders, ceramics, composites, particle agglomeration.
- Civil Engineering: Asphalt, concrete degradation.
- Biomechanics: Tissue modeling, cell clusters.
The Problem with Current Methods:
In simulations with bonded materials, particle bonds (representing chemical cementation, sintering necks, physical cohesion, etc.) form and must persist based on physical criteria (e.g., stress/strain limits), even if the bonded particles temporarily move slightly outside the standard spatial query radius (max_dist in wp.hash_grid_query).
The current approach, relying solely on wp.hash_grid_query within the force calculation kernel each timestep, faces significant challenges for bonded materials:
- Incorrect Bond Dropping: If bonded particles
iandjseparate slightly beyondmax_distdue to vibrations or relative motion,wp.hash_grid_querywill no longer report them as neighbors. Consequently, the bond force calculation is skipped, effectively breaking the bond prematurely and leading to physically incorrect simulation results. - Performance Penalty of Manual Management: Implementing bond management manually within user kernels (e.g., creating explicit neighbor lists per particle, using atomic counters to build global pair lists
(i, j)wherei < j, searching these lists to check for existing bonds before adding new ones, managing bond breakage flags, and performing list compaction) introduces severe performance overhead. This involves:- High atomic contention when updating global lists.
- Complex data management logic within kernels.
- Potentially poor memory access patterns.
- Significant reduction in the performance advantage that Warp otherwise provides.
Proposed Solution:
We request the introduction of a dedicated, optimized mechanism within Warp for managing persistent neighbor relationships (bonds). This could potentially take the form of:
- A new Warp data structure (e.g.,
wp.BondList,wp.PersistentContacts). - Associated functions/methods optimized for GPU execution, potentially including:
wp.bond_list_build(...): A function to update the bond list based on particle positions and user-defined criteria kernels (for both bond formation and breakage). This should handle duplicate prevention internally (e.g., only storing(i, j)ifi < j).wp.bond_list_query_pairs(...): A function that efficiently returns arrays (bond_indices_i,bond_indices_j) or an iterable object representing the currently active bond pairs, suitable for direct use in force calculation kernels.wp.bond_list_compact(...): (Optional but highly useful) An efficient parallel compaction function to remove broken bonds and keep the list dense for optimal iteration performance.
Why Native Support is Crucial:
- Performance: A native C++/CUDA implementation managed by Warp can leverage highly optimized parallel algorithms (prefix sums, stream compaction, specialized hash tables or graph structures) far beyond what users can efficiently implement purely at the Warp kernel level. This is essential for maintaining high performance.
- Correctness & Robustness: Provides a reliable, tested mechanism for handling bond persistence, eliminating a major source of errors in user implementations.
- Ease of Use: Greatly simplifies the complexity for users wanting to simulate bonded materials, making Warp more accessible and powerful for a broader range of scientific and engineering problems.
Additional Considerations for Implementation:
- Bond Data Association: How can users associate custom data (e.g., initial bond length, stiffness, strength, damage variables, bond type ID) with each bond? Allowing linkage to user-defined
wp.structarrays indexed by the bond pair would be powerful. - Criteria Flexibility: The bond formation and breakage checks should ideally accept user-defined
wp.funcor kernel pointers for maximum flexibility. - Efficient Existence Check: A fast mechanism to check if a bond between
iandjalready exists would be beneficial, especially during the bond formation step. - Memory Management: Clear strategies for allocation, potential resizing, or handling overflow if the number of bonds exceeds the initial capacity.
- Workflow: How would this system integrate with
wp.hash_grid_query? (e.g., usingwp.hash_grid_queryfor standard repulsive/frictional contacts and potential new bond detection, then using the bond system for persistent force calculation and breakage checks).
Benefits:
- Enables efficient and physically accurate simulation of bonded particulate systems, significantly expanding Warp's applicability.
- Reduces user code complexity and potential for errors.
- Aligns Warp's capabilities more closely with features found in established (but often slower) CPU-based DEM packages.
Thank you for considering this request. Adding robust support for bonded contacts would be a highly valuable addition to the Warp framework.