Expand description
Classification of a coordinate slice by grid interval.
Given a set of coordinates and a 1D grid (any type implementing
FindIntervalIdOfPoint + HasIntervalIdRange), every coordinate is mapped to
either the grid interval that contains it or to an outside-domain set when no
interval contains it. The result is captured in a
CoordsByIntervalClassification value that provides ergonomic accessors for
downstream processing (finite-element assembly, interpolation, adaptive
refinement, etc.).
§Accepted coordinate inputs
The slice-based constructors accept coords: &[T]. Because Coords1D<T>
implements Deref<Target = [T]>, a &Coords1D<T> coerces automatically and
can be passed anywhere a &[T] is expected — no explicit .as_ref() or
.deref() call is needed:
let classification =
CoordsByIntervalClassification::try_new_dense_from_coords(&my_coords1d, &grid)?;
// ^^^^^^^^^^^^^
// &Coords1D<f64> coerces to &[f64] via Deref§Storage strategies
Two internal representations are offered for the inside-interval mapping:
| Strategy | Constructor | Best for |
|---|---|---|
| Dense | CoordsByIntervalClassification::try_new_dense_from_coords | Most intervals are occupied |
| Sparse | CoordsByIntervalClassification::try_new_sparse_from_coords | Few intervals are occupied |
Both strategies guarantee that the coordinate-index sets stored in each bucket are sorted in ascending order, so callers can rely on that property without an extra sorting step.
§Parallel variants
Every sequential constructor has a _par counterpart
(try_new_dense_from_coords_par,
try_new_sparse_from_coords_par)
that classifies coordinates in parallel using Rayon. The grid type must
implement Sync; the coordinate type must implement Send + Sync.
§Sorted-input fast path
When the input coordinates are already sorted (wrapped in a Coords1D),
CoordsByIntervalClassification::new_dense_from_coords_sorted performs a
single linear sweep through both the coordinate slice and the interval list,
avoiding a per-coordinate binary-search lookup and returning Self directly
(infallible, because Coords1D is guaranteed non-empty).
Structs§
- Coords
ByInterval Classification - Classification of a coordinate slice by grid interval.
Enums§
- Coord
IdsBy Interval - Stores the mapping from each grid interval to the coordinate indices that fall inside it.
- Errors
Coords ByInterval Classification - Errors that can occur when classifying coordinates by grid interval.