pub struct Tree<const N: usize> { /* private fields */ }Expand description
An N-dimensional hypertree, which subdives each axis in two in
each refinement step.
Used as a basis for axes aligned adaptive finite difference meshes. The tree is
Implementations§
Source§impl<const N: usize> Tree<N>
impl<const N: usize> Tree<N>
Sourcepub fn new(domain: HyperBox<N>) -> Self
pub fn new(domain: HyperBox<N>) -> Self
Constructs a new tree consisting of a single root cell, covering the given domain.
pub fn set_periodic(&mut self, axis: usize, periodic: bool)
pub fn domain(&self) -> HyperBox<N>
Sourcepub fn num_active_cells(&self) -> usize
pub fn num_active_cells(&self) -> usize
The number of active (leaf) cells in this tree.
Sourcepub fn num_levels(&self) -> usize
pub fn num_levels(&self) -> usize
The maximum depth of this tree.
pub fn level_cells( &self, level: usize, ) -> impl Iterator<Item = CellId> + ExactSizeIterator
pub fn cell_indices(&self) -> impl Iterator<Item = CellId>
pub fn active_cell_indices(&self) -> impl Iterator<Item = ActiveCellId>
Sourcepub fn bounds(&self, cell: CellId) -> HyperBox<N>
pub fn bounds(&self, cell: CellId) -> HyperBox<N>
Returns the numerical bounds of a given cell.
pub fn active_bounds(&self, active: ActiveCellId) -> HyperBox<N>
pub fn active_level(&self, cell: ActiveCellId) -> usize
Sourcepub fn children(&self, cell: CellId) -> Option<CellId>
pub fn children(&self, cell: CellId) -> Option<CellId>
Returns the children of a given node. Node must not be leaf.
Sourcepub fn child(&self, cell: CellId, child: Split<N>) -> Option<CellId>
pub fn child(&self, cell: CellId, child: Split<N>) -> Option<CellId>
Returns a child of a give node.
Sourcepub fn active_zvalue(&self, active: ActiveCellId) -> &BitSlice<usize, Lsb0> ⓘ
pub fn active_zvalue(&self, active: ActiveCellId) -> &BitSlice<usize, Lsb0> ⓘ
Returns the zvalue of the given active cell.
pub fn active_split(&self, active: ActiveCellId, level: usize) -> Split<N>
pub fn most_recent_active_split(&self, active: ActiveCellId) -> Option<Split<N>>
Sourcepub fn check_refine_flags(&self, flags: &[bool]) -> bool
pub fn check_refine_flags(&self, flags: &[bool]) -> bool
Checks whether the given refinement flags are balanced.
Sourcepub fn balance_refine_flags(&self, flags: &mut [bool])
pub fn balance_refine_flags(&self, flags: &mut [bool])
Balances the given refinement flags, flagging additional cells for refinement to preserve the 2:1 fine coarse ratio between every two neighbors.
Sourcepub fn refine_active_index_map(&self, flags: &[bool], map: &mut [ActiveCellId])
pub fn refine_active_index_map(&self, flags: &[bool], map: &mut [ActiveCellId])
Fills the map with updated indices after refinement is performed. If a cell is refined, this will point to the base cell in that new subdivision.
pub fn refine(&mut self, flags: &[bool])
Sourcepub fn check_coarsen_flags(&self, flags: &[bool]) -> bool
pub fn check_coarsen_flags(&self, flags: &[bool]) -> bool
Checks that the given coarsening flags are balanced and valid.
Sourcepub fn balance_coarsen_flags(&self, flags: &mut [bool])
pub fn balance_coarsen_flags(&self, flags: &mut [bool])
Balances the given coarsening flags
Sourcepub fn coarsen_active_index_map(&self, flags: &[bool], map: &mut [ActiveCellId])
pub fn coarsen_active_index_map(&self, flags: &[bool], map: &mut [ActiveCellId])
Maps current cells to indices after coarsening is performed.
pub fn coarsen(&mut self, flags: &[bool])
pub fn build(&mut self)
Sourcepub fn cell_from_active_index(&self, active: ActiveCellId) -> CellId
pub fn cell_from_active_index(&self, active: ActiveCellId) -> CellId
Computes the cell index corresponding to an active cell.
Sourcepub fn active_index_from_cell(&self, cell: CellId) -> Option<ActiveCellId>
pub fn active_index_from_cell(&self, cell: CellId) -> Option<ActiveCellId>
Computes active cell index from a cell, returning None if cell is
not active.
Sourcepub fn active_children(
&self,
cell: CellId,
) -> impl Iterator<Item = ActiveCellId> + ExactSizeIterator
pub fn active_children( &self, cell: CellId, ) -> impl Iterator<Item = ActiveCellId> + ExactSizeIterator
Returns an iterator over active cells that are children of the given cell.
If is_active(cell) = true then this iterator will be a singleton
returning the same value as tree.active_index_from_cell(cell).
Sourcepub fn cell_from_point(&self, point: [f64; N]) -> CellId
pub fn cell_from_point(&self, point: [f64; N]) -> CellId
Returns the cell which owns the given point. Performs in O(log N).
Sourcepub fn cell_from_point_cached(&self, point: [f64; N], cache: CellId) -> CellId
pub fn cell_from_point_cached(&self, point: [f64; N], cache: CellId) -> CellId
Returns the node which owns the given point, shortening this search with an initial guess. Rather than operating in O(log N) time, this approaches O(1) if the guess is sufficiently close.
Sourcepub fn neighbor(&self, cell: CellId, face: Face<N>) -> Option<CellId>
pub fn neighbor(&self, cell: CellId, face: Face<N>) -> Option<CellId>
Returns the neighboring cell along the given face. If the neighboring cell is more refined, this
returns the cell index of the adjacent cell with tree.level(neighbor) == tree.level(cell).
If this passes over a nonperiodic boundary then it returns None.
Sourcepub fn neighbor_region(&self, cell: CellId, region: Region<N>) -> Option<CellId>
pub fn neighbor_region(&self, cell: CellId, region: Region<N>) -> Option<CellId>
Returns the neighboring cell in the given region. If the neighboring cell is more refined, this
returns the cell index of the adjacent cell with tree.level(neighbor) == tree.level(cell).
If this passes over a nonperiodic boundary then it returns None.
Sourcepub fn _neighbor_region2(
&self,
cell: CellId,
region: Region<N>,
) -> Option<CellId>
pub fn _neighbor_region2( &self, cell: CellId, region: Region<N>, ) -> Option<CellId>
Returns the neighboring cell in the given region. If the neighboring cell is more refined, this
returns the cell index of the adjacent cell with tree.level(neighbor) == tree.level(cell).
If this passes over a nonperiodic boundary then it returns None.
Sourcepub fn active_neighbors_in_region(
&self,
cell: CellId,
region: Region<N>,
) -> impl Iterator<Item = ActiveCellId> + '_
pub fn active_neighbors_in_region( &self, cell: CellId, region: Region<N>, ) -> impl Iterator<Item = ActiveCellId> + '_
Iterates over
pub fn active_neighborhood( &self, cell: ActiveCellId, ) -> impl Iterator<Item = ActiveCellId> + '_
pub fn active_coarse_neighborhood( &self, cell: ActiveCellId, ) -> impl Iterator<Item = ActiveCellId> + '_
Sourcepub fn is_boundary_face(&self, cell: CellId, face: Face<N>) -> bool
pub fn is_boundary_face(&self, cell: CellId, face: Face<N>) -> bool
Returns true if a face lies on a boundary.
Sourcepub fn boundary_region(&self, cell: CellId, region: Region<N>) -> Region<N>
pub fn boundary_region(&self, cell: CellId, region: Region<N>) -> Region<N>
Given a neighboring region to a cell, determines which global region that belongs to (usually)
Trait Implementations§
Source§impl<const N: usize> DataSize for Tree<N>
impl<const N: usize> DataSize for Tree<N>
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
true, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0
const STATIC_HEAP_SIZE: usize = 0
IS_DYNAMIC is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Source§impl<'de, const N: usize> Deserialize<'de> for Tree<N>
impl<'de, const N: usize> Deserialize<'de> for Tree<N>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl<const N: usize> StructuralPartialEq for Tree<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Tree<N>
impl<const N: usize> RefUnwindSafe for Tree<N>
impl<const N: usize> Send for Tree<N>
impl<const N: usize> Sync for Tree<N>
impl<const N: usize> Unpin for Tree<N>
impl<const N: usize> UnsafeUnpin for Tree<N>
impl<const N: usize> UnwindSafe for Tree<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.