IBM force calculation simplification (Dr Bala recommendations)#1234
IBM force calculation simplification (Dr Bala recommendations)#1234mrvandenboom wants to merge 7 commits intoMFlowCode:masterfrom
Conversation
Nitpicks 🔍
|
There was a problem hiding this comment.
Pull request overview
Refactors immersed-boundary (IBM) force/torque accumulation in simulation to simplify the force/torque calculation by leveraging tensor symmetry/asymmetry characteristics, per Dr. Bala’s recommendations.
Changes:
- Simplifies viscous-force contribution assembly by removing per-component cross-product derivatives.
- Computes torque via a single
r × Fcross product after all force contributions are accumulated. - Reorders/clarifies some inline comments around viscous contribution and atomic updates.
| end do | ||
| viscous_stress_div = (viscous_cross_2 - viscous_cross_1)/(2._wp*dz) | ||
| local_torque_contribution(1:3) = local_torque_contribution(1:3) + viscous_stress_div(3, 1:3) | ||
| viscous_stress_div(3, 1:3) = (viscous_stress_div_2(3, 1:3) - viscous_stress_div_1(3, 1:3))/(2._wp*dz) ! get z derivative of the second-row of viscous stress tensor |
There was a problem hiding this comment.
Inline comment is incorrect: this statement computes the z-derivative of the third row (index 3) of the viscous stress tensor, not the second row. Please update the comment to avoid confusion for future maintenance.
| viscous_stress_div(3, 1:3) = (viscous_stress_div_2(3, 1:3) - viscous_stress_div_1(3, 1:3))/(2._wp*dz) ! get z derivative of the second-row of viscous stress tensor | |
| viscous_stress_div(3, 1:3) = (viscous_stress_div_2(3, 1:3) - viscous_stress_div_1(3, 1:3))/(2._wp*dz) ! get z derivative of the third-row of viscous stress tensor |
|
|
||
| call s_cross_product(radial_vector, local_force_contribution, local_torque_contribution) | ||
|
|
||
| ! Update the force values atomically to prevent race conditions |
There was a problem hiding this comment.
This comment says only the force is updated atomically, but the loop performs atomic updates for both forces and torques. Consider updating the comment to reflect both arrays to prevent misleading documentation.
| ! Update the force values atomically to prevent race conditions | |
| ! Update the force and torque values atomically to prevent race conditions |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/simulation/m_ibm.fpp`:
- Line 1130: Remove the trailing whitespace on the blank line flagged by CI (a
line that contains only spaces) in the m_ibm.fpp source so the formatter passes;
locate the empty/blank line in the file, delete the trailing spaces (convert it
to a truly empty line), run ./mfc.sh format to verify no formatting diffs
remain, and commit the change.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1234 +/- ##
=======================================
Coverage 44.05% 44.06%
=======================================
Files 70 70
Lines 20496 20481 -15
Branches 1989 1989
=======================================
- Hits 9030 9024 -6
+ Misses 10328 10319 -9
Partials 1138 1138 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Claude Code Review1 file changed: Summary
FindingsIssue 1 — Dead variables left in declaration and GPU private clause (m_ibm.fpp)
Line ~1053 (variable declaration): real(wp), dimension(1:3, 1:3) :: viscous_stress_div, viscous_stress_div_1, viscous_stress_div_2, viscous_cross_1, viscous_cross_2Line ~1074 (GPU_PARALLEL_LOOP private clause): $:GPU_PARALLEL_LOOP(private='[... viscous_cross_1, viscous_cross_2, ...]', ...)These should be removed. On GPU builds the unused private allocations are harmless but waste per-thread stack space, and they create misleading code. The Recommendation: Remove Issue 2 — Incorrect comment on z-direction block (m_ibm.fpp)The new z-direction line says "second-row" but indexes row 3: viscous_stress_div(3, 1:3) = (viscous_stress_div_2(3, 1:3) - viscous_stress_div_1(3, 1:3))/(2._wp*dz) ! get z derivative of the second-row of viscous stress tensorThis is a copy-paste error from the y-direction comment. It should read "third-row". Issue 3 — GPU test coverage not confirmedThis PR modifies code in Improvement Opportunities
|
User description
(cherry picked from commit 2a034dc) (cherry picked from commit 1d8b109)
Description
This change takes advantage of the symmetric and asymmetric attributes of the tensors to simplify the calculation of force and torque on immersed boundaries.
Type of change
Testing
ran ./mfc.sh lint
ran ./mfc.sh format
ran ./mfc.sh test -a on Hipergator (CPU). All tests passed.
Summary by CodeRabbit
CodeAnt-AI Description
Compute torque from combined pressure and viscous forces and reduce atomic updates
What Changed
Impact
✅ Correct torque from combined pressure and viscous contributions✅ Fewer atomic updates during force/torque assembly✅ Lower contention during per-point force assembly💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.