diff --git a/Cargo.lock b/Cargo.lock index 630fcc6..93c9b05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -367,6 +367,14 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "modelcraft-mesh" +version = "0.1.0" +dependencies = [ + "modelcraft-model", + "thiserror 2.0.21", +] + [[package]] name = "modelcraft-model" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 8927afc..ae4c112 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ repository = "https://github.com/jyviko/modelcraft" # internal modelcraft-model = { path = "crates/model" } modelcraft-geometry = { path = "crates/geometry" } +modelcraft-mesh = { path = "crates/mesh" } modelcraft-engine = { path = "crates/engine" } # foundation diff --git a/crates/mesh/Cargo.toml b/crates/mesh/Cargo.toml new file mode 100644 index 0000000..00c27a8 --- /dev/null +++ b/crates/mesh/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "modelcraft-mesh" +description = "ModelCraft's meshing: robust predicates, surface preparation, tetrahedral and hexahedral meshing, quality metrics" +version.workspace = true +edition.workspace = true +license.workspace = true + +[lints] +workspace = true + +[dependencies] +modelcraft-model = { workspace = true } +thiserror = { workspace = true } diff --git a/crates/mesh/src/lib.rs b/crates/mesh/src/lib.rs new file mode 100644 index 0000000..4fb0843 --- /dev/null +++ b/crates/mesh/src/lib.rs @@ -0,0 +1,22 @@ +//! Meshing: robust geometric predicates, boundary surface preparation, tetrahedral and +//! hexahedral volume meshing, and element quality. +//! +//! Every algorithm here is implemented from the papers cited in its module docs (see +//! `docs/meshing/literature.md`); no GPL-family code is read or used. Meshing decisions use exact +//! predicates, results are deterministic, and every iterative stage is bounded. +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] +#![forbid(unsafe_code)] + +#[derive(Debug, Clone, PartialEq, thiserror::Error)] +pub enum Error { + #[error("invalid input: {0}")] + Invalid(String), + #[error("limit reached: {0}")] + Limit(String), + #[error("meshing failed: {0}")] + Failed(String), + #[error(transparent)] + Model(#[from] modelcraft_model::Error), +} + +pub type Result = std::result::Result; diff --git a/docs/architecture.md b/docs/architecture.md index 2095559..6e75267 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -20,7 +20,7 @@ crates in strictly lower layers. |---|---|---|---| | L0 | `modelcraft-model` | Solver-neutral FE model: nodes, elements by label; materials, sections, sets, BCs, loads and steps as they land. Knows no file format. | started | | L1 | `modelcraft-geometry` | The only door to SolidCraft: B-rep bodies, measures, tessellation into a face-tagged `SurfaceMesh`. No SolidCraft type in its API. | started | -| L1 | `modelcraft-mesh` | Surface preparation (weld, watertightness, feature edges), robust predicates, Delaunay tetrahedralization and refinement, Voronoi-based optimization, hex meshing, quality metrics. | planned | +| L1 | `modelcraft-mesh` | Surface preparation (weld, watertightness, feature edges), robust predicates, Delaunay tetrahedralization and refinement, Voronoi-based optimization, hex meshing, quality metrics. | started | | L1 | `modelcraft-solver` | Element formulations, assembly, sparse linear static and modal solution. | planned | | L1 | `modelcraft-decks` | Abaqus input, Nastran bulk data and LS-DYNA keyword readers and writers, to and from `model`. | planned | | L1 | `modelcraft-render` | Display data (meshes, contour maps) without a GPU dependency. | planned |