Skip to content

Cont damage fix - #1723

Open
ChrisZYJ wants to merge 23 commits into
MFlowCode:masterfrom
ChrisZYJ:cont_damage_fix
Open

Cont damage fix#1723
ChrisZYJ wants to merge 23 commits into
MFlowCode:masterfrom
ChrisZYJ:cont_damage_fix

Conversation

@ChrisZYJ

@ChrisZYJ ChrisZYJ commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

Bug fix; closes #1673.

Following #1673, this PR made the following major changes to the continuous damage model:

  • Instead of the scalar D, now it advances the conservative $U_D=m_{solid}D$ with flux $U_D u$ and source $m_{solid} \dot{D}$
  • $-p\mathbf{I}$ is included correctly in the maximum principle stress, for 1D/2D/3D
  • Energy now tracks energy related to undamaged modulus $G_0$, so the states remain finite and stable as D->1
  • D is carefully clipped to [0,1] (and projects $U_D$) after each stage

Testing

Regenerated the affected continuous damage golden files.

All CI passed on CPU and GPU.

Shock-cylinder interaction - damage evolution in the cylinder:

fig3_disk_2d_first_row

Checklist

Check these like this [x] to indicate which of the below applies.

  • I added or updated tests for new behavior
  • I updated documentation if user-facing behavior changed

See the developer guide for full coding standards.

GPU changes (expand if you modified src/simulation/)
  • GPU results match CPU results
  • Tested on NVIDIA GPU or AMD GPU

AI code reviews

Reviews are not retriggered automatically. To request a review, comment on the PR:

  • @claude full review — Claude full review (also triggers on PR open/reopen/ready)
  • Or add label claude-full-review — Claude full review via label

@ChrisZYJ

Copy link
Copy Markdown
Contributor Author

Almost done. Will update very soon.

@ChrisZYJ
ChrisZYJ marked this pull request as ready for review September 1, 2026 02:57
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.69231% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.29%. Comparing base (70589fd) to head (2f16756).

Files with missing lines Patch % Lines
src/simulation/m_data_output.fpp 9.09% 19 Missing and 1 partial ⚠️
src/simulation/m_hypoelastic.fpp 82.00% 0 Missing and 9 partials ⚠️
src/simulation/m_riemann_solver_hllc.fpp 0.00% 5 Missing and 1 partial ⚠️
src/common/m_variables_conversion.fpp 58.33% 1 Missing and 4 partials ⚠️
src/simulation/m_riemann_solver_hll.fpp 62.50% 0 Missing and 3 partials ⚠️
src/simulation/m_riemann_state.fpp 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1723      +/-   ##
==========================================
- Coverage   62.30%   62.29%   -0.02%     
==========================================
  Files          84       84              
  Lines       21583    21635      +52     
  Branches     3195     3209      +14     
==========================================
+ Hits        13448    13477      +29     
- Misses       5937     5951      +14     
- Partials     2198     2207       +9     

☔ View full report in Codecov by Harness.
📢 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.

@sbryngelson

Copy link
Copy Markdown
Member

Merged master to resolve the conflicts from #1762, which moved the elastic-energy term into f_hypoelastic_energy. The resolution keeps this PR's physics under that API: the elastic energy uses the undamaged modulus (G_K in m_variables_conversion, G_undamaged in m_data_output) and the sound speed the damaged one. That leaves master's G_damaged block in s_convert_conservative_to_primitive dead, so it is removed, together with the stress_cons copies the new API no longer needs; the Riemann private lists are master's plus solid_partial_density_L/R. Please check the G_K choice there matches your intent. Verified on the Hypoelasticity set (61 passed).

@sbryngelson
sbryngelson requested a balanced review from Copilot September 6, 2026 02:52
@ChrisZYJ

ChrisZYJ commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged master to resolve the conflicts from #1762, which moved the elastic-energy term into f_hypoelastic_energy. The resolution keeps this PR's physics under that API: the elastic energy uses the undamaged modulus (G_K in m_variables_conversion, G_undamaged in m_data_output) and the sound speed the damaged one. That leaves master's G_damaged block in s_convert_conservative_to_primitive dead, so it is removed, together with the stress_cons copies the new API no longer needs; the Riemann private lists are master's plus solid_partial_density_L/R. Please check the G_K choice there matches your intent. Verified on the Hypoelasticity set (61 passed).

