Skip to content

Commit acf5c96

Browse files
committed
address comments
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
1 parent b6c4f4d commit acf5c96

File tree

4 files changed

+8
-30
lines changed

4 files changed

+8
-30
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/update.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ SequenceIdx<ComponentTypes...> get_all_sequence_idx_map(MainModelState<Component
247247
template <class... ComponentTypes, class ComponentContainer>
248248
SequenceIdx<ComponentTypes...> get_all_sequence_idx_map(MainModelState<ComponentContainer> const& state,
249249
ConstDataset const& update_data) {
250-
// Independence for all components is set to true as permanent updates involve only one scenario.
251-
// Flags for all components (not only the ones present in update_data) are set to avoid more expensive checks.
252-
constexpr ComponentFlags<ComponentTypes...> all_true = [] {
253-
ComponentFlags<ComponentTypes...> result{};
254-
std::ranges::fill(result, true);
255-
return result;
256-
}();
257-
return get_all_sequence_idx_map<ComponentTypes...>(state, update_data, 0, all_true);
250+
ComponentFlags<ComponentTypes...> components_to_store{};
251+
Idx comp_idx{};
252+
utils::run_functor_with_all_types_return_void<ComponentTypes...>(
253+
[&update_data, &components_to_store, &comp_idx]<typename CompType>() {
254+
components_to_store[comp_idx] = (update_data.find_component(CompType::name, false) != invalid_index);
255+
++comp_idx;
256+
});
257+
return get_all_sequence_idx_map<ComponentTypes...>(state, update_data, 0, components_to_store);
258258
}
259259

260260
// template to update components

power_grid_model_c/power_grid_model/include/power_grid_model/main_model.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class MainModel {
5050
};
5151
~MainModel() { impl_.reset(); }
5252

53-
std::map<std::string, Idx, std::less<>> all_component_count() const { return impl().all_component_count(); }
5453
void get_indexer(std::string_view component_type, ID const* id_begin, Idx size, Idx* indexer_begin) const {
5554
impl().get_indexer(component_type, id_begin, size, indexer_begin);
5655
}

power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,6 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
166166
return state_.components.template size<CompType>();
167167
}
168168

169-
// all component count
170-
std::map<std::string, Idx, std::less<>> all_component_count() const {
171-
auto const get_comp_count = [this]<typename CT>() {
172-
return make_pair(std::string{CT::name}, this->component_count<CT>());
173-
};
174-
auto const all_count =
175-
main_core::utils::run_functor_with_all_types_return_array<ComponentType...>(get_comp_count);
176-
std::map<std::string, Idx, std::less<>> result;
177-
for (auto const& [name, count] : all_count) {
178-
if (count > 0) {
179-
// only add if count is greater than 0
180-
result[name] = count;
181-
}
182-
}
183-
return result;
184-
}
185-
186169
// helper function to get the number of components per type
187170
std::array<Idx, n_types> get_n_components_per_type() const {
188171
std::array<Idx, n_types> result{};

tests/cpp_integration_tests/test_main_model.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,10 +1208,6 @@ TEST_CASE("Test main model - runtime dispatch") {
12081208
state.asym_node.data());
12091209

12101210
MainModel model{50.0, input_data};
1211-
auto const count = model.all_component_count();
1212-
CHECK(count.at("node") == 3);
1213-
CHECK(count.at("source") == 2);
1214-
CHECK(count.find("sym_gen") == count.cend());
12151211

12161212
// calculation
12171213
model.calculate(get_default_options(symmetric, newton_raphson), sym_result_data);

0 commit comments

Comments
 (0)