Skip to content

Commit

Permalink
docs cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuche committed Dec 17, 2024
1 parent 9ccab7b commit a7b0ed2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/fem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize>;

pub type VecConnectivity = Vec<Vec<usize>>;
pub type Metrics = Array1<f64>;
pub type Nodes = Vec<usize>;
Expand Down
11 changes: 9 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ 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<const N: usize> = 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<NSD, 1>;

/// A three-dimensional vector.
pub type Vector = VectorFlavio<1>;
11 changes: 7 additions & 4 deletions src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::time::Instant;

use super::{
fem::NODE_NUMBERING_OFFSET, Coordinate, Coordinates, HexahedralFiniteElements, Points, Vector,
fem::NODE_NUMBERING_OFFSET, Coordinate, Coordinates, HexahedralFiniteElements, Vector,
VoxelData, Voxels, NUM_NODES_HEX,
};
use flavio::math::{Tensor, TensorArray};
Expand All @@ -15,11 +15,14 @@ const NUM_OCTANTS: usize = 8;
type Cells = [Cell; NUM_OCTANTS];
type Faces = [Option<usize>; NUM_FACES];
type Indices = [usize; NUM_OCTANTS];

/// The octree type.
pub type Octree = Vec<Cell>;

/// 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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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<f64> = points.iter().map(|point| point[0]).collect();
let y_vals: Vec<f64> = points.iter().map(|point| point[1]).collect();
let z_vals: Vec<f64> = points.iter().map(|point| point[2]).collect();
Expand Down
4 changes: 3 additions & 1 deletion src/voxel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ use tiff::{

type InitialNodalCoordinates = Vec<Option<Coordinate>>;
type Nel = [usize; NSD];
pub type VoxelData = Array3<u8>;
type VoxelDataFlattened = Vec<u8>;
type VoxelDataSized<const N: usize> = Vec<[usize; N]>;

/// The segmentation data corresponding to voxels.
pub type VoxelData = Array3<u8>;

/// The voxels type.
pub struct Voxels {
data: VoxelData,
Expand Down

0 comments on commit a7b0ed2

Please sign in to comment.