#[derive(Debug, Clone, PartialEq)]
pub enum MeshError {
ArrayLengthMismatch {
array: &'static str,
expected: usize,
got: usize,
},
PatchStartMismatch {
name: String,
expected: usize,
got: usize,
},
PatchCoverageMismatch {
covered: usize,
n_faces: usize,
},
NonPositiveCellCount { got: i64 },
CyclicPairMismatch {
name: String,
reason: &'static str,
},
AmiCouplingInvalid {
target_face: usize,
reason: &'static str,
},
}
impl std::fmt::Display for MeshError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
MeshError::ArrayLengthMismatch {
array,
expected,
got,
} => write!(
f,
"mesh array '{array}': expected length {expected}, got {got}"
),
MeshError::PatchStartMismatch {
name,
expected,
got,
} => write!(
f,
"patch '{name}': expected to start at face {expected}, starts at {got}"
),
MeshError::PatchCoverageMismatch { covered, n_faces } => write!(
f,
"boundary patches cover {covered} faces but n_faces = {n_faces}"
),
MeshError::NonPositiveCellCount { got } => {
write!(f, "number_of_cells must be ≥ 1, got {got}")
}
MeshError::CyclicPairMismatch { name, reason } => {
write!(f, "cyclic patch '{name}': {reason}")
}
MeshError::AmiCouplingInvalid {
target_face,
reason,
} => {
write!(f, "AMI coupling at target face {target_face}: {reason}")
}
}
}
}
impl std::error::Error for MeshError {}