Ib collisions#1348
Conversation
…on. Ready to collide
…that I am accessing the device copy of positions
…enerated golden files
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1348 +/- ##
==========================================
- Coverage 64.90% 64.62% -0.28%
==========================================
Files 70 71 +1
Lines 18254 18407 +153
Branches 1508 1516 +8
==========================================
+ Hits 11847 11895 +48
- Misses 5444 5555 +111
+ Partials 963 957 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
sync with master (hopefully gracefully) |
|
@sbryngelson this is ready for review |
Code reviewThorough review of the soft-sphere collision model. Found 17 issues across 4 severity levels. Critical1.
Fix: replace 2. Wrong sign on pid2 torque — Newton's third law violated for rotational DOF In torques(pid2, l) = torques(pid2, l) - torque(l)*patch_ib(pid2)%radius/patch_ib(pid1)%radiusSphere 2 receives force Fix: change 3. Division by zero when particle centroids coincide normal_vector = centroid_2 - centroid_1
overlap_distance = R1 + R2 - norm2(normal_vector)
if (overlap_distance > 0._wp) then
normal_vector = normal_vector/norm2(normal_vector)If two spheres are initialized at the same location (or drift there numerically), MFC/src/simulation/m_collisions.fpp Lines 414 to 417 in 957fcd2 4. The $:GPU_DECLARE(create='[ib_bc_x%beg, ib_bc_y%beg, ib_bc_z%beg]')But Fix: add MFC/src/simulation/m_global_parameters.fpp Lines 807 to 808 in 957fcd2 Major5. The PR correctly introduces Fix: leave MFC/src/common/m_constants.fpp Lines 28 to 29 in 957fcd2 6. @:ALLOCATE(collision_lookup(num_ibs * 8, 4))The maximum number of unique IB-IB pairs is Fix: either size analytically (e.g., MFC/src/simulation/m_collisions.fpp Line 343 in 957fcd2 7. integer, dimension(num_gps, 2) :: raw_pairs
8. Restart reader always loads most recent state, not the requested checkpoint
MFC/src/simulation/m_start_up.fpp Lines 1133 to 1143 in 957fcd2 9. Commented-out The line Line 955 in 957fcd2 Moderate10. Missing validation for damping_parameter = -2._wp*log(e)/collision_time
spring_stiffness = (pi**2 + log(e)**2)/(collision_time**2)If 11. Rotation matrix removal — unexplained physics change The PR removes Line 934 in 957fcd2 12. Torque arm inconsistency Velocity at the contact point uses the corrected arm 13. Coulomb friction cap uses total normal force instead of spring-only component tangental_force = -ib_coefficient_of_friction*norm2(normal_force)*tangental_vectorStandard DEM applies the Coulomb cap using only the elastic (spring) component: 14. O(N^2) collision deduplication on CPU After the GPU-parallel detection phase, the coalescing loop does a linear scan over Minor / Style15. Dead code: This subroutine is defined but never referenced. It also doesn't populate 16. Debug
MFC/src/simulation/m_start_up.fpp Lines 1124 to 1127 in 957fcd2 17. Module docstring is wrong
Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
|
I looked at the AI review, and none of it looks particularly plausible. It sugests things like the type of macro for MFC_MPI mattering, even though that was not demonstrated in any test, and chenging signs to be wrong a violate conservation of momentum. It is also simply wrong about the upper limit of array sizes. I don't see any comments here that make me think I need to modify the code now. |
| call s_decode_patch_periodicity(encoded_patch_id, patch_id, xp, yp, zp) | ||
| ghost_points_in(local_idx)%ib_patch_id = patch_id | ||
| ib_markers%sf(i, j, k) = patch_id | ||
| ! ib_markers%sf(i, j, k) = patch_id |
Description
Added a soft-sphere collision model for sphere/circle IB patches to collide with each other and walls. Collisions with friction were validated against references to obtain reasonable results. This code was also run on 64 MPI ranks to simulate a 10k particle case in a shock tube. Adding this feature also required the ability to restart from previous data, which was added and integrated with existing file reading. That required some refactoring of the existing IB state writing, and will require more modifications to write in parallel.
Fixes #1108
Type of change
Testing
Ran a 10k particle case as well as the new example to compare rebound angles and collision energies.
Checklist
See the developer guide for full coding standards.
AI code reviews
Reviews are not triggered automatically. To request a review, comment on the PR:
@coderabbitai review— incremental review (new changes only)@coderabbitai full review— full review from scratch/review— Qodo review/improve— Qodo code suggestions@claude full review— Claude full review (also triggers on PR open/reopen/ready)claude-full-review— Claude full review via label