@@ -75,7 +75,10 @@ function OpenBoundarySystem(boundary_zones::Union{BoundaryZone, Nothing}...;
7575 pressure_acceleration= fluid_system. pressure_acceleration_formulation,
7676 shifting_technique= boundary_model isa
7777 BoundaryModelDynamicalPressureZhang ?
78- shifting_technique (fluid_system) : nothing )
78+ shifting_technique (fluid_system) : nothing ,
79+ density_diffusion= boundary_model isa
80+ BoundaryModelDynamicalPressureZhang ?
81+ density_diffusion (fluid_system) : nothing )
7982 boundary_zones_ = filter (bz -> ! isnothing (bz), boundary_zones)
8083
8184 initial_conditions = union ((bz. initial_condition for bz in boundary_zones_). .. )
@@ -90,7 +93,8 @@ function OpenBoundarySystem(boundary_zones::Union{BoundaryZone, Nothing}...;
9093 cache = (;
9194 create_cache_shifting (initial_conditions, shifting_technique)... ,
9295 create_cache_open_boundary (boundary_model, fluid_system, initial_conditions,
93- calculate_flow_rate, boundary_zones_)... )
96+ density_diffusion, calculate_flow_rate,
97+ boundary_zones_)... )
9498
9599 if any (pr -> isa (pr, RCRWindkesselModel), cache. pressure_reference_values)
96100 calculate_flow_rate = true
@@ -130,7 +134,7 @@ function initialize!(system::OpenBoundarySystem, semi)
130134end
131135
132136function create_cache_open_boundary (boundary_model, fluid_system, initial_condition,
133- calculate_flow_rate, boundary_zones)
137+ density_diffusion, calculate_flow_rate, boundary_zones)
134138 reference_values = map (bz -> bz. reference_values, boundary_zones)
135139 ELTYPE = eltype (initial_condition)
136140
@@ -174,15 +178,14 @@ function create_cache_open_boundary(boundary_model, fluid_system, initial_condit
174178 # as it was already verified in `allocate_buffer` that the density array is constant.
175179 density_rest = first (initial_condition. density)
176180
177- dd = density_diffusion (fluid_system)
178- if dd isa DensityDiffusionAntuono
179- density_diffusion_ = DensityDiffusionAntuono (initial_condition; delta= dd . delta)
181+ if density_diffusion isa DensityDiffusionAntuono
182+ density_diffusion_ = DensityDiffusionAntuono (initial_condition;
183+ delta= density_diffusion . delta)
180184 else
181- density_diffusion_ = dd
185+ density_diffusion_ = density_diffusion
182186 end
183187
184- cache = (; density_calculator= ContinuityDensity (),
185- density_diffusion= density_diffusion_,
188+ cache = (; density_diffusion= density_diffusion_,
186189 pressure_boundary= pressure_boundary,
187190 density_rest= density_rest, cache... )
188191
@@ -261,6 +264,10 @@ system_sound_speed(system::OpenBoundarySystem) = system_sound_speed(system.fluid
261264
262265@inline hydrodynamic_mass (system:: OpenBoundarySystem , particle) = system. mass[particle]
263266
267+ @propagate_inbounds function current_velocity (v, system:: OpenBoundarySystem )
268+ return view (v, 1 : ndims (system), :)
269+ end
270+
264271@inline function current_density (v, system:: OpenBoundarySystem )
265272 return system. cache. density
266273end
@@ -306,6 +313,9 @@ function update_boundary_interpolation!(system::OpenBoundarySystem, v, u, v_ode,
306313 semi, t)
307314 update_boundary_model! (system, system. boundary_model, v, u, v_ode, u_ode, semi, t)
308315 update_shifting! (system, shifting_technique (system), v, u, v_ode, u_ode, semi)
316+
317+ @trixi_timeit timer () " update density diffusion" update! (density_diffusion (system),
318+ v, u, system, semi)
309319end
310320
311321# This function is called by the `UpdateCallback`, as the integrator array might be modified
@@ -397,8 +407,8 @@ function check_domain!(system, v, u, v_ode, u_ode, semi)
397407 v, u, v_fluid, u_fluid)
398408 end
399409
400- update_system_buffer! (system. buffer, semi )
401- update_system_buffer! (fluid_system. buffer, semi )
410+ update_system_buffer! (system. buffer)
411+ update_system_buffer! (fluid_system. buffer)
402412
403413 fluid_candidates .= false
404414
@@ -428,8 +438,8 @@ function check_domain!(system, v, u, v_ode, u_ode, semi)
428438 v, u, v_fluid, u_fluid)
429439 end
430440
431- update_system_buffer! (system. buffer, semi )
432- update_system_buffer! (fluid_system. buffer, semi )
441+ update_system_buffer! (system. buffer)
442+ update_system_buffer! (fluid_system. buffer)
433443
434444 # Since particles have been transferred, the neighborhood searches must be updated
435445 update_nhs! (semi, u_ode)
453463 # to determine if it exited the boundary zone through the free surface (outflow).
454464 if dot (relative_position, boundary_zone. face_normal) < 0
455465 # Particle is outside the fluid domain
456- deactivate_particle! (system, particle, u)
466+ deactivate_particle! (system, particle, v, u)
457467
458468 return system
459469 end
475485 # Verify the particle remains inside the boundary zone after the reset; deactivate it if not.
476486 particle_coords = current_coords (u, system, particle)
477487 if ! is_in_boundary_zone (boundary_zone, particle_coords)
478- deactivate_particle! (system, particle, u)
488+ deactivate_particle! (system, particle, v, u)
479489
480490 return system
481491 end
494504 transfer_particle! (system, fluid_system, particle, particle_new, v, u, v_fluid, u_fluid)
495505
496506 # Deactivate particle in interior domain
497- deactivate_particle! (fluid_system, particle, u_fluid)
507+ deactivate_particle! (fluid_system, particle, v_fluid, u_fluid)
498508
499509 return fluid_system
500510end
0 commit comments