Skip to content

Commit 44fab7f

Browse files
committed
Resolve requested change for docs for SpatialHashingCellList.
1 parent f9f0ebb commit 44fab7f

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

src/cell_lists/spatial_hashing.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
44
A basic spatial hashing implementation. Similar to [`DictionaryCellList`](@ref), the domain is discretized into cells,
55
and the particles in each cell are stored in a hash map. The hash is computed using the spatial location of each cell
6-
[as described by Ihmsen et al. (2001)](@cite Ihmsen2003). By using a hash map, which only stores non-empty cells,
7-
the domain is effectively infinite. The size of the hash map is recommended to be approximately twice the number of particles to balance memory consumption
8-
against the likelihood of hash collisions.
6+
[as described by Ihmsen et al. (2001)](@cite Ihmsen2003). By using a hash map that stores entries only for non-empty cells,
7+
the domain is effectively infinite. The size of the hash map is recommended to be approximately twice the number of particles
8+
to balance memory consumption against the likelihood of hash collisions.
99
1010
# Arguments
1111
- `NDIMS::Int`: Number of spatial dimensions (e.g., `2` or `3`).

src/nhs_grid.jl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ end
312312

313313
# `each_cell_index(cell_list)` might return a `KeySet`, which has to be `collect`ed
314314
# first to be able to be used in a threaded loop. This function takes care of that.
315-
@threaded parallelization_backend for cell_index in
316-
each_cell_index_threadable(cell_list)
315+
@threaded parallelization_backend for cell_index in each_cell_index_threadable(cell_list)
317316
mark_changed_cell!(neighborhood_search, cell_index, y)
318317
end
319318
end
@@ -361,13 +360,12 @@ function update_grid!(neighborhood_search::GridNeighborhoodSearch{<:Any,
361360
# We can work around this by using the old lengths.
362361
# TODO this is hardcoded for the `FullGridCellList`
363362
@threaded parallelization_backend for i in eachindex(update_buffer,
364-
cell_list.cells.lengths)
363+
cell_list.cells.lengths)
365364
update_buffer[i] = cell_list.cells.lengths[i]
366365
end
367366

368367
# Add points to new cells
369-
@threaded parallelization_backend for cell_index in
370-
each_cell_index_threadable(cell_list)
368+
@threaded parallelization_backend for cell_index in each_cell_index_threadable(cell_list)
371369
for i in 1:update_buffer[cell_index]
372370
point = cell_list.cells.backend[i, cell_index]
373371
point_coords = extract_svector(y, Val(ndims(neighborhood_search)), point)
@@ -381,8 +379,7 @@ function update_grid!(neighborhood_search::GridNeighborhoodSearch{<:Any,
381379
end
382380

383381
# Remove points from old cells
384-
@threaded parallelization_backend for cell_index in
385-
each_cell_index_threadable(cell_list)
382+
@threaded parallelization_backend for cell_index in each_cell_index_threadable(cell_list)
386383
points = cell_list[cell_index]
387384

388385
# WARNING!!!

test/cell_lists/spatial_hashing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
cell2_hash = PointNeighbors.spatial_hash(cell2, n_points)
5252
points1 = nhs.cell_list[cell1]
5353
points2 = nhs.cell_list[cell2]
54-
54+
5555
@test points1 == points2 == [1, 2]
5656
@test cell1_hash == cell2_hash
5757
end

test/neighborhood_search.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,11 @@
132132

133133
seeds = [1, 2]
134134
name(size,
135-
seed) = "$(length(size))D with $(prod(size)) Particles " *
136-
"($(seed == 1 ? "`initialize!`" : "`update!`"))"
135+
seed) = "$(length(size))D with $(prod(size)) Particles " *
136+
"($(seed == 1 ? "`initialize!`" : "`update!`"))"
137137
@testset verbose=true "$(name(cloud_size, seed)))" for cloud_size in cloud_sizes,
138138
seed in seeds
139+
139140
coords = point_cloud(cloud_size, seed = seed)
140141
NDIMS = length(cloud_size)
141142
n_points = size(coords, 2)

0 commit comments

Comments
 (0)