diff --git a/src/fem/mod.rs b/src/fem/mod.rs index c18f01a..cc32569 100644 --- a/src/fem/mod.rs +++ b/src/fem/mod.rs @@ -29,9 +29,13 @@ use vtkio::{ const ELEMENT_NUMBERING_OFFSET: usize = 1; const ELEMENT_TYPE: &str = "C3D8R"; pub const NODE_NUMBERING_OFFSET: usize = 1; + +/// The number of nodes in a hexahedral finite element. pub const NUM_NODES_HEX: usize = 8; +/// A vector of finite element block IDs. pub type Blocks = Vec; + pub type VecConnectivity = Vec>; pub type Metrics = Array1; pub type Nodes = Vec; diff --git a/src/lib.rs b/src/lib.rs index 469adb8..d69d533 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,16 +16,23 @@ mod fem; mod tree; mod voxel; -pub use fem::{Blocks, FiniteElements, HexahedralFiniteElements, Smoothing, NUM_NODES_HEX}; +pub use fem::{Blocks, FiniteElements, HexahedralFiniteElements, Smoothing}; pub use tree::{Octree, Tree}; pub use voxel::{VoxelData, Voxels}; use flavio::{math::TensorRank1Vec, mechanics::Vector as VectorFlavio}; +/// The number of spatial dimensions. const NSD: usize = 3; +/// An element-to-node connectivity. pub type Connectivity = Vec<[usize; N]>; + +/// A three-dimensional coordinate. pub type Coordinate = VectorFlavio<1>; -pub type Coordinates = TensorRank1Vec<3, 1>; -pub type Points = TensorRank1Vec<3, 1>; + +/// A vector of three-dimensional coordinates. +pub type Coordinates = TensorRank1Vec; + +/// A three-dimensional vector. pub type Vector = VectorFlavio<1>; diff --git a/src/tree/mod.rs b/src/tree/mod.rs index dfee2e5..78387ce 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -2,8 +2,8 @@ use std::time::Instant; use super::{ - fem::NODE_NUMBERING_OFFSET, Coordinate, Coordinates, HexahedralFiniteElements, Points, Vector, - VoxelData, Voxels, NUM_NODES_HEX, + fem::{NODE_NUMBERING_OFFSET, NUM_NODES_HEX}, + Coordinate, Coordinates, HexahedralFiniteElements, Vector, VoxelData, Voxels, }; use flavio::math::{Tensor, TensorArray}; use ndarray::{s, Axis}; @@ -15,11 +15,14 @@ const NUM_OCTANTS: usize = 8; type Cells = [Cell; NUM_OCTANTS]; type Faces = [Option; NUM_FACES]; type Indices = [usize; NUM_OCTANTS]; + +/// The octree type. pub type Octree = Vec; +/// Methods for trees such as quadtrees or octrees. pub trait Tree { fn balance(&mut self, strong: bool); - fn from_points(levels: &usize, points: &Points) -> Self; + fn from_points(levels: &usize, points: &Coordinates) -> Self; fn from_voxels(voxels: Voxels) -> Self; fn into_finite_elements( self, @@ -47,7 +50,7 @@ pub struct Cell { } impl Cell { - fn contains(&self, points: &Points) -> bool { + fn contains(&self, points: &Coordinates) -> bool { for point in points.iter() { if &point[0] >= self.get_min_x() && &point[0] <= self.get_max_x() @@ -633,7 +636,7 @@ impl Tree for Octree { } } } - fn from_points(levels: &usize, points: &Points) -> Self { + fn from_points(levels: &usize, points: &Coordinates) -> Self { let x_vals: Vec = points.iter().map(|point| point[0]).collect(); let y_vals: Vec = points.iter().map(|point| point[1]).collect(); let z_vals: Vec = points.iter().map(|point| point[2]).collect(); diff --git a/src/voxel/mod.rs b/src/voxel/mod.rs index 50a50a8..d8f680d 100644 --- a/src/voxel/mod.rs +++ b/src/voxel/mod.rs @@ -25,10 +25,12 @@ use tiff::{ type InitialNodalCoordinates = Vec>; type Nel = [usize; NSD]; -pub type VoxelData = Array3; type VoxelDataFlattened = Vec; type VoxelDataSized = Vec<[usize; N]>; +/// The segmentation data corresponding to voxels. +pub type VoxelData = Array3; + /// The voxels type. pub struct Voxels { data: VoxelData,