Skip to content

Commit 1f1246f

Browse files
committed
Use contiguous memory layout for neighbor lists
1 parent eecc4a7 commit 1f1246f

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
@@ -5,17 +5,17 @@ struct NeighborListsNeighborhoodSearch{NDIMS, NHS, NL, PB, SR}
55

66
function NeighborListsNeighborhoodSearch{NDIMS}(search_radius, n_particles;
77
periodic_box_min_corner = nothing,
8-
periodic_box_max_corner = nothing) where {
9-
NDIMS
10-
}
8+
periodic_box_max_corner = nothing
9+
backend = VectorOfVectors{Int}) where {
10+
NDIMS
11+
}
1112
nhs = GridNeighborhoodSearch{NDIMS}(search_radius, n_particles,
1213
periodic_box_min_corner = periodic_box_min_corner,
1314
periodic_box_max_corner = periodic_box_max_corner)
1415

15-
neighbor_lists = Vector{Vector{Int}}()
16+
neighbor_lists = backend()
1617

17-
new{NDIMS, typeof(nhs),
18-
typeof(neighbor_lists),
18+
new{NDIMS, typeof(nhs), typeof(neighbor_lists),
1919
typeof(nhs.periodic_box)}(nhs, neighbor_lists, nhs.periodic_box)
2020
end
2121
end
@@ -59,6 +59,17 @@ function initialize_neighbor_lists!(neighbor_lists, neighborhood_search, x, y)
5959
end
6060
end
6161

62+
function initialize_neighbor_lists!(neighbor_lists::VectorOfVectors, neighborhood_search, x,
63+
y)
64+
neighbor_lists_ = Vector{Vector{Int}}()
65+
initialize_neighbor_lists!(neighbor_lists_, neighborhood_search, x, y)
66+
67+
empty!(neighbor_lists)
68+
for i in eachindex(neighbor_lists_)
69+
push!(neighbor_lists, neighbor_lists_[i])
70+
end
71+
end
72+
6273
@inline function foreach_neighbor(f, system_coords, neighbor_system_coords,
6374
neighborhood_search::NeighborListsNeighborhoodSearch,
6475
particle, search_radius = nothing)

0 commit comments

Comments
 (0)