Skip to content

Commit

Permalink
Merge pull request #246 from autotwin/dev
Browse files Browse the repository at this point in the history
dev
  • Loading branch information
mrbuche authored Dec 17, 2024
2 parents 9ccab7b + 72d28a9 commit e9bc0ef
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 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
13 changes: 10 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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>;
13 changes: 8 additions & 5 deletions src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
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 e9bc0ef

Please sign in to comment.