Skip to content

Commit fe71099

Browse files
author
LasNikas
committed
Merge branch 'more-robust-obc' into fsi-aorta
2 parents fff6a8c + 148e198 commit fe71099

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

src/schemes/boundary/open_boundary/boundary_zones.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,19 @@ function update_boundary_zone_indices!(system, u, boundary_zones, semi)
440440
end
441441
end
442442

443-
# This only occurs if `face_normal` is not exactly normal to the `boundary_face`.
444-
# In such cases, particles that are actually outside the simulation domain (outflow particles)
445-
# may be incorrectly kept active as inflow particles and therefore cannot be assigned to any boundary zone.
446-
# This issue should not occur and has been fixed in https://github.com/trixi-framework/TrixiParticles.jl/pull/926 .
447-
@assert system.boundary_zone_indices[particle] != 0 "No boundary zone found for active buffer particle"
443+
# Assert that every active buffer particle is assigned to a boundary zone.
444+
# This should always be true if the boundary zone geometry is set up correctly.
445+
# However, rare edge cases during particle conversion (`convert_particle!`)
446+
# may leave a particle unassigned. Potential causes for failure:
447+
# - `face_normal` is not exactly normal to the `boundary_face`
448+
# (fixed in https://github.com/trixi-framework/TrixiParticles.jl/pull/926).
449+
# - Large downstream expansion can shift an inflow particle to the zone edge;
450+
# even after upstream adjustment it may remain outside
451+
# (fixed in https://github.com/trixi-framework/TrixiParticles.jl/pull/997).
452+
# - Floating-point rounding when a particle lies almost exactly on the `boundary_face`
453+
# during transition, causing a reset just outside the zone
454+
# (fixed in https://github.com/trixi-framework/TrixiParticles.jl/pull/997).
455+
@assert system.boundary_zone_indices[particle]!=0 "No boundary zone found for active buffer particle"
448456
end
449457

450458
return system

src/schemes/boundary/open_boundary/system.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,22 @@ end
421421
# Activate a new particle in simulation domain
422422
transfer_particle!(fluid_system, system, particle, particle_new, v_fluid, u_fluid, v, u)
423423

424-
# Reset position of boundary particle
424+
# Reset position of boundary particle back into the boundary zone.
425+
# Particles lying almost exactly on the `boundary_face` might be reset
426+
# slightly outside the boundary zone.
427+
# Thus, we use a shortened vector to account for numerical precision issues.
428+
reset_dist = boundary_zone.zone_width - sqrt(eps(boundary_zone.zone_width))
429+
reset_vector = -boundary_zone.face_normal * reset_dist
425430
for dim in 1:ndims(system)
426-
u[dim, particle] += boundary_zone.spanning_set[1][dim]
431+
u[dim, particle] += reset_vector[dim]
432+
end
433+
434+
# Verify the particle remains inside the boundary zone after the reset; deactivate it if not.
435+
particle_coords = current_coords(u, system, particle)
436+
if !is_in_boundary_zone(boundary_zone, particle_coords)
437+
deactivate_particle!(system, particle, u)
438+
439+
return system
427440
end
428441

429442
impose_rest_density!(v, system, particle, system.boundary_model)

0 commit comments

Comments
 (0)