Skip to main content

Module window

Module window 

Source
Expand description

Zero-copy windowed view over a contiguous slice of intervals in a partition.

This module provides Grid1DWindow, a lightweight borrowed view that restricts an existing crate::Grid1DTrait to a contiguous sub-range [first_interval_id, first_interval_id + num_intervals_in_window). All point-location queries are filtered to that sub-range: points outside the window return None.

§Motivation

Domain-decomposition algorithms and overlapping Schwarz methods frequently operate on a strict sub-domain of the global grid. Grid1DWindow avoids copying coordinates or constructing a new grid object — it borrows the underlying partition and delegates the heavy lifting (coordinate arrays, interval construction, point-location) to it.

§Window domain semantics

The Grid1DWindow::window_domain method returns the covering interval of the window, with boundary semantics derived from the underlying partition domain:

Partition domainInterior windowEnd window
[a, b][pₖ, pₖ₊ₘ)[pₖ, pₙ]
(a, b)(pₖ, pₖ₊ₘ](pₖ, pₙ)
[a, b)[pₖ, pₖ₊ₘ)[pₖ, pₙ)
(a, b](pₖ, pₖ₊ₘ](pₖ, pₙ]

§Construction and errors

Use Grid1DWindow::try_new. The only possible error is ErrorsGrid1DWindow::WindowExceedsPartitionBounds, returned when first_interval_id + num_intervals_in_window exceeds the total interval count.

use grid1d::{Grid1DUniform, Grid1DWindow, FindIntervalIdOfPoint, intervals::*};
use grid1d::scalars::{NumIntervals, IntervalId};
use try_create::TryNew;

let grid = Grid1DUniform::new(
    IntervalClosed::new(0.0_f64, 3.0),
    NumIntervals::try_new(3).unwrap(),
);

// Window over intervals 1 and 2 ([1.0, 3.0])
let window = Grid1DWindow::try_new(
    &grid,
    IntervalId::new(1),
    NumIntervals::try_new(2).unwrap(),
).unwrap();

assert!(window.find_interval_id_of_point(&1.5).is_some()); // inside window
assert!(window.find_interval_id_of_point(&0.5).is_none()); // outside window

Structs§

Grid1DWindow
A contiguous sub-range of intervals within a borrowed Grid1DTrait.

Enums§

ErrorsGrid1DWindow
Errors that can arise when constructing a Grid1DWindow.