@@ -17,12 +17,6 @@ namespace power_grid_model::main_core::update {
1717
1818constexpr Idx invalid_index{-1 };
1919
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-
2620namespace detail {
2721template <component_c Component, forward_iterator_like<typename Component::UpdateType> ForwardIterator, typename Func>
2822 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
9892 }
9993 // Remember the begin iterator of the first scenario, then loop over the remaining scenarios and
10094 // check the ids
101- auto const first_span = all_spans[ 0 ] ;
95+ auto const first_span = all_spans. front () ;
10296 // check the subsequent scenarios
10397 // only return true if ids of all scenarios match the ids of the first batch
10498
@@ -157,9 +151,9 @@ inline void validate_update_data_independence(UpdateCompProperties const& comp)
157151}
158152
159153template <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{};
163157 size_t comp_idx{};
164158 utils::run_functor_with_all_types_return_void<ComponentTypes...>(
165159 [&result, &relevant_component_count, &update_data, &comp_idx]<typename CompType>() {
@@ -227,12 +221,13 @@ std::vector<Idx2D> get_component_sequence(MainModelState<ComponentContainer> con
227221} // namespace detail
228222
229223template <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) {
233228 return utils::run_functor_with_all_types_return_array<ComponentTypes...>(
234229 [&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)) {
236231 return std::vector<Idx2D>{};
237232 }
238233 auto const n_components = state.components .template size <CompType>();
@@ -245,12 +240,14 @@ SequenceIdx<ComponentTypes...> get_all_sequence_idx_map(MainModelState<Component
245240// The sequence idx map of the batch is the same as that of the first scenario in the batch (assuming homogeneity)
246241// This is the entry point for permanent updates.
247242template <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{};
251246 Idx comp_idx{};
252247 utils::run_functor_with_all_types_return_void<ComponentTypes...>(
253248 [&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.
254251 components_to_store[comp_idx] = (update_data.find_component (CompType::name, false ) != invalid_index);
255252 ++comp_idx;
256253 });
0 commit comments