Files
OneCAD-Simulation/crates/mesh/src/lib.rs
T
jyvikoandClaude Opus 5.5 3587b0de74 mesh: unstructured all-hex octree mesher
`fieldcraft_mesh::octree::octree_hex_mesh` meshes any closed part with hex8 only:

- an adaptive 3-refinement grid (27-tree) with strong balance and closure, filled with
  conforming node-marking transition templates (Schneiders; checked over all 48 symmetries);
- a core of grid cells kept clear of the boundary (the HybridOctree buffer rule), with
  non-manifold cleanup and a genus check against the part;
- a feature graph from the B-rep (corners, curves, patches) and a partition-first map of the
  core's boundary onto it, then two boundary layers: a padding layer and a pillow per patch,
  so every face boundary and sharp edge is captured by element edges;
- a Garanzha-type untangling and fitting energy (shape term |J|^3/chi, a volume term and a
  soft fitting term, deterministic across platforms), a compass search on the worst
  elements and a certified repair; failures refine the grid near them and rebuild, within
  bounded attempts and growth.

The output passes the certified Jacobian check of every element and a gate that the
boundary encloses the elements' volume; boundary quads carry their B-rep faces. Quality is
reported with the same scaled Jacobian as mesh.quality. Literature notes for each step are in
docs/meshing/literature.md (B1.6-B1.10).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm
2026-10-14 07:38:11 -04:00

45 lines
1.4 KiB
Rust

//! 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)]
pub mod block;
pub mod cdt;
pub mod delaunay;
pub mod hex;
pub mod join;
pub mod octree;
pub mod planar;
pub mod quad;
pub mod quality;
pub mod size;
pub mod surface;
mod vec3;
#[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),
/// The input is valid but outside what the mesher handles yet (a body that is not
/// sweepable, …); the message says why.
#[error("not supported yet: {0}")]
Unsupported(String),
/// The boundary surface has defects ([`surface::BoundarySurface::new`]).
#[error("invalid boundary surface: {0}")]
Surface(surface::Defects),
#[error(transparent)]
Model(#[from] fieldcraft_model::Error),
}
pub type Result<T> = std::result::Result<T, Error>;
pub mod predicates;