Skip to content

Commit d4f8af7

Browse files
svchbLasNikas
andauthored
Fix error message when using TVF without UpdateCB (#807)
* fix * review --------- Co-authored-by: Niklas Neher <73897120+LasNikas@users.noreply.github.com>
1 parent cf1a67e commit d4f8af7

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/schemes/fluid/entropically_damped_sph/system.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ function update_final!(system::EntropicallyDampedSPHSystem, v, u, v_ode, u_ode,
306306
compute_curvature!(system, surface_tension, v, u, v_ode, u_ode, semi, t)
307307
compute_stress_tensors!(system, surface_tension, v, u, v_ode, u_ode, semi, t)
308308
update_average_pressure!(system, system.transport_velocity, v_ode, u_ode, semi)
309+
310+
# Check that TVF is only used together with `UpdateCallback`
311+
check_tvf_configuration(system, system.transport_velocity, v, u, v_ode, u_ode, semi, t;
312+
update_from_callback)
309313
end
310314

311315
function update_average_pressure!(system, ::Nothing, v_ode, u_ode, semi)

src/schemes/fluid/transport_velocity.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,15 @@ function update_callback_used!(system, transport_velocity)
165165
system.cache.update_callback_used[] = true
166166
end
167167

168-
function update_final!(system::FluidSystem, v, u, v_ode, u_ode, semi, t;
169-
update_from_callback=false)
170-
update_final!(system, system.transport_velocity,
171-
v, u, v_ode, u_ode, semi, t; update_from_callback)
172-
end
173-
174-
function update_final!(system::FluidSystem, ::Nothing,
175-
v, u, v_ode, u_ode, semi, t; update_from_callback=false)
168+
function check_tvf_configuration(system::FluidSystem, ::Nothing,
169+
v, u, v_ode, u_ode, semi, t; update_from_callback=false)
176170
return system
177171
end
178172

179-
function update_final!(system::FluidSystem, ::TransportVelocityAdami,
180-
v, u, v_ode, u_ode, semi, t; update_from_callback=false)
173+
function check_tvf_configuration(system::FluidSystem, ::TransportVelocityAdami,
174+
v, u, v_ode, u_ode, semi, t; update_from_callback=false)
175+
# The `UpdateCallback` will set `system.cache.update_callback_used[]` to `true`
176+
# in the initialization. However, other callbacks might update the system first, hence `update_from_callback`.
181177
if !update_from_callback && !(system.cache.update_callback_used[])
182178
throw(ArgumentError("`UpdateCallback` is required when using `TransportVelocityAdami`"))
183179
end

src/schemes/fluid/weakly_compressible_sph/system.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ function update_final!(system::WeaklyCompressibleSPHSystem, v, u, v_ode, u_ode,
304304
# Surface normal of neighbor and boundary needs to have been calculated already
305305
compute_curvature!(system, surface_tension, v, u, v_ode, u_ode, semi, t)
306306
compute_stress_tensors!(system, surface_tension, v, u, v_ode, u_ode, semi, t)
307+
308+
# Check that TVF is only used together with `UpdateCallback`
309+
check_tvf_configuration(system, system.transport_velocity, v, u, v_ode, u_ode, semi, t;
310+
update_from_callback)
307311
end
308312

309313
function kernel_correct_density!(system::WeaklyCompressibleSPHSystem, v, u, v_ode, u_ode,

0 commit comments

Comments
 (0)