Skip to content

Commit 746264f

Browse files
committed
rename
Signed-off-by: Nitish Bharambe <[email protected]>
1 parent 024be07 commit 746264f

File tree

5 files changed

+72
-73
lines changed

5 files changed

+72
-73
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/job_adapter.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ template <class MainModel> class JobAdapter;
1818

1919
template <class MainModel> class JobAdapter : public JobInterface<JobAdapter<MainModel>> {
2020
public:
21-
using MainModelType = typename MainModel::MainModelType;
21+
using ModelType = typename MainModel::ImplType;
2222

2323
JobAdapter(std::reference_wrapper<MainModel> model_reference,
2424
std::reference_wrapper<MainModelOptions const> options)
@@ -88,12 +88,12 @@ template <class MainModel> class JobAdapter : public JobInterface<JobAdapter<Mai
8888
std::reference_wrapper<MainModel> model_reference_;
8989
std::reference_wrapper<MainModelOptions const> options_;
9090

91-
typename MainModelType::ComponentFlags components_to_update_{};
92-
typename MainModelType::UpdateIndependence update_independence_{};
93-
typename MainModelType::ComponentFlags independence_flags_{};
94-
std::shared_ptr<typename MainModelType::SequenceIdx> all_scenarios_sequence_;
91+
typename ModelType::ComponentFlags components_to_update_{};
92+
typename ModelType::UpdateIndependence update_independence_{};
93+
typename ModelType::ComponentFlags independence_flags_{};
94+
std::shared_ptr<typename ModelType::SequenceIdx> all_scenarios_sequence_;
9595
// current_scenario_sequence_cache_ is calculated per scenario, so it is excluded from the constructors.
96-
typename MainModelType::SequenceIdx current_scenario_sequence_cache_{};
96+
typename ModelType::SequenceIdx current_scenario_sequence_cache_{};
9797

9898
Logger* log_{nullptr};
9999

@@ -124,17 +124,17 @@ template <class MainModel> class JobAdapter : public JobInterface<JobAdapter<Mai
124124
// cache component update order where possible.
125125
// the order for a cacheable (independent) component by definition is the same across all scenarios
126126
components_to_update_ = model_reference_.get().get_components_to_update(update_data);
127-
update_independence_ = main_core::update::independence::check_update_independence<MainModelType>(
127+
update_independence_ = main_core::update::independence::check_update_independence<ModelType>(
128128
model_reference_.get().state(), update_data);
129129
std::ranges::transform(update_independence_, independence_flags_.begin(),
130130
[](auto const& comp) { return comp.is_independent(); });
131-
all_scenarios_sequence_ = std::make_shared<typename MainModelType::SequenceIdx>(
132-
main_core::update::get_all_sequence_idx_map<MainModelType>(
131+
all_scenarios_sequence_ =
132+
std::make_shared<typename ModelType::SequenceIdx>(main_core::update::get_all_sequence_idx_map<ModelType>(
133133
model_reference_.get().state(), update_data, 0, components_to_update_, update_independence_, false));
134134
}
135135

136136
void setup_impl(ConstDataset const& update_data, Idx scenario_idx) {
137-
current_scenario_sequence_cache_ = main_core::update::get_all_sequence_idx_map<MainModelType>(
137+
current_scenario_sequence_cache_ = main_core::update::get_all_sequence_idx_map<ModelType>(
138138
model_reference_.get().state(), update_data, scenario_idx, components_to_update_, update_independence_,
139139
true);
140140
auto const current_scenario_sequence = get_current_scenario_sequence_view_();
@@ -148,8 +148,8 @@ template <class MainModel> class JobAdapter : public JobInterface<JobAdapter<Mai
148148
}
149149

150150
auto get_current_scenario_sequence_view_() const {
151-
return MainModelType::run_functor_with_all_component_types_return_array([this]<typename CT>() {
152-
constexpr auto comp_idx = MainModelType::template index_of_component<CT>;
151+
return ModelType::run_functor_with_all_component_types_return_array([this]<typename CT>() {
152+
constexpr auto comp_idx = ModelType::template index_of_component<CT>;
153153
if (std::get<comp_idx>(independence_flags_)) {
154154
return std::span<Idx2D const>{std::get<comp_idx>(*all_scenarios_sequence_)};
155155
}

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/core_utils.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ struct MainModelType<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLi
133133
using SequenceIdxView = std::array<std::span<Idx2D const>, n_types>;
134134
using UpdateIndependence = std::array<UpdateCompProperties, n_types>;
135135
using SequenceIdx = std::array<std::vector<Idx2D>, n_types>;
136+
using SequenceIdxRefWrappers = std::array<std::reference_wrapper<std::vector<Idx2D> const>, n_types>;
136137
using ComponentFlags = std::array<bool, n_types>;
137138

138139
// Clean these 2. They are unused

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,25 +207,25 @@ constexpr void register_connections_components(ComponentContainer const& compone
207207

208208
} // namespace detail
209209

210-
template <typename MainModelType>
211-
requires common::component_container_c<typename MainModelType::ComponentContainer, Branch, Branch3, Source, Shunt,
210+
template <typename ModelType>
211+
requires common::component_container_c<typename ModelType::ComponentContainer, Branch, Branch3, Source, Shunt,
212212
GenericLoadGen, GenericVoltageSensor, GenericPowerSensor,
213213
GenericCurrentSensor, Regulator>
214-
ComponentTopology construct_topology(typename MainModelType::ComponentContainer const& components) {
214+
ComponentTopology construct_topology(typename ModelType::ComponentContainer const& components) {
215215
ComponentTopology comp_topo;
216-
using TopologyTypesTuple = typename MainModelType::TopologyTypesTuple;
216+
using TopologyTypesTuple = typename ModelType::TopologyTypesTuple;
217217
main_core::utils::run_functor_with_tuple_return_void<TopologyTypesTuple>(
218218
[&components, &comp_topo]<typename CompType>() {
219219
detail::register_topology_components<CompType>(components, comp_topo);
220220
});
221221
return comp_topo;
222222
}
223223

224-
template <typename MainModelType>
225-
requires common::component_container_c<typename MainModelType::ComponentContainer, Branch, Branch3, Source>
226-
ComponentConnections construct_components_connections(typename MainModelType::ComponentContainer const& components) {
224+
template <typename ModelType>
225+
requires common::component_container_c<typename ModelType::ComponentContainer, Branch, Branch3, Source>
226+
ComponentConnections construct_components_connections(typename ModelType::ComponentContainer const& components) {
227227
ComponentConnections comp_conn;
228-
using TopologyConnectionTypesTuple = typename MainModelType::TopologyConnectionTypesTuple;
228+
using TopologyConnectionTypesTuple = typename ModelType::TopologyConnectionTypesTuple;
229229
main_core::utils::run_functor_with_tuple_return_void<TopologyConnectionTypesTuple>(
230230
[&components, &comp_conn]<typename CompType>() {
231231
detail::register_connections_components<CompType>(components, comp_conn);

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

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,13 @@ inline void validate_update_data_independence(UpdateCompProperties const& comp,
123123
}
124124
}
125125

126-
template <typename MainModelType>
127-
typename MainModelType::UpdateIndependence
128-
check_update_independence(typename MainModelType::MainModelState const& state, ConstDataset const& update_data) {
129-
return MainModelType::run_functor_with_all_component_types_return_array(
130-
[&state, &update_data]<typename CompType>() {
131-
auto const n_component = state.components.template size<CompType>();
132-
return check_component_independence<CompType>(update_data, n_component);
133-
});
126+
template <typename ModelType>
127+
typename ModelType::UpdateIndependence check_update_independence(typename ModelType::MainModelState const& state,
128+
ConstDataset const& update_data) {
129+
return ModelType::run_functor_with_all_component_types_return_array([&state, &update_data]<typename CompType>() {
130+
auto const n_component = state.components.template size<CompType>();
131+
return check_component_independence<CompType>(update_data, n_component);
132+
});
134133
}
135134

136135
} // namespace independence
@@ -187,22 +186,21 @@ std::vector<Idx2D> get_component_sequence(MainModelState<ComponentContainer> con
187186
}
188187
} // namespace detail
189188

190-
template <class MainModelType>
191-
typename MainModelType::SequenceIdx
192-
get_all_sequence_idx_map(typename MainModelType::MainModelState const& state, ConstDataset const& update_data,
193-
Idx scenario_idx, typename MainModelType::ComponentFlags const& components_to_store,
194-
typename MainModelType::UpdateIndependence const& independence, bool cached) {
195-
return MainModelType::run_functor_with_all_component_types_return_array(
189+
template <class ModelType>
190+
typename ModelType::SequenceIdx
191+
get_all_sequence_idx_map(typename ModelType::MainModelState const& state, ConstDataset const& update_data,
192+
Idx scenario_idx, typename ModelType::ComponentFlags const& components_to_store,
193+
typename ModelType::UpdateIndependence const& independence, bool cached) {
194+
return ModelType::run_functor_with_all_component_types_return_array(
196195
[&state, &update_data, scenario_idx, &components_to_store, &independence, cached]<typename CompType>() {
197-
auto const component_properties =
198-
std::get<MainModelType::template index_of_component<CompType>>(independence);
196+
auto const component_properties = std::get<ModelType::template index_of_component<CompType>>(independence);
199197
// The sequence for the independent components is cached (true). For the remaining components, the sequence
200198
// cannot be cached (false), so the independence flags are inverted to not return an empty sequence when
201199
// this is the case.
202200

203201
if (bool const component_independence = cached != component_properties.is_independent();
204202
!component_independence ||
205-
!std::get<MainModelType::template index_of_component<CompType>>(components_to_store)) {
203+
!std::get<ModelType::template index_of_component<CompType>>(components_to_store)) {
206204
return std::vector<Idx2D>{};
207205
}
208206
independence::validate_update_data_independence(component_properties, CompType::name);

0 commit comments

Comments
 (0)