Yes the G_K choice matches my intent, and all the merges look correct to me.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_hypoelastic.fpp 628 +37
src/simulation/m_data_output.fpp 1336 +26
src/simulation/m_riemann_solver_hll.fpp 615 +20
src/common/m_variables_conversion.fpp 1144 +16
src/simulation/m_riemann_solver_hllc.fpp 1284 +16
src/simulation/m_time_steppers.fpp 829 +2
Directory Lines Diff
common 9962 +16
simulation 27769 +101
total 45588 +117

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Fixes and stabilizes the continuum damage model by switching to a conservative damage carrier, correcting stress/energy handling, and enforcing bounds; updates validation, tests, and docs accordingly.

Changes:

  • Advance conservative damage carrier (U_D=m_sD) (with updated flux/source treatment) and clip/projection to physical bounds.
  • Correct maximum-principle stress to include (-p\mathbf{I}) and adjust elastic energy accounting to use undamaged modulus (G_0).
  • Update case validation rules, add/adjust regression cases, regenerate goldens, and refresh documentation/examples.

Reviewed changes

Copilot reviewed 25 out of 30 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
toolchain/mfc/test/cases.py Updates/extends regression cases for continuum damage (threshold/stress configs, adds 2-fluid axisym coverage).
toolchain/mfc/case_validator.py Tightens cont_damage validation (requires hypoelasticity; enforces parameter sign/positivity constraints).
src/simulation/m_time_steppers.fpp Enforces conservative damage bounds after each RK stage.
src/simulation/m_riemann_state.fpp Ensures hypoelastic interface energy uses undamaged modulus before damage scaling.
src/simulation/m_riemann_solver_hllc.fpp Adds conservative damage flux (U_D u) based on damageable-solid partial mass.
src/simulation/m_riemann_solver_hll.fpp Adds conservative damage flux and carries it into geometric-source flux path.
src/simulation/m_rhs.fpp Passes primitive state into damage source computation (for (-p\mathbf{I}) principal-stress evaluation).
src/simulation/m_hypoelastic.fpp Reworks damage source to use max principal Cauchy stress, weights by solid partial mass, adds bounds projection helper.
src/simulation/m_data_output.fpp Outputs damage as recovered (D=U_D/m_s); uses (G_0) for energy and damaged modulus for wave speed.
src/post_process/m_start_up.fpp Writes damage_state from primitive (D) instead of conservative carrier.
src/common/m_variables_conversion.fpp Converts conservative↔primitive damage consistently (D↔U_D), and keeps elastic energy based on (G_0).
examples/2D_cont_damage/case.py Updates and documents 2D continuum-damage demo setup (domain/driver/disk).
examples/1D_cont_damage/case.py Removes the legacy 1D continuum-damage example.
docs/references.bib Adds Spratt (2024) thesis reference for continuum damage documentation.
docs/documentation/equations.md Documents the conservative continuum damage model and its stress/energy coupling.
docs/documentation/case.md Updates cont_damage option documentation (requirements, bounds, interpretation).
tests/EF3E7C79/golden-metadata.txt Regenerated golden metadata for updated continuum damage behavior.
tests/B73DC79F/golden.txt Removes obsolete golden output for retired/changed case.
tests/B73DC79F/golden-metadata.txt Removes obsolete golden metadata for retired/changed case.
tests/6CFBCF4A/golden-metadata.txt Adds new golden metadata for newly covered regression case.
tests/5A137315/golden-metadata.txt Regenerated golden metadata.
tests/574636EE/golden-metadata.txt Regenerated golden metadata.
tests/32A3A936/golden-metadata.txt Regenerated golden metadata.
tests/0BAA2F42/golden-metadata.txt Regenerated golden metadata.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/common/m_variables_conversion.fpp
Comment thread src/simulation/m_hypoelastic.fpp
Comment thread src/simulation/m_hypoelastic.fpp
Comment thread docs/documentation/equations.md
Comment thread toolchain/mfc/test/cases.py
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.

Continuum-damage model has transport, stress-measure, principal-stress, and documentation inconsistencies

3 participants