Skip to content

Fix issues with history output - #624

Open
michelebucelli wants to merge 10 commits into
SimVascular:mainfrom
michelebucelli:fix/history-output
Open

Fix issues with history output#624
michelebucelli wants to merge 10 commits into
SimVascular:mainfrom
michelebucelli:fix/history-output

Conversation

@michelebucelli

Copy link
Copy Markdown
Collaborator

Fixes #615 about incorrect reporting of iterations in multi-equation simulations. Also adds some cosmetic improvements to the history table. See the issue for details.

This has no effect on calculations, but only on convergence history reporting.

Code of Conduct & Contributing Guidelines

@michelebucelli
michelebucelli requested review from ktbolt and zasexton and a lite review from Copilot August 27, 2026 23:19

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@michelebucelli michelebucelli self-assigned this Aug 27, 2026
@michelebucelli michelebucelli changed the title Fix/history output Fix issues with history output Aug 27, 2026

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.

Pull request overview

This PR addresses incorrect convergence history reporting in multi-equation simulations (Fixes #615) by restructuring when/where history rows are emitted, and by reformatting the history table for consistent fixed-width alignment.

Changes:

  • Introduce output::output_header() and refactor output::output_result() to generate aligned, fixed-width history output (including improved separator handling).
  • Move history row emission into Integrator::step() so every Newton iteration (including the converged one) is printed exactly once, with an s flag when VTU output is scheduled.
  • Simplify VTU-save decision logic in main.cpp and pass it into Integrator::step(save_vtu).

Reviewed changes

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

Show a summary per file
File Description
Code/Source/solver/output.h Adds output_header() and updates output_result() API/documentation.
Code/Source/solver/output.cpp Implements header printing + fixed-width row formatting and separator generation.
Code/Source/solver/main.cpp Computes save_vtu, passes it to Integrator::step(), and streamlines VTU write logic.
Code/Source/solver/Integrator.h Extends step() signature to accept save_results flag (defaulted).
Code/Source/solver/Integrator.cpp Emits one history row per Newton iteration (including converged) from within step().
Code/Source/solver/initialize.cpp Switches history initialization from output_result(co=1) to output_header().

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

Comment thread Code/Source/solver/output.cpp Outdated
Comment thread Code/Source/solver/output.cpp
@michelebucelli
michelebucelli requested a review from kko27 August 27, 2026 23:31
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.86%. Comparing base (9ff6e43) to head (a7b4688).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #624   +/-   ##
=======================================
  Coverage   72.86%   72.86%           
=======================================
  Files         258      258           
  Lines       39500    39490   -10     
  Branches     6730     6726    -4     
=======================================
- Hits        28780    28773    -7     
+ Misses      10477    10474    -3     
  Partials      243      243           

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

@zasexton zasexton left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks good to me

@kko27 kko27 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.

Thanks so much @michelebucelli! The changes look great! Have two minor comments.

Comment thread Code/Source/solver/main.cpp Outdated
Comment on lines 254 to 255
bool l1 = false;
bool l2 = false;

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.

Is there a possibility of also replacing these boolean flags with more meaningful variable names, or removing them? Not sure if that increases the scope of this PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done, as follows:

  1. l1 was only used in a statement like l1 = expression_A; if (expression_B && l1) { ... }. I removed the variable l1 entirely, and replaced that statement with if (expression_B && expression_A) { ... }. Since the two expressions were slightly obscure due to the variables involved having somewhat cryptic names (to me at least), I included comments to explain the meaning of both (I'd rather not go on a variable renaming spree at this time 😅 ).
  2. l2 was used similarly, although its value was printed by a debug statement as well so it couldn't be removed without changing behavior. I moved its declaration down to where it is used, and gave it the more explicit name is_restart_output_step.
  3. There was another l1 variable, declared in the while loop (and thus hiding the l1 variable here). I also renamed it to reached_stop_time_step.

Conceivably there's a bit more cleanup to be done in the main function code along these lines (making variables as local as possible, giving more expressive names, removing unused variables), but maybe we can save it for a more scoped issue.

Comment thread Code/Source/solver/output.cpp
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.

Various issues with history standard output in electromechanics simulations

4 participants