Skip to main content

Mesh

Struct Mesh 

Source
pub struct Mesh<const N: usize> { /* private fields */ }
Expand description

A discretization of a rectangular axis aligned grid into a collection of uniform grids of nodes with different spacings. A Mesh is built on top of a Quadtree, allowing one to selectively refine areas of interest without wasting computational power on smoother regions of the domain.

This abstraction also handles multithread dispatch and sharing nodes between threads in a an effecient manner. This allows the user to write generic, sequential, and straighforward code on the main thread, while still maximising performance and fully utilizing computational resources.

Implementations§

Source§

impl<const N: usize> Mesh<N>

Source

pub fn evaluate<P: Function<N> + Sync>( &mut self, order: usize, function: P, source: ImageRef<'_>, dest: ImageMut<'_>, ) -> Result<(), P::Error>
where P::Error: Send,

Applies the projection to source, and stores the result in dest.

Source

pub fn is_block_in_interior(&self, block: BlockId) -> bool

Checks if the all neighbors of the block have strongly enforced boundary conditions (and thus can use centered stencils).

Source

pub fn apply<C: SystemBoundaryConds<N> + Sync, P: Function<N> + Sync>( &mut self, order: usize, bcs: C, op: P, f: ImageMut<'_>, ) -> Result<(), P::Error>
where P::Error: Send,

Applies an operator to a system in place, enforcing both strong and weak boundary conditions and running necessary preprocessing.

Source

pub fn copy_from_slice(&mut self, dest: ImageMut<'_>, src: ImageRef<'_>)

Copies an immutable src slice into a mutable dest slice.

Source

pub fn project<P: Projection<N> + Sync>( &mut self, order: usize, projection: P, dest: &mut [f64], )

Applies a projection and stores the result in the destination vector.

Source

pub fn dissipation<const ORDER: usize>( &mut self, amplitude: f64, dest: ImageMut<'_>, )

Applies the projection to source, and stores the result in dest.

Source

pub fn spacing_per_vertex(&mut self, dest: &mut [f64])

This function computes the distance between each vertex and its nearest neighbor.

Source

pub fn adaptive_cfl(&mut self, spacing_per_vertex: &[f64], dest: ImageMut<'_>)

Source§

impl<const N: usize> Mesh<N>

Source

pub fn refine_flags(&self) -> &[bool]

Retrieves a vector representing all regridding flags for the mesh.

Source

pub fn coarsen_flags(&self) -> &[bool]

Retrievs a vector representing all coarsening flags for the mesh.

Source

pub fn regrid(&mut self)

Refines the mesh using currently set flags.

Source

pub fn refine_global(&mut self)

Flags every cell for refinement, then performs the operation.

Source

pub fn refine_innermost(&mut self)

Refines innermost cell

Source

pub fn coarsen_innermost(&mut self)

Coarsens innermost cell

Source

pub fn regrid_in_radius(&mut self, radius: f64, fgl: usize)

Refines or coarsens cells one level (towards target level fgl) within a given radius

Source

pub fn flag_wavelets( &mut self, order: usize, lower: f64, upper: f64, data: ImageRef<'_>, )

Flags cells for refinement using a wavelet criterion. The system must have filled boundaries. This function tags any cell that is insufficiently refined to approximate operators of the given order within the range of error.

Source

pub fn flags_debug(&mut self, debug: &mut [i64])

Store flags for each cell in a debug buffer.

Source

pub fn set_refine_flag(&mut self, cell: usize)

Manually marks a cell for refinement.

Source

pub fn set_coarsen_flag(&mut self, cell: usize)

Manually marks a cell for coarsening.

Source

pub fn buffer_refine_flags(&mut self, count: usize)

Source

pub fn limit_level_range_flags(&mut self, min_level: usize, max_level: usize)

Limits coarsening to cells with a level > min_level, and refinement to cells with a level < max_level.

Source

pub fn balance_flags(&mut self)

After cells have been tagged, the refinement/coarsening flags must be balanced to ensure that the 2:1 balance across faces and vertices is still maintained.

Source

pub fn requires_regridding(&self) -> bool

Returns true if the mesh requires regridding (i.e. any cells are tagged for either refinement or coarsening).

Source

pub fn num_refine_cells(&self) -> usize

The number of cell that are marked for refinement.

Source

pub fn num_coarsen_cells(&self) -> usize

The number of cells that are marked for coarsening.

Source§

impl<const N: usize> Mesh<N>

Source

pub fn transfer_system( &mut self, order: usize, source: ImageRef<'_>, dest: ImageMut<'_>, )

Transfers data from an older version of the mesh to the new refined version, using the given order of interpolation.

Source

pub fn fill_boundary<BCs: SystemBoundaryConds<N> + Sync>( &mut self, order: usize, bcs: BCs, system: ImageMut<'_>, )

Enforces strong boundary conditions. This includes strong physical boundary conditions, as well as handling interior boundaries (same level, coarse-fine, or fine-coarse).

Source

pub fn fill_boundary_to_extent<C: SystemBoundaryConds<N> + Sync>( &mut self, order: usize, extent: usize, bcs: C, system: ImageMut<'_>, )

Enforces strong boundary conditions, only filling ghost nodes if those nodes are within extent of a physical node. This is useful if one is using Kriss-Olgier dissipation, where dissipation and derivatives use different order stencils.

Source

pub fn block_debug(&mut self, debug: &mut [i64])

Stores the index of the block which owns each individual node in a debug vector.

Source

pub fn cell_debug(&mut self, debug: &mut [i64])

Stores the index of the cell which owns each individual node in a debug vector.

Source

pub fn interface_neighbor_debug(&mut self, extent: usize, debug: &mut [i64])

Stores the index of the neighbor along each interface.

Source

pub fn interface_index_debug(&mut self, extent: usize, debug: &mut [i64])

Stores the index of each interface for nodes along that interface.

Source§

impl<const N: usize> Mesh<N>

Source

pub fn new( bounds: HyperBox<N>, width: usize, ghost: usize, boundary: FaceArray<N, BoundaryClass>, ) -> Self

Constructs a new Mesh covering the domain, with a number of nodes defined by width and ghost.

Source

pub fn width(&self) -> usize

Retrieves width of individual cells in this mesh.

Source

pub fn ghost(&self) -> usize

Retrieves the number of ghost nodes on each cell of a mesh.

Source

pub fn tree(&self) -> &Tree<N>

Retrieves the Quadtree this mesh is built on top of.

Source

pub fn num_blocks(&self) -> usize

Returns the total number of blocks on the mesh.

Source

pub fn num_active_cells(&self) -> usize

Returns the total number of cells on the mesh.

Source

pub fn num_nodes(&self) -> usize

Returns the total number of nodes on the mesh.

Source

pub fn num_dofs(&self) -> usize

Source

pub fn boundary_classes(&self) -> FaceArray<N, BoundaryClass>

Returns the boundary classes associated with each boundary of the physical domain.

Source

pub fn blocks(&self) -> &TreeBlocks<N>

Returns underlying TreeBlocks<N> object.

Source

pub fn block_nodes(&self, block: BlockId) -> Range<usize>

The range of nodes assigned to a given block.

Source

pub fn block_space(&self, block: BlockId) -> NodeSpace<N>

Computes the nodespace corresponding to a block.

Source

pub fn block_bounds(&self, block: BlockId) -> HyperBox<N>

Computes the bounds of a block.

Source

pub fn block_physical_boundary_flags(&self, block: BlockId) -> FaceMask<N>

Computes flags indicating whether a particular face of a block borders a physical boundary.

Source

pub fn block_boundary_classes( &self, block: BlockId, ) -> FaceArray<N, BoundaryClass>

Indicates what class of boundary condition is enforced along each face of the block.

Source

pub fn block_bcs<B: SystemBoundaryConds<N>>( &self, block: BlockId, bcs: B, ) -> BlockBoundaryConds<N, B>

Produces a block boundary which correctly accounts for interior interfaces.

Source

pub fn block_level(&self, block: BlockId) -> usize

The level of a given block.

Source

pub fn window_bounds( &self, block: BlockId, window: NodeWindow<N>, ) -> HyperBox<N>

Finds bounds associated with a node window.

Source

pub fn active_window(&self, cell: ActiveCellId) -> NodeWindow<N>

Retrieves the node window associated with a certain active cell on its block.

Source

pub fn interpolate_window( &self, cell: ActiveCellId, position: [f64; N], ) -> NodeWindow<N>

Retrieves the node window that is optimal for interpolating values to the given position, lying within the given active cell.

Source

pub fn element_window(&self, cell: ActiveCellId) -> NodeWindow<N>

Element associated with a given cell.

Source

pub fn element_coarse_window(&self, cell: ActiveCellId) -> NodeWindow<N>

Returns the window of nodes in a block corresponding to a given cell, including no padding.

Source

pub fn request_element(&mut self, width: usize, order: usize) -> Element<N>

Retrieves an element from the mesh’s element cache.

Source

pub fn replace_element(&mut self, element: Element<N>)

Reinserts an element into the mesh’s element cache.

Source

pub fn cell_node_size(&self, cell: ActiveCellId) -> [usize; N]

Retrieves the number of nodes along each axis of a cell. This defaults to [self.width; N] but is increased by one if the cell lies along a block boundary for a given axis.

Source

pub fn active_node_origin(&self, cell: ActiveCellId) -> [usize; N]

Returns the origin of an active cell in its block’s NodeSpace<N>.

Source

pub fn cell_needs_coarse_element(&self, cell: ActiveCellId) -> bool

Returns true if the given cell is on a boundary that does not contain ghost nodes. If this is the case we must fall back to a lower order element error approximation.

Source

pub fn num_levels(&self) -> usize

Returns number of levels on the mesh.

Source

pub fn min_spacing(&self) -> f64

Returns the minimum spatial distance between any two nodes on the mesh. Commonly used in conjunction with a CFL factor to determine time step.

Source

pub fn block_spacing(&self, block: BlockId) -> f64

Computes the spacing on a particular block (albeit not accounting for coarse-fine interfaces).

Source

pub fn block_compute<F: Fn(&Self, &MeshStore, BlockId) + Sync>(&mut self, f: F)

Runs a computation in parallel on every single block in the mesh, providing a MeshStore object for allocating scratch data.

Source

pub fn try_block_compute<E: Send, F: Fn(&Self, &MeshStore, BlockId) -> Result<(), E> + Sync>( &mut self, f: F, ) -> Result<(), E>

Runs a (possibily failable) computation in parallel on every single block in the mesh.

Source

pub fn l2_norm_system(&mut self, source: ImageRef<'_>) -> f64

Computes the maximum l2 norm of all fields in the system.

Source

pub fn max_norm_system(&mut self, source: ImageRef<'_>) -> f64

Computes the maximum l-infinity norm of all fields in the system.

Source

pub fn bottom_left_value(&self, src: &[f64]) -> f64

Returns the value of a function at the bottom left corner of the mesh.

Source

pub fn l2_norm(&mut self, src: &[f64]) -> f64

Computes the l2 norm of a field on the mesh.

Source

pub fn oscillation_heuristic(&mut self, src: &[f64]) -> f64

Source

pub fn oscillation_heuristic_system(&mut self, source: ImageRef<'_>) -> f64

Source

pub fn max_norm(&mut self, src: &[f64]) -> f64

Computes the l-infinity norm of a field on a mesh.

Source

pub fn write_debug(&self, result: impl Write)

Writes a textual summary of the Mesh to a sink. This is pimrarily used to debug features of the mesh that can’t be easily represented graphically (i.e in .vtu files).

Trait Implementations§

Source§

impl<const N: usize> Clone for Mesh<N>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> DataSize for Mesh<N>

Source§

const IS_DYNAMIC: bool = false

If true, the type has a heap size that can vary at runtime, depending on the actual value.
Source§

const STATIC_HEAP_SIZE: usize = 0

The amount of space a value of the type always occupies. If 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

Estimates the size of heap memory taken up by this value. Read more
Source§

impl<const N: usize> Debug for Mesh<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Default for Mesh<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, const N: usize> Deserialize<'de> for Mesh<N>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<const N: usize> Serialize for Mesh<N>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<const N: usize> !Freeze for Mesh<N>

§

impl<const N: usize> RefUnwindSafe for Mesh<N>

§

impl<const N: usize> Send for Mesh<N>

§

impl<const N: usize> Sync for Mesh<N>

§

impl<const N: usize> Unpin for Mesh<N>

§

impl<const N: usize> UnsafeUnpin for Mesh<N>

§

impl<const N: usize> !UnwindSafe for Mesh<N>

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

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> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

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

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows 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
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows 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
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .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
where Self: BorrowMut<B>, B: ?Sized,

Calls .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
where Self: AsRef<R>, R: ?Sized,

Calls .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
where Self: AsMut<R>, R: ?Sized,

Calls .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
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,