Skip to content

Commit 7f3d0c0

Browse files
committed
Use contiguous memory layout for neighbor lists
1 parent c131f90 commit 7f3d0c0

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
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.2-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/neighbor_lists_nhs.jl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ struct NeighborListsNeighborhoodSearch{NDIMS, NHS, NL, PB}
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
backend = 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

1718
new{NDIMS, typeof(backend),
1819
typeof(neighbor_lists),
@@ -59,6 +60,17 @@ function initialize_neighbor_lists!(neighbor_lists, neighborhood_search, x, y)
5960
end
6061
end
6162

63+
function initialize_neighbor_lists!(neighbor_lists::VectorOfVectors, neighborhood_search, x,
64+
y)
65+
neighbor_lists_ = Vector{Vector{Int}}()
66+
initialize_neighbor_lists!(neighbor_lists_, neighborhood_search, x, y)
67+
68+
empty!(neighbor_lists)
69+
for i in eachindex(neighbor_lists_)
70+
push!(neighbor_lists, neighbor_lists_[i])
71+
end
72+
end
73+
6274
@inline function for_particle_neighbor_inner(f, system_coords, neighbor_system_coords,
6375
neighborhood_search::NeighborListsNeighborhoodSearch,
6476
particle)

0 commit comments

Comments
 (0)