|
| 1 | +abstract type AbstractNeighborhoodSearch end |
| 2 | + |
| 3 | +""" |
| 4 | + initialize!(search::AbstractNeighborhoodSearch, x, y) |
| 5 | +
|
| 6 | +Initialize a neighborhood search with the two coordinate arrays `x` and `y`. |
| 7 | +
|
| 8 | +In general, the purpose of a neighborhood search is to find for one point in `x` |
| 9 | +all points in `y` whose distances to that point are smaller than the search radius. |
| 10 | +`x` and `y` are expected to be matrices, where the `i`-th column contains the coordinates |
| 11 | +of point `i`. Note that `x` and `y` can be identical. |
| 12 | +
|
| 13 | +See also [`update!`](@ref). |
| 14 | +""" |
| 15 | +@inline initialize!(search::AbstractNeighborhoodSearch, x, y) = search |
| 16 | + |
| 17 | +""" |
| 18 | + update!(search::AbstractNeighborhoodSearch, x, y; particles_moving = (true, true)) |
| 19 | +
|
| 20 | +Update an already initialized neighborhood search with the two coordinate arrays `x` and `y`. |
| 21 | +
|
| 22 | +Like [`initialize!`](@ref), but reusing the existing data structures of the already |
| 23 | +initialized neighborhood search. |
| 24 | +When the points only moved a small distance since the last `update!` or `initialize!`, |
| 25 | +this is significantly faster than `initialize!`. |
| 26 | +
|
| 27 | +Not all implementations support incremental updates. |
| 28 | +If incremental updates are not possible for an implementation, `update!` will fall back |
| 29 | +to a regular `initialize!`. |
| 30 | +
|
| 31 | +Some neighborhood searches might not need to update when only `x` changed since the last |
| 32 | +`update!` or `initialize!` and `y` did not change. Pass `particles_moving = (true, false)` |
| 33 | +in this case to avoid unnecessary updates. |
| 34 | +The first flag in `particles_moving` indicates if points in `x` are moving. |
| 35 | +The second flag indicates if points in `y` are moving. |
| 36 | +
|
| 37 | +See also [`initialize!`](@ref). |
| 38 | +""" |
| 39 | +@inline function update!(search::AbstractNeighborhoodSearch, x, y; |
| 40 | + particles_moving = (true, true)) |
| 41 | + return search |
| 42 | +end |
| 43 | + |
1 | 44 | struct PeriodicBox{NDIMS, ELTYPE} |
2 | 45 | min_corner :: SVector{NDIMS, ELTYPE} |
3 | 46 | max_corner :: SVector{NDIMS, ELTYPE} |
|
0 commit comments