[codex] Fix density reinitialization callback#1181
Conversation
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
efaulhaber
left a comment
There was a problem hiding this comment.
Doesn't work because the system might be replaced in the semidiscretization.
…einit-callback # Conflicts: # src/callbacks/density_reinit.jl
efaulhaber
left a comment
There was a problem hiding this comment.
The big question is: is this a breaking change that requires a new major release? Or was the density reinit callback unusably broken before, so that we can consider it a fix instead?
| - `reinit_initial_solution`: Reinitialize the initial solution (default=true) | ||
| """ | ||
| mutable struct DensityReinitializationCallback{I} | ||
| mutable struct DensityReinitializationCallbackAffect{I} |
There was a problem hiding this comment.
Why did you change the name? We don't append Affect for the other callbacks either.
| v = wrap_v(v_ode, particle_system, semi) | ||
| u = wrap_u(u_ode, particle_system, semi) | ||
|
|
||
| reinit_density!(particle_system, v, u, v_ode, u_ode, semi) |
There was a problem hiding this comment.
In the WCSPH system,
v[end, :] ./= kernel_correction_coefficientdoesn't work when there are inactive particles (e.g. with open boundaries). Please change this to
@threaded semi for particle in eachparticle(system)
v[end, particle] /= kernel_correction_coefficient[particle]
endto make it work.
Summary
DensityReinitializationCallbackand reinitialize only that systemdt-based reinitialization when the requested interval is reached, not only after it is exceededdttriggering, and selected-system reinitializationRoot 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")'