runmat_meshing/visualization/field_mapping/
error.rs1use runmat_meshing_core::contracts::AnalysisFieldTopologyLocation;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
4pub enum FieldMappingError {
5 FieldTopologyMissing {
6 topology_id: String,
7 location: AnalysisFieldTopologyLocation,
8 element_kind: Option<String>,
9 },
10 FieldTopologyCountMismatch {
11 topology_id: String,
12 location: AnalysisFieldTopologyLocation,
13 expected_entity_count: usize,
14 actual_entity_count: usize,
15 },
16 FieldTopologyElementKindMismatch {
17 topology_id: String,
18 location: AnalysisFieldTopologyLocation,
19 expected_element_kind: String,
20 actual_element_kind: Option<String>,
21 },
22 ElementFieldLengthMismatch {
23 element_value_count: usize,
24 volume_element_count: usize,
25 },
26 NodeVectorFieldLengthMismatch {
27 node_value_count: usize,
28 node_count: usize,
29 },
30 NonFiniteElementValue {
31 element_index: usize,
32 },
33 NonFiniteNodeVectorValue {
34 node_index: usize,
35 component_index: usize,
36 },
37 BoundaryFaceMissingAdjacentVolume {
38 face_id: String,
39 },
40 BoundaryFaceReferencesUnknownVolume {
41 face_id: String,
42 volume_element_id: String,
43 },
44 BoundaryFaceReferencesUnknownNode {
45 face_id: String,
46 node_id: u32,
47 },
48 BoundaryFaceHasNoNodes {
49 face_id: String,
50 },
51 BoundaryEdgeReferencesUnknownNode {
52 edge_id: String,
53 node_id: u32,
54 },
55}
56
57impl std::fmt::Display for FieldMappingError {
58 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
59 match self {
60 Self::FieldTopologyMissing {
61 topology_id,
62 location,
63 element_kind,
64 } => write!(
65 formatter,
66 "mesh field topology descriptor is missing: topology_id={topology_id} location={location:?} element_kind={}",
67 element_kind.as_deref().unwrap_or("none")
68 ),
69 Self::FieldTopologyCountMismatch {
70 topology_id,
71 location,
72 expected_entity_count,
73 actual_entity_count,
74 } => write!(
75 formatter,
76 "mesh field topology count mismatch: topology_id={topology_id} location={location:?} expected_entity_count={expected_entity_count} actual_entity_count={actual_entity_count}"
77 ),
78 Self::FieldTopologyElementKindMismatch {
79 topology_id,
80 location,
81 expected_element_kind,
82 actual_element_kind,
83 } => write!(
84 formatter,
85 "mesh field topology element kind mismatch: topology_id={topology_id} location={location:?} expected_element_kind={expected_element_kind} actual_element_kind={}",
86 actual_element_kind.as_deref().unwrap_or("none")
87 ),
88 Self::ElementFieldLengthMismatch {
89 element_value_count,
90 volume_element_count,
91 } => write!(
92 formatter,
93 "element scalar field length {element_value_count} does not match volume element count {volume_element_count}"
94 ),
95 Self::NodeVectorFieldLengthMismatch {
96 node_value_count,
97 node_count,
98 } => write!(
99 formatter,
100 "node vector field length {node_value_count} does not match mesh node count {node_count}"
101 ),
102 Self::NonFiniteElementValue { element_index } => {
103 write!(formatter, "element scalar field value {element_index} is not finite")
104 }
105 Self::NonFiniteNodeVectorValue {
106 node_index,
107 component_index,
108 } => write!(
109 formatter,
110 "node vector field value {node_index} component {component_index} is not finite"
111 ),
112 Self::BoundaryFaceMissingAdjacentVolume { face_id } => {
113 write!(formatter, "boundary face {face_id} has no adjacent volume element")
114 }
115 Self::BoundaryFaceReferencesUnknownVolume {
116 face_id,
117 volume_element_id,
118 } => write!(
119 formatter,
120 "boundary face {face_id} references unknown volume element {volume_element_id}"
121 ),
122 Self::BoundaryFaceReferencesUnknownNode { face_id, node_id } => write!(
123 formatter,
124 "boundary face {face_id} references unknown node {node_id}"
125 ),
126 Self::BoundaryFaceHasNoNodes { face_id } => {
127 write!(formatter, "boundary face {face_id} has no nodes")
128 }
129 Self::BoundaryEdgeReferencesUnknownNode { edge_id, node_id } => write!(
130 formatter,
131 "boundary edge {edge_id} references unknown node {node_id}"
132 ),
133 }
134 }
135}
136
137impl std::error::Error for FieldMappingError {}