Skip fiber stretch/rate computation when active stress model doesn't need it - #610
Open
dseyler wants to merge 5 commits into
Open
Skip fiber stretch/rate computation when active stress model doesn't need it#610dseyler wants to merge 5 commits into
dseyler wants to merge 5 commits into
Conversation
…iber stretch/rate. Integrator:predictor() now skips fiber kinematics when not required (~5% of total runtime)
…e closely resemble main branch
dseyler
requested review from
kko27 and
michelebucelli
and
a lite review from Copilot
August 20, 2026 18:01
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds per–active stress model flags indicating whether fiber stretch and/or fiber stretch rate are required, and updates Integrator::predictor() to compute those quantities only when needed (reducing per-step overhead for models that don’t use them).
Changes:
- Add
needs_fiber_stretch/needs_fiber_stretch_rateflags to theActiveStressbase class and plumb them throughActiveStressODE. - Update active stress model constructors to declare their stretch / stretch-rate requirements.
- Update
Integrator::predictor()to allocate stretch vectors when active stress is present, but only compute stretch/rate when required by at least one model.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Code/Source/solver/Integrator.cpp | Computes fiber stretch/rate conditionally based on active stress model needs while preserving required allocations. |
| Code/Source/solver/active_stress.h | Adds required flags to the ActiveStress API via constructor + public const members. |
| Code/Source/solver/active_stress_ode.h | Extends ActiveStressODE constructor to forward stretch/rate requirement flags. |
| Code/Source/solver/active_stress_uniform_unsteady.h | Declares uniform-unsteady model does not require stretch or stretch rate. |
| Code/Source/solver/active_stress_uniform_steady.h | Declares uniform-steady model does not require stretch or stretch rate. |
| Code/Source/solver/active_stress_regazzoni.h | Declares Regazzoni model requires stretch and stretch rate. |
| Code/Source/solver/active_stress_nash_panfilov.h | Declares Nash–Panfilov model does not require stretch or stretch rate. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
466
to
+468
| // Determine if we need to compute fiber stretch and stretch rate, by going | ||
| // through all domains of all equations until we find one for which active | ||
| // stress is enabled. | ||
| // stress is enabled and the active stres model needs the stretch or stretch rate. |
Comment on lines
+520
to
524
| if (have_active_stress) { | ||
| fiber_stretch_rate.resize(com_mod.tnNo); | ||
|
|
||
| if (fiber_stretch_eq_index >= 0) { | ||
| if (need_fiber_stretch_rate && fiber_stretch_eq_index >= 0) { | ||
| for (const auto &mesh : com_mod.msh) { |
Comment on lines
+126
to
+128
| RegazzoniActiveStress() : ActiveStress(/* n_state_variables = */ n_state_variables, | ||
| /* needs_fiber_stretch = */ true, | ||
| /* needs_fiber_stretch_rate = */ true) {} |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #610 +/- ##
=======================================
Coverage 72.73% 72.73%
=======================================
Files 255 255
Lines 39290 39300 +10
Branches 6726 6726
=======================================
+ Hits 28576 28586 +10
Misses 10472 10472
Partials 242 242 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current situation
As discussed in issue #604, this PR adds flags stating whether each active stress model needs to use fiber stretch or stretch rate. Computing these quantities at each time step was quite expensive (~5% of total runtime for 500k element simulation), so it makes sense to skip when the active stress model does not need them.
In active_stress.h:
In each active stress model:
Then Integrator::predictor() determines when stretch and stretch rate should be computed:
Release Notes
Testing
Please ensure that the PR meets the testing requirements set by GitHub Actions.
In addition, please ensure all modified and new code is covered by tests.
Code of Conduct & Contributing Guidelines