Skip to content

Commit 47981f8

Browse files
committed
Use contiguous memory layout for neighbor lists
1 parent 7b56e96 commit 47981f8

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ authors = ["Erik Faulhaber <[email protected]>"]
44
version = "0.2.4-dev"
55

66
[deps]
7+
ArraysOfArrays = "65a8f2f4-9b39-5baf-92e2-a9cc46fdf018"
78
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
89
Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588"
910
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1011
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1112

1213
[compat]
14+
ArraysOfArrays = "0.6
1315
LinearAlgebra = "1"
1416
Polyester = "0.7.5"
1517
Reexport = "1"

src/PointNeighbors.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module PointNeighbors
22

33
using Reexport: @reexport
44

5+
using ArraysOfArrays: VectorOfVectors
56
using LinearAlgebra: dot
67
using Polyester: @batch
78
@reexport using StaticArrays: SVector

src/nhs_neighbor_lists.jl

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ struct NeighborListsNeighborhoodSearch{NDIMS, NHS, NL, PB}
3131

3232
function NeighborListsNeighborhoodSearch{NDIMS}(search_radius, n_particles;
3333
periodic_box_min_corner = nothing,
34-
periodic_box_max_corner = nothing) where {
35-
NDIMS
36-
}
34+
periodic_box_max_corner = nothing
35+
backend = VectorOfVectors{Int}) where {
36+
NDIMS
37+
}
3738
nhs = GridNeighborhoodSearch{NDIMS}(search_radius, n_particles,
3839
periodic_box_min_corner = periodic_box_min_corner,
3940
periodic_box_max_corner = periodic_box_max_corner)
4041

41-
neighbor_lists = Vector{Vector{Int}}()
42+
neighbor_lists = backend()
4243

43-
new{NDIMS, typeof(nhs),
44-
typeof(neighbor_lists),
44+
new{NDIMS, typeof(nhs), typeof(neighbor_lists),
4545
typeof(nhs.periodic_box)}(nhs, neighbor_lists, nhs.periodic_box)
4646
end
4747
end
@@ -88,6 +88,17 @@ function initialize_neighbor_lists!(neighbor_lists, neighborhood_search, x, y)
8888
end
8989
end
9090

91+
function initialize_neighbor_lists!(neighbor_lists::VectorOfVectors, neighborhood_search, x,
92+
y)
93+
neighbor_lists_ = Vector{Vector{Int}}()
94+
initialize_neighbor_lists!(neighbor_lists_, neighborhood_search, x, y)
95+
96+
empty!(neighbor_lists)
97+
for i in eachindex(neighbor_lists_)
98+
push!(neighbor_lists, neighbor_lists_[i])
99+
end
100+
end
101+
91102
@inline function foreach_neighbor(f, system_coords, neighbor_system_coords,
92103
neighborhood_search::NeighborListsNeighborhoodSearch,
93104
particle; search_radius = nothing)

0 commit comments

Comments
 (0)