Skip to content

refactor: simplify hypoelastic source terms in m_hypoelastic.fpp#1399

Open
sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
sbryngelson:refactor/hypoelastic-simplify-source-terms
Open

refactor: simplify hypoelastic source terms in m_hypoelastic.fpp#1399
sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
sbryngelson:refactor/hypoelastic-simplify-source-terms

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

Summary

Addresses #1343 (readability only — no correctness change).

The source term formula is $S^e_{ij} = \rho(l_{ik}\tau_{kj} + \tau_{ik}l^T_{kj} - \tau_{ij},\mathrm{tr}(\mathbf{D}) + 2G,D^d_{ij})$. Because $\mathbf{l}\tau + \tau\mathbf{l}^T$ is symmetric and doubles the off-diagonal contributions, the old code wrote e.g. τ_12*du_dy + τ_12*du_dy as two separate lines. The zero-sum pairs (e.g. + τ_12*du_dx - τ_12*du_dx in the τ_12 update) are algebraic cancellations from expanding $\mathbf{l}\tau + \tau\mathbf{l}^T$ before simplifying.

This PR collapses each duplicate pair to 2._wp * τ * dv and removes the zero-sum pairs, making the code match the formula directly. The change is purely cosmetic: no numerical values change.

Changes

src/simulation/m_hypoelastic.fpp, idir == 2 and idir == 3 blocks:

  • Collapse x + x2._wp*x for the doubled off-diagonal rotation terms
  • Drop +a - a zero-sum pairs in the τ_12, τ_13, τ_23 shear updates
  • Simplify 2._wp*G*(1._wp/2._wp)*...G*... and 2._wp*G*(1._wp/3._wp)*...(2._wp/3._wp)*G*...

Net: 36 lines → 19 lines (−17 lines).

Test plan

  • Hypoelastic regression tests pass (results must be bit-identical to master)

@qodo-code-review
Copy link
Copy Markdown
Contributor

ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@sbryngelson has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 38 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1ae807ad-a492-4579-86d5-8a9deabcff47

📥 Commits

Reviewing files that changed from the base of the PR and between d513442 and 8c1f7ef.

📒 Files selected for processing (1)
  • src/simulation/m_hypoelastic.fpp

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sbryngelson
Copy link
Copy Markdown
Member Author

Automated Code Review

Summary: No issues found. ✅

Performed term-by-term algebraic verification of every simplification in the idir==2 and idir==3 blocks:

  • tau_xy*du_dy + tau_xy*du_dy2._wp*tau_xy*du_dy
  • 2._wp*G*(1._wp/3._wp)(2._wp/3._wp)*G
  • 2._wp*G*(1._wp/2._wp)G
  • All zero-sum cancelling pairs (+a - a) correctly dropped ✓
  • Off-diagonal rotation terms correctly identified and collapsed ✓

All simplifications are algebraically exact. Precision conventions respected throughout (2._wp, (2._wp/3._wp), no d0 literals). No raw GPU pragmas introduced. Safe to merge.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.75%. Comparing base (d513442) to head (8c1f7ef).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1399   +/-   ##
=======================================
  Coverage   64.75%   64.75%           
=======================================
  Files          71       71           
  Lines       18721    18721           
  Branches     1551     1551           
=======================================
  Hits        12123    12123           
  Misses       5640     5640           
  Partials      958      958           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Possible duplicate/canceling terms in hypoelastic stress rate (m_hypoelastic.fpp)

1 participant