cartan_dec/error.rs
1// ~/cartan/cartan-dec/src/error.rs
2
3//! Error type for cartan-dec operations.
4
5use thiserror::Error;
6
7/// Errors that can occur in discrete exterior calculus operations.
8#[derive(Debug, Error)]
9pub enum DecError {
10 /// The mesh has no vertices, edges, or triangles.
11 #[error("empty mesh")]
12 EmptyMesh,
13
14 /// A simplex index is out of bounds.
15 #[error("index out of bounds: index {index} in collection of size {len}")]
16 IndexOutOfBounds { index: usize, len: usize },
17
18 /// A mesh is not well-centered (a circumcenter lies outside its simplex).
19 /// This causes the Hodge star to have negative weights, breaking SPD.
20 #[error("mesh is not well-centered: simplex {simplex} has negative dual volume {volume:.6e}")]
21 NotWellCentered { simplex: usize, volume: f64 },
22
23 /// The Laplacian matrix is singular (expected for closed manifolds without
24 /// boundary conditions; caller should use a pseudoinverse or add a pin constraint).
25 #[error("Laplacian is singular; add a Dirichlet pin or use pseudoinverse")]
26 SingularLaplacian,
27
28 /// A field has the wrong number of components for this mesh.
29 #[error("field length mismatch: expected {expected}, got {got}")]
30 FieldLengthMismatch { expected: usize, got: usize },
31
32 /// Linear algebra error (e.g., Cholesky failed on non-SPD matrix).
33 #[error("linear algebra error: {0}")]
34 LinearAlgebra(String),
35}