IBM force calculation simplification (Dr Bala recommendations)#1234
IBM force calculation simplification (Dr Bala recommendations)#1234mrvandenboom wants to merge 4 commits intoMFlowCode:masterfrom
Conversation
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
📝 WalkthroughWalkthroughThe IBM simulation module undergoes internal refactoring of force and torque computation logic. The changes reorganize how viscous stress derivatives are processed—shifting from atomic updates interleaved with force/torque calculations to incremental computation of x, y, and z divergence components with deferred torque updates that occur via cross-product at the end of Jacobian cell processing. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Nitpicks 🔍
|
|
CodeAnt AI finished reviewing your PR. |
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.
| 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 | ||
| local_force_contribution(1:3) = local_force_contribution(1:3) + viscous_stress_div(3, 1:3) ! add the z components of the divergence to the force | ||
| end if | ||
|
|
There was a problem hiding this comment.
Trailing whitespace — this is causing the CI formatting failure.
Line 1130 appears to contain trailing whitespace. The pipeline log confirms: formatting diff found in m_ibm.fpp. Remove the trailing spaces to pass the ./mfc.sh format check.
🔧 Fix trailing whitespace
-
+📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/simulation/m_ibm.fpp` at 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:
|
|
CodeAnt AI is running Incremental review Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
CodeAnt AI Incremental review completed. |
|
CodeAnt AI is running Incremental review Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
CodeAnt AI Incremental review completed. |
Claude Code ReviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Claude Code ReviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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 per-point computation and contention during 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.