|
5 | 5 | #pragma once |
6 | 6 |
|
7 | 7 | #include "container_queries.hpp" |
8 | | -#include "state.hpp" |
9 | 8 |
|
10 | 9 | #include "../all_components.hpp" |
11 | 10 |
|
@@ -185,46 +184,52 @@ constexpr void register_topology_components(ComponentContainer const& components |
185 | 184 | [](Regulator const& regulator) { return regulator.regulated_object_type(); }); |
186 | 185 | } |
187 | 186 |
|
188 | | -ComponentTopology construct_topology(main_model_state_c auto const& state) { |
| 187 | +template <typename ComponentContainer> |
| 188 | + requires multi_extended_component_container_c<ComponentContainer, Branch, Branch3, Source, Shunt, GenericLoadGen, |
| 189 | + GenericVoltageSensor, GenericPowerSensor, GenericCurrentSensor, |
| 190 | + Regulator> |
| 191 | +ComponentTopology construct_topology(ComponentContainer const& components) { |
189 | 192 | ComponentTopology comp_topo; |
190 | | - register_topology_components<Node>(state.components, comp_topo); |
191 | | - register_topology_components<Branch>(state.components, comp_topo); |
192 | | - register_topology_components<Branch3>(state.components, comp_topo); |
193 | | - register_topology_components<Source>(state.components, comp_topo); |
194 | | - register_topology_components<Shunt>(state.components, comp_topo); |
195 | | - register_topology_components<GenericLoadGen>(state.components, comp_topo); |
196 | | - register_topology_components<GenericVoltageSensor>(state.components, comp_topo); |
197 | | - register_topology_components<GenericPowerSensor>(state.components, comp_topo); |
198 | | - register_topology_components<GenericCurrentSensor>(state.components, comp_topo); |
199 | | - register_topology_components<Regulator>(state.components, comp_topo); |
| 193 | + register_topology_components<Node>(components, comp_topo); |
| 194 | + register_topology_components<Branch>(components, comp_topo); |
| 195 | + register_topology_components<Branch3>(components, comp_topo); |
| 196 | + register_topology_components<Source>(components, comp_topo); |
| 197 | + register_topology_components<Shunt>(components, comp_topo); |
| 198 | + register_topology_components<GenericLoadGen>(components, comp_topo); |
| 199 | + register_topology_components<GenericVoltageSensor>(components, comp_topo); |
| 200 | + register_topology_components<GenericPowerSensor>(components, comp_topo); |
| 201 | + register_topology_components<GenericCurrentSensor>(components, comp_topo); |
| 202 | + register_topology_components<Regulator>(components, comp_topo); |
200 | 203 | return comp_topo; |
201 | 204 | } |
202 | 205 |
|
203 | | -ComponentConnections construct_components_connections(main_model_state_c auto const& state) { |
| 206 | +template <typename ComponentContainer> |
| 207 | + requires multi_extended_component_container_c<ComponentContainer, Branch, Branch3, Source> |
| 208 | +ComponentConnections construct_components_connections(ComponentContainer const& components) { |
204 | 209 | ComponentConnections comp_conn; |
205 | | - comp_conn.branch_connected.resize(get_component_size<Branch>(state.components)); |
206 | | - comp_conn.branch_phase_shift.resize(get_component_size<Branch>(state.components)); |
207 | | - comp_conn.branch3_connected.resize(get_component_size<Branch3>(state.components)); |
208 | | - comp_conn.branch3_phase_shift.resize(get_component_size<Branch3>(state.components)); |
209 | | - comp_conn.source_connected.resize(get_component_size<Source>(state.components)); |
| 210 | + comp_conn.branch_connected.resize(get_component_size<Branch>(components)); |
| 211 | + comp_conn.branch_phase_shift.resize(get_component_size<Branch>(components)); |
| 212 | + comp_conn.branch3_connected.resize(get_component_size<Branch3>(components)); |
| 213 | + comp_conn.branch3_phase_shift.resize(get_component_size<Branch3>(components)); |
| 214 | + comp_conn.source_connected.resize(get_component_size<Source>(components)); |
210 | 215 | std::ranges::transform( |
211 | | - state.components.template citer<Branch>(), comp_conn.branch_connected.begin(), [](Branch const& branch) { |
| 216 | + components.template citer<Branch>(), comp_conn.branch_connected.begin(), [](Branch const& branch) { |
212 | 217 | return BranchConnected{static_cast<IntS>(branch.from_status()), static_cast<IntS>(branch.to_status())}; |
213 | 218 | }); |
214 | 219 |
|
215 | | - std::ranges::transform(state.components.template citer<Branch>(), comp_conn.branch_phase_shift.begin(), |
| 220 | + std::ranges::transform(components.template citer<Branch>(), comp_conn.branch_phase_shift.begin(), |
216 | 221 | [](Branch const& branch) { return branch.phase_shift(); }); |
217 | 222 |
|
218 | 223 | std::ranges::transform( |
219 | | - state.components.template citer<Branch3>(), comp_conn.branch3_connected.begin(), [](Branch3 const& branch3) { |
| 224 | + components.template citer<Branch3>(), comp_conn.branch3_connected.begin(), [](Branch3 const& branch3) { |
220 | 225 | return Branch3Connected{static_cast<IntS>(branch3.status_1()), static_cast<IntS>(branch3.status_2()), |
221 | 226 | static_cast<IntS>(branch3.status_3())}; |
222 | 227 | }); |
223 | 228 |
|
224 | | - std::ranges::transform(state.components.template citer<Branch3>(), comp_conn.branch3_phase_shift.begin(), |
| 229 | + std::ranges::transform(components.template citer<Branch3>(), comp_conn.branch3_phase_shift.begin(), |
225 | 230 | [](Branch3 const& branch3) { return branch3.phase_shift(); }); |
226 | 231 |
|
227 | | - std::ranges::transform(state.components.template citer<Source>(), comp_conn.source_connected.begin(), |
| 232 | + std::ranges::transform(components.template citer<Source>(), comp_conn.source_connected.begin(), |
228 | 233 | [](Source const& source) { return source.status(); }); |
229 | 234 | return comp_conn; |
230 | 235 | } |
|
0 commit comments