Skip to main content

GridND

Struct GridND 

Source
pub struct GridND<F: SemiflowFloat = f64, const D: usize = 2> {
    pub axes: [Grid1D<F>; D],
    pub interp: InterpKind,
}
Expand description

d-dimensional tensor-product grid with uniform axes.

Each axis is a Grid1D<F> with independent geometry, boundary policy, and interpolation kind. Dimension D is a const generic parameter. Values are stored axis-0-fastest: flat_idx = k_{D-1}·n_{D-2}·…·n₀ + … + k₁·n₀ + k₀.

§Example

use semiflow::{Grid1D, grid_nd::GridND};
let axes = core::array::from_fn(|_| Grid1D::new(-5.0_f64, 5.0, 16).unwrap());
let grid = GridND::<f64, 2>::new(axes).unwrap();
assert_eq!(grid.len(), 256); // 16*16

Fields§

§axes: [Grid1D<F>; D]

Per-axis grids. axes[0] is the fastest-varying axis.

Each axis contributes its own crate::grid::BoundaryPolicy to GridFnND::sample. The axes’ individual InterpKinds are NOT consulted — see GridND::interp.

§interp: InterpKind

Tensor-product interpolation kind used by GridFnND::sample.

Default InterpKind::CubicHermite (ADR-0191). A single grid-level knob rather than a per-axis one because Grid1D::new already stamps every axis with SepticHermite, leaving no way to tell a deliberate choice from an inherited default. CubicHermite removes the accumulated per-step interpolation variance at 4^D nodes per sample; SepticHermite would cost 8^D for no gain on that failure mode, and is not implemented for D > 1.

Implementations§

Source§

impl<F: SemiflowFloat, const D: usize> GridND<F, D>

Source

pub fn new(axes: [Grid1D<F>; D]) -> Result<Self, SemiflowError>

Construct from an array of D axes.

§Errors
  • DomainViolation if D == 0.
  • DomainViolation if any axis has n < 4.
Source

pub fn with_interp(self, interp: InterpKind) -> Self

Override the tensor-product interpolation kind (builder, ADR-0191).

Only InterpKind::CubicHermite and InterpKind::Linear are implemented for D > 1; the others make GridFnND::sample return SemiflowError::Unsupported. Linear needs the linear-interp feature, matching the 1-D contract.

Source

pub fn len(&self) -> usize

Total number of grid points: n₀ · n₁ · … · n_{D-1}.

Source

pub fn is_empty(&self) -> bool

Returns false for any valid GridND (all axes have n >= 4).

Source

pub fn n_along(&self, d: usize) -> usize

Number of nodes along axis d.

§Panics

Panics if d >= D (debug only).

Source

pub fn flat_idx(&self, idx: &[usize; D]) -> usize

Convert a multi-index [k₀, k₁, …, k_{D-1}] to a flat index.

Axis 0 is fastest-varying (row-major in axis-0 direction).

§Panics

Panics in debug if kd >= n_d for any d.

Source

pub fn x_at(&self, d: usize, k: usize) -> F

Physical coordinate of multi-index [k₀, …, k_{D-1}] on axis d.

Source

pub fn centre(&self) -> [F; D]

Physical coordinates of the grid CENTRE (used for SPD validation).

Trait Implementations§

Source§

impl<F: Clone + SemiflowFloat, const D: usize> Clone for GridND<F, D>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<F, const D: usize> Freeze for GridND<F, D>
where [Grid1D<F>; D]: Freeze,

§

impl<F, const D: usize> RefUnwindSafe for GridND<F, D>
where [Grid1D<F>; D]: RefUnwindSafe,

§

impl<F, const D: usize> Send for GridND<F, D>
where [Grid1D<F>; D]: Send,

§

impl<F, const D: usize> Sync for GridND<F, D>
where [Grid1D<F>; D]: Sync,

§

impl<F, const D: usize> Unpin for GridND<F, D>
where [Grid1D<F>; D]: Unpin,

§

impl<F, const D: usize> UnsafeUnpin for GridND<F, D>
where [Grid1D<F>; D]: UnsafeUnpin,

§

impl<F, const D: usize> UnwindSafe for GridND<F, D>
where [Grid1D<F>; D]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.