Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/cell_lists/full_grid.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
FullGridCellList(; min_corner, max_corner, search_radius = 0.0,
periodicity = false, backend = DynamicVectorOfVectors{Int32},
FullGridCellList(; min_corner, max_corner,
search_radius = zero(eltype(min_corner)),
backend = DynamicVectorOfVectors{Int32},
max_points_per_cell = 100)

A simple cell list implementation where each (empty or non-empty) cell of a rectangular
Expand All @@ -15,12 +16,8 @@ See [`copy_neighborhood_search`](@ref) for more details.
# Keywords
- `min_corner`: Coordinates of the domain corner in negative coordinate directions.
- `max_corner`: Coordinates of the domain corner in positive coordinate directions.
- `search_radius = 0.0`: Search radius of the neighborhood search, which will determine the
cell size. Use the default of `0.0` to create a template (see above).
- `periodicity = false`: Set to `true` when using a [`PeriodicBox`](@ref) with the
neighborhood search. When using [`copy_neighborhood_search`](@ref),
this option can be ignored an will be set automatically depending
on the periodicity of the neighborhood search.
- `search_radius`: Search radius of the neighborhood search, which will determine the
cell size. Use the default of zero to create a template (see above).
- `backend = DynamicVectorOfVectors{Int32}`: Type of the data structure to store the actual
cell lists. Can be
- `Vector{Vector{Int32}}`: Scattered memory, but very memory-efficient.
Expand Down
2 changes: 2 additions & 0 deletions src/neighborhood_search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ struct PeriodicBox{NDIMS, ELTYPE}
end
end

@inline Base.eltype(::PeriodicBox{<:Any, ELTYPE}) where {ELTYPE} = ELTYPE

"""
foreach_point_neighbor(f, system_coords, neighbor_coords, neighborhood_search;
parallelization_backend = default_backend(system_coords),
Expand Down
12 changes: 12 additions & 0 deletions src/nhs_grid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ since not sorting makes our implementation a lot faster (although less paralleli
"A Parallel SPH Implementation on Multi-Core CPUs".
In: Computer Graphics Forum 30.1 (2011), pages 99–112.
[doi: 10.1111/J.1467-8659.2010.01832.X](https://doi.org/10.1111/J.1467-8659.2010.01832.X)

!!! note "Note"
The type of `search_radius` determines the type used for the internals of the
neighborhood search.
When working with single precision, the `search_radius` must be `Float32` in order
to avoid the use of double precision values (for example when working with GPUs).
When using a `periodic_box`, its type must match the type of the `search_radius`.
"""
struct GridNeighborhoodSearch{NDIMS, US, CL, ELTYPE, PB, UB} <: AbstractNeighborhoodSearch
cell_list :: CL
Expand Down Expand Up @@ -84,6 +91,11 @@ function GridNeighborhoodSearch{NDIMS}(; search_radius = 0.0, n_points = 0,
n_cells = ntuple(_ -> -1, Val(NDIMS))
cell_size = ntuple(_ -> search_radius, Val(NDIMS))
else
if typeof(search_radius) != eltype(periodic_box)
throw(ArgumentError("the `search_radius` and the `PeriodicBox` must have " *
"the same element type"))
end

# Round up search radius so that the grid fits exactly into the domain without
# splitting any cells. This might impact performance slightly, since larger
# cells mean that more potential neighbors are considered than necessary.
Expand Down
Loading