Skip to content

Conversation

@JoshuaLampert
Copy link
Member

This allows to manually set the io, which the AnalysisCallback and SummaryCallback print to instead of using hardcoded stdout. Previously, it was possible to use redirect_stdout, but that was not so intuitive to use. The only part, which is still hardcoded to print to stdout is the final timer summary from TimerOutputs.jl from the SummaryCallback, but that is not so straightforward to allow for customization because the SummaryCallback is not an individual struct, but rather directly wrapped into a DiscreteCallback, i.e., it cannot hold any additional fields, which means that the io passed initially is forgotten at the end of the simulation.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md with its PR number.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 92.72727% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.83%. Comparing base (585f4b4) to head (35777ff).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/callbacks_step/analysis.jl 92.94% 6 Missing ⚠️
src/callbacks_step/alive.jl 87.50% 1 Missing ⚠️
src/callbacks_step/summary.jl 92.86% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2698      +/-   ##
==========================================
- Coverage   96.84%   96.83%   -0.01%     
==========================================
  Files         550      550              
  Lines       43427    43433       +6     
==========================================
+ Hits        42054    42056       +2     
- Misses       1373     1377       +4     
Flag Coverage Δ
unittests 96.83% <92.73%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@DanielDoehring
Copy link
Member

The only part, which is still hardcoded to print to stdout is the final timer summary from TimerOutputs.jl from the SummaryCallback, but that is not so straightforward to allow for customization because the SummaryCallback is not an individual struct, but rather directly wrapped into a DiscreteCallback, i.e., it cannot hold any additional fields, which means that the io passed initially is forgotten at the end of the simulation.

Ok, would you say it makes then sense to redirect only parts of the summary callback? I would in that case probably still send everything to stdout.

Copy link
Member

@DanielDoehring DanielDoehring left a comment

Choose a reason for hiding this comment

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

Could you add a redirect to file in an elixir to showcase this?

@JoshuaLampert
Copy link
Member Author

We could also make the SummaryCallback an own struct similar to the AnalysisCallback. Not sure if this counts as breaking because SummaryCallback() now returns a different object, but there should be nothing visibly that changes for the user.

@JoshuaLampert
Copy link
Member Author

Failing Documenter seems to be because of JuliaDocs/Documenter.jl#1245 and JuliaDocs/Documenter.jl#1580.

@JoshuaLampert
Copy link
Member Author

Could you add a redirect to file in an elixir to showcase this?

Done. I also added a field io to the AliveCallback.

DanielDoehring
DanielDoehring previously approved these changes Dec 8, 2025
@DanielDoehring DanielDoehring changed the title Allow passing io to AnalysisCallback and SummaryCallback Allow passing io to Analysis, Alive, and Summary Callbacks Dec 9, 2025
DanielDoehring
DanielDoehring previously approved these changes Dec 9, 2025
@JoshuaLampert
Copy link
Member Author

The Documenter.jl bug is a bit unfortunate because I don't see any good way to work around this.

@DanielDoehring
Copy link
Member

The Documenter.jl bug is a bit unfortunate because I don't see any good way to work around this

Yeah looks like we need a force merge here. Maybe you can ask on the Trixi slack

@JoshuaLampert
Copy link
Member Author

The Documenter.jl bug is a bit unfortunate because I don't see any good way to work around this

Yeah looks like we need a force merge here. Maybe you can ask on the Trixi slack

I would not do that because the failure is not spurious. It is real and comes from the changes of this PR. It is just because of a bug in Documenter.jl (or rather their helper package IOCapture.jl).

@JoshuaLampert JoshuaLampert marked this pull request as draft December 9, 2025 13:17
@ranocha
Copy link
Member

ranocha commented Dec 14, 2025

We could also make the SummaryCallback an own struct similar to the AnalysisCallback. Not sure if this counts as breaking because SummaryCallback() now returns a different object, but there should be nothing visibly that changes for the user.

That's a good idea 👍

@ranocha
Copy link
Member

ranocha commented Dec 14, 2025

The Documenter.jl bug is a bit unfortunate because I don't see any good way to work around this

Yeah looks like we need a force merge here. Maybe you can ask on the Trixi slack

I would not do that because the failure is not spurious. It is real and comes from the changes of this PR. It is just because of a bug in Documenter.jl (or rather their helper package IOCapture.jl).

Yes, that's annoying... Was there a specific application you had in mind to introduce the new feature in this PR?

@JoshuaLampert
Copy link
Member Author

Was there a specific application you had in mind to introduce the new feature in this PR?

Sometimes I want to print the output of the summary callback to stdout and the output of the analysis callback to a file (or maybe also the other way round). Sometimes I also want to conveniently switch between different ios for different callbacks without needing to fiddle around with redirect_stdout. I think we are just more flexible allowing to pass io to the callbacks.

@JoshuaLampert
Copy link
Member Author

We could also make the SummaryCallback an own struct similar to the AnalysisCallback. Not sure if this counts as breaking because SummaryCallback() now returns a different object, but there should be nothing visibly that changes for the user.

That's a good idea 👍

I did that in 35777ff.

@DanielDoehring DanielDoehring added the enhancement New feature or request label Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants