@@ -17,12 +17,6 @@ namespace power_grid_model::main_core::update {
17
17
18
18
constexpr Idx invalid_index{-1 };
19
19
20
- // main core utils
21
- template <class CompType , class ... ComponentTypes>
22
- constexpr auto index_of_component = main_core::utils::index_of_component<CompType, ComponentTypes...>;
23
- template <class ... ComponentTypes> using SequenceIdx = main_core::utils::SequenceIdx<ComponentTypes...>;
24
- template <class ... ComponentTypes> using ComponentFlags = main_core::utils::ComponentFlags<ComponentTypes...>;
25
-
26
20
namespace detail {
27
21
template <component_c Component, forward_iterator_like<typename Component::UpdateType> ForwardIterator, typename Func>
28
22
requires std::invocable<std::remove_cvref_t <Func>, typename Component::UpdateType, Idx2D const &>
@@ -98,7 +92,7 @@ template <typename CompType> void process_buffer_span(auto const& all_spans, Upd
98
92
}
99
93
// Remember the begin iterator of the first scenario, then loop over the remaining scenarios and
100
94
// check the ids
101
- auto const first_span = all_spans[ 0 ] ;
95
+ auto const first_span = all_spans. front () ;
102
96
// check the subsequent scenarios
103
97
// only return true if ids of all scenarios match the ids of the first batch
104
98
@@ -157,9 +151,9 @@ inline void validate_update_data_independence(UpdateCompProperties const& comp)
157
151
}
158
152
159
153
template <class ... ComponentTypes>
160
- ComponentFlags<ComponentTypes...> is_update_independent (ConstDataset const & update_data,
161
- std::span<Idx const > relevant_component_count) {
162
- ComponentFlags<ComponentTypes...> result{};
154
+ main_core::utils:: ComponentFlags<ComponentTypes...>
155
+ is_update_independent (ConstDataset const & update_data, std::span<Idx const > relevant_component_count) {
156
+ main_core::utils:: ComponentFlags<ComponentTypes...> result{};
163
157
size_t comp_idx{};
164
158
utils::run_functor_with_all_types_return_void<ComponentTypes...>(
165
159
[&result, &relevant_component_count, &update_data, &comp_idx]<typename CompType>() {
@@ -227,12 +221,13 @@ std::vector<Idx2D> get_component_sequence(MainModelState<ComponentContainer> con
227
221
} // namespace detail
228
222
229
223
template <class ... ComponentTypes, class ComponentContainer >
230
- SequenceIdx<ComponentTypes...> get_all_sequence_idx_map (MainModelState<ComponentContainer> const & state,
231
- ConstDataset const & update_data, Idx scenario_idx,
232
- ComponentFlags<ComponentTypes...> const & components_to_store) {
224
+ main_core::utils::SequenceIdx<ComponentTypes...>
225
+ get_all_sequence_idx_map (MainModelState<ComponentContainer> const & state, ConstDataset const & update_data,
226
+ Idx scenario_idx,
227
+ main_core::utils::ComponentFlags<ComponentTypes...> const & components_to_store) {
233
228
return utils::run_functor_with_all_types_return_array<ComponentTypes...>(
234
229
[&update_data, &components_to_store, &state, scenario_idx]<typename CompType>() {
235
- if (!std::get<index_of_component<CompType, ComponentTypes...>>(components_to_store)) {
230
+ if (!std::get<main_core::utils:: index_of_component<CompType, ComponentTypes...>>(components_to_store)) {
236
231
return std::vector<Idx2D>{};
237
232
}
238
233
auto const n_components = state.components .template size <CompType>();
@@ -245,12 +240,14 @@ SequenceIdx<ComponentTypes...> get_all_sequence_idx_map(MainModelState<Component
245
240
// The sequence idx map of the batch is the same as that of the first scenario in the batch (assuming homogeneity)
246
241
// This is the entry point for permanent updates.
247
242
template <class ... ComponentTypes, class ComponentContainer >
248
- SequenceIdx<ComponentTypes...> get_all_sequence_idx_map (MainModelState<ComponentContainer> const & state,
249
- ConstDataset const & update_data) {
250
- ComponentFlags<ComponentTypes...> components_to_store{};
243
+ main_core::utils:: SequenceIdx<ComponentTypes...>
244
+ get_all_sequence_idx_map (MainModelState<ComponentContainer> const & state, ConstDataset const & update_data) {
245
+ main_core::utils:: ComponentFlags<ComponentTypes...> components_to_store{};
251
246
Idx comp_idx{};
252
247
utils::run_functor_with_all_types_return_void<ComponentTypes...>(
253
248
[&update_data, &components_to_store, &comp_idx]<typename CompType>() {
249
+ // In a permanent update, all components that are present are independent (because only one scenario is
250
+ // considered) hence all present components are labeled are marked true (independent), the rest are false.
254
251
components_to_store[comp_idx] = (update_data.find_component (CompType::name, false ) != invalid_index);
255
252
++comp_idx;
256
253
});
0 commit comments