Skip to content

[codex] Fix density reinitialization callback#1181

Open
svchb wants to merge 3 commits into
trixi-framework:mainfrom
svchb:codex/fix-density-reinit-callback
Open

[codex] Fix density reinitialization callback#1181
svchb wants to merge 3 commits into
trixi-framework:mainfrom
svchb:codex/fix-density-reinit-callback

Conversation

@svchb
Copy link
Copy Markdown
Collaborator

@svchb svchb commented May 11, 2026

Summary

  • store the particle system passed to DensityReinitializationCallback and reinitialize only that system
  • trigger dt-based reinitialization when the requested interval is reached, not only after it is exceeded
  • mark the integrator state as modified after density and pressure fields are changed
  • add focused unit coverage for show output, dt triggering, and selected-system reinitialization

Root Cause

The callback constructor accepted a specific particle system, but the affect path called the global reinit_density!(vu_ode, semi) helper, which loops over every system in the semidiscretization. The time-based condition also used a strict > comparison, delaying callbacks that land exactly on the configured interval.

Validation

  • julia --project=. -e 'using Test, TrixiParticles; include("test/callbacks/density_reinit.jl")'\n- julia --project=. -e 'using Test, TrixiParticles, Printf; include("test/callbacks/callbacks.jl")'

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.95%. Comparing base (7e43937) to head (fcf5838).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1181      +/-   ##
==========================================
+ Coverage   89.92%   89.95%   +0.02%     
==========================================
  Files         132      133       +1     
  Lines       10434    10449      +15     
==========================================
+ Hits         9383     9399      +16     
+ Misses       1051     1050       -1     
Flag Coverage Δ
total 89.95% <100.00%> (+0.02%) ⬆️
unit 70.74% <84.21%> (+0.22%) ⬆️

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.

@svchb svchb self-assigned this May 12, 2026
@svchb svchb requested a review from efaulhaber May 12, 2026 11:12
@svchb svchb added the bug Something isn't working label May 12, 2026
@svchb svchb marked this pull request as ready for review May 12, 2026 11:12
Copy link
Copy Markdown
Member

@efaulhaber efaulhaber left a comment

Choose a reason for hiding this comment

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

Doesn't work because the system might be replaced in the semidiscretization.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants