Skip to content

Fiber Stretch and Stretch Rate Computations#550

Open
kko27 wants to merge 15 commits into
SimVascular:mainfrom
kko27:#544_fibstretchpost
Open

Fiber Stretch and Stretch Rate Computations#550
kko27 wants to merge 15 commits into
SimVascular:mainfrom
kko27:#544_fibstretchpost

Conversation

@kko27
Copy link
Copy Markdown
Contributor

@kko27 kko27 commented May 20, 2026

Current situation

Resolves #544

Release Notes

  • Added fiber stretch rate computation routine in post.cpp. Stretch rate is computed as a FD of fiber stretch
  • Added integration test for stretch and stretch rates

Testing

Integration test has been added that checks if the stretch and stretch rates computed by the code match reference solutions that were obtained analytically.

Code of Conduct & Contributing Guidelines

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 81.81818% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.02%. Comparing base (ed4c544) to head (b0cdc87).

Files with missing lines Patch % Lines
Code/Source/solver/post.cpp 76.78% 13 Missing ⚠️
Code/Source/solver/cep_ion.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #550      +/-   ##
==========================================
+ Coverage   68.80%   69.02%   +0.21%     
==========================================
  Files         181      181              
  Lines       34157    34128      -29     
  Branches     5903     5904       +1     
==========================================
+ Hits        23503    23557      +54     
+ Misses      10517    10434      -83     
  Partials      137      137              

☔ 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.

Copy link
Copy Markdown
Collaborator

@aabrown100-git aabrown100-git left a comment

Choose a reason for hiding this comment

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

Nice work, made a few suggestions

Comment thread Code/Source/solver/post.cpp Outdated
Comment thread Code/Source/solver/post.cpp
Comment thread Code/Source/solver/vtk_xml.cpp Outdated
Comment thread tests/cases/struct/uniaxial_block_stretch/fiberstretch.png
Copy link
Copy Markdown
Collaborator

@michelebucelli michelebucelli left a comment

Choose a reason for hiding this comment

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

Thank you @kko27! I have left a few suggestions and comments.

Comment thread Code/Source/solver/consts.h Outdated
Comment thread Code/Source/solver/post.cpp Outdated
Comment thread Code/Source/solver/post.cpp Outdated
Comment thread Code/Source/solver/post.cpp
Comment thread Code/Source/solver/vtk_xml.cpp Outdated
Comment thread Code/Source/solver/post.cpp Outdated
Comment thread Code/Source/solver/post.cpp
Comment thread Code/Source/solver/post.cpp Outdated
Comment thread Code/Source/solver/post.cpp Outdated
Comment thread Code/Source/solver/post.cpp
Comment thread Code/Source/solver/post.cpp Outdated
Comment thread Code/Source/solver/post.cpp Outdated
Comment thread Code/Source/solver/post.cpp Outdated
@javijv4
Copy link
Copy Markdown
Contributor

javijv4 commented May 21, 2026

Hey @kko27, thanks for working on this. Besides the comments I left, I asked Codex to run a review, and it found this issue:

In cep_ion.cpp (line 160), post::fib_stretch(simulation, iEq, ...) is called with iEq for the CEP equation. But compute_fib_stretch() (line 745) uses com_mod.eq[iEq].s at post.cpp (line 757) to choose which rows of the global displacement state feed F at post.cpp (line 791). In a coupled CEP+struct run, the CEP equation’s s is not the structural displacement offset, so the stretch-activated current path can be driven by unrelated data.

I think it's right. You are passing the EP index equation, not the mechanics, to fib_stretch, so that's going to fail. I don't think this PR addresses the electromechanics coupling, so this is a future issue, but it might be worth commenting out (or deleting?) the fib_stretch call in cep_ion.cpp until we have tested it?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds solver support and a new integration case to compute and validate fiber stretch and fiber stretch rate outputs needed for electromechanics post-processing (resolves #544).

Changes:

  • Introduces Fiber_stretch and Fiber_stretch_rate outputs end-to-end (enums, output properties, VTU writer, post-processing routines).
  • Refactors deformation gradient computation into a shared helper and implements stretch rate via backward finite difference.
  • Adds a new structural integration test case (uniaxial_block_stretch) with reference results for both fields.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Code/Source/solver/post.cpp Adds fiber stretch + stretch-rate post routines; refactors deformation gradient usage.
Code/Source/solver/post.h Declares new/renamed post-processing APIs (fib_stretch, fib_stretch_rate).
Code/Source/solver/vtk_xml.cpp Writes new scalar nodal outputs to VTU (Fiber_stretch, Fiber_stretch_rate).
Code/Source/solver/consts.h Extends OutputNameType with new output groups and output names.
Code/Source/solver/set_output_props.h Registers output props (group, length, VTK name strings) for new outputs.
Code/Source/solver/set_equation_props.h Adds new outputs to struct/ustruct default output lists and updates nDOP.
Code/Source/solver/cep_ion.cpp Updates call site to renamed post::fib_stretch().
tests/conftest.py Adds absolute tolerances for the new output fields in reference comparisons.
tests/test_struct.py Adds integration test entry for the new uniaxial block stretch case.
tests/cases/struct/uniaxial_block_stretch/* New integration test case assets (solver input, mesh, load, reference VTU, docs/media).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Code/Source/solver/post.cpp
Comment thread Code/Source/solver/post.cpp Outdated
@kko27
Copy link
Copy Markdown
Contributor Author

kko27 commented May 22, 2026

Hey @kko27, thanks for working on this. Besides the comments I left, I asked Codex to run a review, and it found this issue:

In cep_ion.cpp (line 160), post::fib_stretch(simulation, iEq, ...) is called with iEq for the CEP equation. But compute_fib_stretch() (line 745) uses com_mod.eq[iEq].s at post.cpp (line 757) to choose which rows of the global displacement state feed F at post.cpp (line 791). In a coupled CEP+struct run, the CEP equation’s s is not the structural displacement offset, so the stretch-activated current path can be driven by unrelated data.

I think it's right. You are passing the EP index equation, not the mechanics, to fib_stretch, so that's going to fail. I don't think this PR addresses the electromechanics coupling, so this is a future issue, but it might be worth commenting out (or deleting?) the fib_stretch call in cep_ion.cpp until we have tested it?

Oh dear, this will definitely become a problem for coupling. We don't need to address this in this issue as right now users cannot enable electromechanics coupling, but I will add this note to the main issue #523

@kko27
Copy link
Copy Markdown
Contributor Author

kko27 commented May 22, 2026

@michelebucelli and @javijv4 I think this is ready for final review and approval

Copy link
Copy Markdown
Contributor

@javijv4 javijv4 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post-processing of fiber stretch and stretch rates

6 participants