FindNearbySegments
VortexPasta.FindNearbySegments Module
FindNearbySegmentsA module for finding pairs of nearby filament segments.
This is a common operation, used for instance for:
computing short-range Biot-Savart interactions between filament segments;
detecting vortex reconnection candidates.
Backends
VortexPasta.FindNearbySegments.NaiveSegmentFinder Type
NaiveSegmentFinder <: NearbySegmentFinder
NaiveSegmentFinder(fs::AbstractVector{<:AbstractFilament})Initialise nearby segment finder based on a naive searching method.
When using this segment finder, nearby_segments iterates through all segments in all filaments fs, performing no filtering at all. One should manually use segment_is_close to filter the returned segments while iterating.
VortexPasta.FindNearbySegments.CellListSegmentFinder Type
CellListSegmentFinder <: NearbySegmentFinder
CellListSegmentFinder(
fs::AbstractVector{<:AbstractFilament},
r_cut::Real,
Ls::NTuple{3, Real};
nsubdiv = Val(1),
)Initialise nearby segment finder based on cell lists algorithm.
Only supports fully periodic domains.
See the CellLists module for more details.
Mandatory arguments
fs: vector of filaments;r_cut::Real: cut-off distance;Ls::NTuple{3, Real}: domain period in each direction. Note that this backend doesn't support non-periodic (Infinity) directions.
Optional keyword arguments
nsubdiv = Val(M): number of cell lists subdivisions. HereMmust be a positive integer (M = 1means no subdivisions). SeePeriodicCellListfor details.
Functions
VortexPasta.FindNearbySegments.set_filaments! Function
set_filaments!(c::NearbySegmentFinder, fs::AbstractVector{<:AbstractFilament})Store (and optionally process) the list of filaments.
This must be called to set the filament list before using nearby_segments.
VortexPasta.FindNearbySegments.nearby_segments Function
nearby_segments(c::NearbySegmentFinder, x⃗::Vec3)Return an iterator over the segments that are "close" to the location x⃗.
A segment is considered to be close to x⃗ if the minimum[1] distance between x⃗ and the segment midpoint is smaller than the cutoff distance
Typical usage:
x⃗ = Vec3(0.1, 0.3, 0.2)
for segment ∈ nearby_segments(c, x⃗)
# Get the filament `f` and the index `i` of the segment within the filament.
# The segment is between the filament nodes `f[i]` and `f[i + 1]`.
(; f, i,) = segment
# Do something with the segment...
endVortexPasta.FindNearbySegments.segment_is_close Function
segment_is_close(s::Segment, x⃗, r_cut::Real, r²_cut::Real, Ls, Lhs) -> BoolDetermine whether segment s is close to the point x⃗.
Here r_cut is the critical distance below which s and x⃗ will be considered to be "close", and r²_cut = r_cut^2 is its squared value.
Moreover, Ls = (Lx, Ly, Lz) contains the domain period along each dimension (components can be Infinity() for infinite non-periodic domains), and Lhs = (Lx/2, Ly/2, Lz/2) contains half the domain periods.
When periodicity is enabled, the relevant distance is the minimum distance between the two points, after considering all their periodic images. ↩︎