Skip to content

[codex] Fix density reinitialization callback#1181

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

[codex] Fix density reinitialization callback#1181
svchb wants to merge 7 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

❌ Patch coverage is 93.02326% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.91%. Comparing base (71d42df) to head (0f0e9a2).

Files with missing lines Patch % Lines
test/callbacks/density_reinit.jl 72.72% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1181      +/-   ##
==========================================
+ Coverage   89.88%   89.91%   +0.02%     
==========================================
  Files         133      134       +1     
  Lines       10452    10483      +31     
==========================================
+ Hits         9395     9426      +31     
  Misses       1057     1057              
Flag Coverage Δ
total 89.91% <93.02%> (+0.02%) ⬆️
unit 70.90% <90.69%> (+0.41%) ⬆️

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.

@svchb svchb requested a review from efaulhaber May 17, 2026 19:42
Comment thread src/callbacks/density_reinit.jl Outdated
@svchb svchb requested a review from efaulhaber May 18, 2026 10:40
…einit-callback

# Conflicts:
#	src/callbacks/density_reinit.jl
Comment thread examples/fluid/dam_break_2d.jl Outdated
@svchb svchb requested a review from efaulhaber May 18, 2026 11:22
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