Skip to content

Commit

Permalink
add docs and fix julia 1.6 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenPL committed Dec 6, 2023
1 parent 3b5b782 commit 9d77ddf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ function periodic_neighbouring_boxes(ht::BoundedHashTable, gridpos, r)
return ( (hashindex(ht, rep), offset) for (rep, offset) in neighbour_reps)
end

"""
periodic_neighbours(ht::BoundedHashTable, pos, r)
Returns an iterator over the particles in the neighbourhood of `pos` in the hash table `ht`
together with the offset which is might needed to wrap the particle back into the domain.
The argument `r` determines the radius of the neighbourhood.
The offset is the vector such that `X[j] + offset` is close to `pos`.
Consider the following example:
```julia
using LinearAlgebra
X = [SVec2(0.01,0.01), SVec2(0.99, 0.99)]
ht = BoundedHashTable(X, 0.01, [1.0, 1.0])
for i in 1:2
Xi = X[i]
for (j, offset) in periodic_neighbours(ht, X[i], 0.1)
Xj = X[j] + offset
d = norm(Xi - Xj)
end
end
```
"""
function periodic_neighbours(ht::BoundedHashTable, pos, r)
gridpos = gridindices(ht, pos)
return ((k, offset) for (boxhash, offset) in periodic_neighbouring_boxes(ht, gridpos, r)
Expand Down

0 comments on commit 9d77ddf

Please sign in to comment.