Skip to content

Commit 4e4f5a9

Browse files
author
LasNikas
committed
use ideal_neighbor_count
1 parent 0558efb commit 4e4f5a9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/schemes/boundary/open_boundary/system.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ end
557557
@inline deactivate_lost_particles!(system, ::Nothing, u, semi) = system
558558

559559
@inline function deactivate_lost_particles!(system, ::AbstractShiftingTechnique, u, semi)
560+
(; particle_spacing) = system.initial_condition
560561
(; neighbor_counter) = system.cache
561562

562563
set_zero!(neighbor_counter)
@@ -572,10 +573,13 @@ end
572573
neighbor_counter[particle] += 1
573574
end
574575

576+
# Set 20% of the ideal neighbor count as threshold
577+
min_neighbors = ideal_neighbor_count(Val(ndims(system)), particle_spacing,
578+
compact_support(system, system)) / 5
579+
575580
@threaded semi for particle in each_integrated_particle(system)
576-
# Deactivate particles that have three or fewer neighbors.
577-
# The threshold of 3 also accounts for possible clustered pairs.
578-
if neighbor_counter[particle] <= 3
581+
# Deactivate particles that have too few neighbors
582+
if neighbor_counter[particle] < min_neighbors
579583
@warn "deactivate particle $particle"
580584
deactivate_particle!(system, particle, u)
581585
end

0 commit comments

Comments
 (0)