1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//! Identity of each component that declares capabilities.
/// Component that declares capabilities.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum ComponentId {
/// 2D shallow-water surface solver.
SurfaceSolver,
/// Opt-in 2D shallow-water surface solver running in F32 (CPU, CUDA, and WGPU).
SurfaceSolverF32,
/// Channel reach with a rectangular cross-section.
ChannelReachRectangular,
/// Channel reach with a triangular cross-section.
ChannelReachTriangular,
/// Channel reach with a surveyed cross-section.
ChannelReachSurveyed,
/// Channel reaches joined through pools.
ChannelPools,
/// Single level-pool storage.
LevelPool,
/// Level pools joined through connections.
CoupledLevelPools,
/// Runoff routed into pools.
RunoffPools,
/// Reservoir storage.
Reservoir,
/// Subcatchment runoff generator.
Subcatchment,
/// Soil infiltration model.
Soil,
/// Control logic that sets structure operation.
OperatingControl,
/// Actuator that moves a gate opening.
GateActuator,
/// Gate under operating control.
ControlledGate,
/// Pump under operating control.
ControlledPump,
/// 2D surface coupled to channel reaches through lateral bank weirs.
SurfaceChannels,
/// Closed-conduit culvert barrel geometry for circular and box barrels.
CulvertBarrel,
/// HDS-5 inlet-control headwater of circular and box culverts.
CulvertInlet,
/// Outlet-control headwater and hydraulic jump of circular and box culverts.
CulvertOutlet,
/// HDS-5 culvert structure law: discharge from the heads at both ends.
Culvert,
/// Pinned EPA SWMM v5.2.4 piped drainage network solver.
SwmmDrainage,
/// 2D surface coupled to a pinned EPA SWMM v5.2.4 piped drainage network.
SurfaceDrainage,
}
impl ComponentId {
/// Returns the stable kebab-case id. Persisted decisions store it, so it never changes.
pub fn id(&self) -> &'static str {
match self {
Self::SurfaceSolver => "surface-solver",
Self::SurfaceSolverF32 => "surface-solver-f32",
Self::ChannelReachRectangular => "channel-reach-rectangular",
Self::ChannelReachTriangular => "channel-reach-triangular",
Self::ChannelReachSurveyed => "channel-reach-surveyed",
Self::ChannelPools => "channel-pools",
Self::LevelPool => "level-pool",
Self::CoupledLevelPools => "coupled-level-pools",
Self::RunoffPools => "runoff-pools",
Self::Reservoir => "reservoir",
Self::Subcatchment => "subcatchment",
Self::Soil => "soil",
Self::OperatingControl => "operating-control",
Self::GateActuator => "gate-actuator",
Self::ControlledGate => "controlled-gate",
Self::ControlledPump => "controlled-pump",
Self::SurfaceChannels => "surface-channels",
Self::CulvertBarrel => "culvert-barrel",
Self::CulvertInlet => "culvert-inlet",
Self::CulvertOutlet => "culvert-outlet",
Self::Culvert => "culvert",
Self::SwmmDrainage => "swmm-drainage",
Self::SurfaceDrainage => "surface-drainage",
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::capability::id_check::assert_ids;
#[test]
fn ids_are_unique_kebab_case() {
let all = [
ComponentId::SurfaceSolver,
ComponentId::SurfaceSolverF32,
ComponentId::ChannelReachRectangular,
ComponentId::ChannelReachTriangular,
ComponentId::ChannelReachSurveyed,
ComponentId::ChannelPools,
ComponentId::LevelPool,
ComponentId::CoupledLevelPools,
ComponentId::RunoffPools,
ComponentId::Reservoir,
ComponentId::Subcatchment,
ComponentId::Soil,
ComponentId::OperatingControl,
ComponentId::GateActuator,
ComponentId::ControlledGate,
ComponentId::ControlledPump,
ComponentId::SurfaceChannels,
ComponentId::CulvertBarrel,
ComponentId::CulvertInlet,
ComponentId::CulvertOutlet,
ComponentId::Culvert,
ComponentId::SwmmDrainage,
ComponentId::SurfaceDrainage,
];
assert_ids(&all.map(|c| c.id()));
}
}