Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
efaulhaber committed Jun 24, 2024
1 parent eef17da commit 58b712d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/neighborhood_search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ struct PeriodicBox{NDIMS, ELTYPE}
end

"""
for_particle_neighbor(f, system_coords, neighbor_coords, neighborhood_search;
particles = axes(system_coords, 2), parallel = true)
foreach_point_neighbor(f, system_coords, neighbor_coords, neighborhood_search;
points = axes(system_coords, 2), parallel = true)
Loop for each point in `system_coords` all points in `neighbor_coords` whose distances
Loop for each point in `system_coords` over all points in `neighbor_coords` whose distances
to that point are smaller than the search radius and execute the function `f(i, j, x, y, d)`,
where `i` is the column index of the point in `system_coords`, `j` the column index of the
neighbor in `neighbor_coords`, `x` the coordinates of the point, `y` the coordinates of the
neighbor, and `d` the distance between `x` and `y`.
`x` will be an `SVector` of `system_coords[:, i]`,
`y` will be an `SVector` of `neighbor_coords[:, j]`.
where
- `i` is the column index of the point in `system_coords`,
- `j` the column index of the neighbor in `neighbor_coords`,
- `x` an `SVector` of the coordinates of the point (`system_coords[:, i]`),
- `y` an `SVector` of the coordinates of the neighbor (`neighbor_coords[:, j]`),
- `d` the distance between `x` and `y`.
The `neighborhood_search` must have been initialized or updated with `system_coords`
as first coordinate array and `neighbor_coords` as second coordinate array.
Expand All @@ -122,18 +122,18 @@ Note that `system_coords` and `neighbor_coords` can be identical.
coordinate array.
# Keywords
- `particles`: Loop over these point indices. By default all columns of `system_coords`.
- `parallel=true`: Run the outer loop over `particles` thread-parallel.
- `points`: Loop over these point indices. By default all columns of `system_coords`.
- `parallel=true`: Run the outer loop over `points` thread-parallel.
See also [`initialize!`](@ref), [`update!`](@ref).
"""
# The type annotation is to make Julia specialize on the type of the function.
# Otherwise, unspecialized code will cause a lot of allocations
# and heavily impact performance.
# See https://docs.julialang.org/en/v1/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing
function foreach_point_neighbor(f::T, system_coords, neighbor_coords, neighborhood_search;
points = axes(system_coords, 2),
parallel = true) where {T}
# The type annotation above is to make Julia specialize on the type of the function.
# Otherwise, unspecialized code will cause a lot of allocations
# and heavily impact performance.
# See https://docs.julialang.org/en/v1/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing
foreach_point_neighbor(f, system_coords, neighbor_coords, neighborhood_search, points,
Val(parallel))
end
Expand Down

0 comments on commit 58b712d

Please sign in to comment.