Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unsafe bitsets #610

Merged
merged 6 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/general/buffer.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
struct SystemBuffer{V}
active_particle :: BitVector
active_particle :: Vector{Bool}
eachparticle :: V # Vector{Int}
buffer_size :: Int

function SystemBuffer(active_size, buffer_size::Integer)
active_particle = vcat(trues(active_size), falses(buffer_size))
# We cannot use a `BitVector` here, as writing to a `BitVector` is not thread-safe
active_particle = vcat(fill(true, active_size), fill(false, buffer_size))
svchb marked this conversation as resolved.
Show resolved Hide resolved
eachparticle = collect(1:active_size)

return new{typeof(eachparticle)}(active_particle, eachparticle, buffer_size)
Expand Down
3 changes: 2 additions & 1 deletion src/preprocessing/geometries/triangle_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ function unique_sorted(vertices)
# Sort by the first entry of the vectors
compare_first_element = (x, y) -> x[1] < y[1]
vertices_sorted = sort!(vertices, lt=compare_first_element)
keep = trues(length(vertices_sorted))
# We cannot use a `BitVector` here, as writing to a `BitVector` is not thread-safe
keep = fill(true, length(vertices_sorted))

PointNeighbors.@threaded vertices_sorted for i in eachindex(vertices_sorted)
# We only sorted by the first entry, so we have to check all previous vertices
Expand Down
2 changes: 1 addition & 1 deletion src/schemes/boundary/open_boundary/boundary_zones.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ end
function remove_outside_particles(initial_condition, spanning_set, zone_origin)
(; coordinates, density, particle_spacing) = initial_condition

in_zone = trues(nparticles(initial_condition))
in_zone = fill(true, nparticles(initial_condition))

for particle in eachparticle(initial_condition)
current_position = current_coords(coordinates, initial_condition, particle)
Expand Down
Loading