Skip to content

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

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

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)

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