Skip to content

Commit

Permalink
add DictionaryCellList
Browse files Browse the repository at this point in the history
  • Loading branch information
LasNikas committed Dec 18, 2024
1 parent 1eb31dd commit 11d248f
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions src/nhs_faces.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
struct FaceNeighborhoodSearch{NDIMS, ELTYPE, PB}
cell_list :: Dict{NTuple{NDIMS, Int}, Vector{Int}}
cell_size :: NTuple{NDIMS, ELTYPE}
neighbor_iterator :: Dict{NTuple{NDIMS, Int}, Vector{Int}}
empty_vector :: Vector{Int} # Just an empty vector (used in `eachneighbor`)
n_cells :: NTuple{NDIMS, Int}
periodic_box :: Nothing
struct FaceNeighborhoodSearch{NDIMS, CL, ELTYPE} <: AbstractNeighborhoodSearch
neighbor_iterator :: CL
cell_list :: CL
search_radius :: ELTYPE
periodic_box :: Nothing
cell_size :: NTuple{NDIMS, ELTYPE} # Required to calculate cell index
end

function FaceNeighborhoodSearch{NDIMS}(search_radius) where {NDIMS}
ELTYPE = eltype(search_radius)

cell_list = Dict{NTuple{NDIMS, Int}, Vector{Int}}()
neighbor_iterator = Dict{NTuple{NDIMS, Int}, Vector{Int}}()
function FaceNeighborhoodSearch{NDIMS}(; cell_list = DictionaryCellList{NDIMS}(),
search_radius) where {NDIMS}
ELTYPE = eltype(search_radius)
CL = typeof(cell_list)

cell_size = ntuple(dim -> search_radius, NDIMS)
empty_vector = Int[]
neighbor_iterator = copy(cell_list)

n_cells = ntuple(_ -> -1, Val(NDIMS))
cell_size = ntuple(_ -> search_radius, Val(NDIMS))

new{NDIMS, ELTYPE, Nothing}(cell_list, cell_size, neighbor_iterator, empty_vector,
n_cells, nothing, search_radius)
end
new{NDIMS, CL, ELTYPE}(neighbor_iterator, cell_list, search_radius, nothing, cell_size)
end

@inline Base.ndims(::FaceNeighborhoodSearch{NDIMS}) where {NDIMS} = NDIMS
Expand Down

0 comments on commit 11d248f

Please sign in to comment.