113 template <
typename T>
116 const T& get()
const {
117 return *this->m_data;
124 void update(T
object)
126 this->m_data = std::make_shared<T>( std::move(
object) );
135 this->m_data = other.m_data;
138 const T& operator()()
const {
139 return *this->m_data;
143 std::shared_ptr<T> m_data;
158 template <
typename K,
typename T>
161 std::vector<K> keys()
const {
162 std::vector<K> key_vector;
163 std::transform( this->m_data.begin(), this->m_data.end(), std::back_inserter(key_vector), [](
const auto& pair) { return pair.first; });
168 template <
typename Predicate>
169 const T* find(Predicate&& predicate)
const {
170 auto iter = std::find_if( this->m_data.begin(), this->m_data.end(), std::forward<Predicate>(predicate));
171 if (iter == this->m_data.end())
174 return iter->second.get();
178 const std::shared_ptr<T> get_ptr(
const K& key)
const {
179 auto iter = this->m_data.find(key);
180 if (iter != this->m_data.end())
187 bool has(
const K& key)
const {
188 auto ptr = this->get_ptr(key);
189 return (ptr !=
nullptr);
193 void update(T
object) {
194 auto key =
object.name();
195 this->m_data[key] = std::make_shared<T>( std::move(
object) );
199 auto other_ptr = other.get_ptr(key);
201 this->m_data[key] = other.get_ptr(key);
203 throw std::logic_error(std::string{
"Tried to update member: "} + as_string(key) + std::string{
"with uninitialized object"});
206 const T& operator()(
const K& key)
const {
207 return this->get(key);
210 const T& get(
const K& key)
const {
211 return *this->m_data.at(key);
214 T& get(
const K& key) {
215 return *this->m_data.at(key);
219 std::vector<std::reference_wrapper<const T>> operator()()
const {
220 std::vector<std::reference_wrapper<const T>> as_vector;
221 for (
const auto& [_, elm_ptr] : this->m_data) {
223 as_vector.push_back( std::cref(*elm_ptr));
229 std::vector<std::reference_wrapper<T>> operator()() {
230 std::vector<std::reference_wrapper<T>> as_vector;
231 for (
const auto& [_, elm_ptr] : this->m_data) {
233 as_vector.push_back( std::ref(*elm_ptr));
240 if (this->m_data.size() != other.m_data.size())
243 for (
const auto& [key1, ptr1] : this->m_data) {
244 const auto& ptr2 = other.get_ptr(key1);
248 if (!(*ptr1 == *ptr2))
255 std::size_t size()
const {
256 return this->m_data.size();
259 typename std::unordered_map<K, std::shared_ptr<T>>::const_iterator begin()
const {
260 return this->m_data.begin();
263 typename std::unordered_map<K, std::shared_ptr<T>>::const_iterator end()
const {
264 return this->m_data.end();
270 T value_object = T::serializationTestObject();
271 K key = value_object.name();
272 map_object.m_data.emplace( key, std::make_shared<T>( std::move(value_object) ));
278 std::unordered_map<K, std::shared_ptr<T>> m_data;
285 ScheduleState(
const time_point& start_time,
const time_point& end_time);
290 time_point start_time()
const;
291 time_point end_time()
const;
297 std::size_t sim_step()
const;
301 std::size_t month_num()
const;
302 std::size_t year_num()
const;
303 bool first_in_month()
const;
304 bool first_in_year()
const;
309 void update_tuning(
Tuning tuning);
311 const Tuning& tuning()
const;
312 double max_next_tstep()
const;
314 void init_nupcol(
Nupcol nupcol);
315 void update_nupcol(
int nupcol);
322 void update_events(
Events events);
324 const Events& events()
const;
330 void update_geo_keywords(std::vector<DeckKeyword> geo_keywords);
331 std::vector<DeckKeyword>& geo_keywords();
332 const std::vector<DeckKeyword>& geo_keywords()
const;
338 WellProducerCMode whistctl()
const;
339 void update_whistctl(WellProducerCMode whistctl);
341 bool rst_file(
const RSTConfig& rst_config,
const time_point& previous_restart_output_time)
const;
342 void update_date(
const time_point& prev_time);
343 void updateSAVE(
bool save);
346 const std::optional<double>& sumthin()
const;
347 void update_sumthin(
double sumthin);
349 bool rptonly()
const;
350 void rptonly(
const bool only);
352 bool has_gpmaint()
const;
354 bool hasAnalyticalAquifers()
const
356 return ! this->aqufluxs.empty();
361 ptr_member<GConSale> gconsale;
362 ptr_member<GConSump> gconsump;
363 ptr_member<GroupEconProductionLimits> gecon;
364 ptr_member<GuideRateConfig> guide_rate;
366 ptr_member<WListManager> wlist_manager;
367 ptr_member<NameOrder> well_order;
368 ptr_member<GroupOrder> group_order;
370 ptr_member<Action::Actions> actions;
371 ptr_member<UDQConfig> udq;
372 ptr_member<UDQActive> udq_active;
374 ptr_member<PAvg> pavg;
375 ptr_member<WellTestConfig> wtest_config;
376 ptr_member<GasLiftOpt> glo;
377 ptr_member<Network::ExtNetwork> network;
378 ptr_member<Network::Balance> network_balance;
380 ptr_member<RPTConfig> rpt_config;
381 ptr_member<RFTConfig> rft_config;
382 ptr_member<RSTConfig> rst_config;
386 template <
typename T>
388 if constexpr ( std::is_same_v<T, PAvg> )
390 else if constexpr ( std::is_same_v<T, WellTestConfig> )
391 return this->wtest_config;
392 else if constexpr ( std::is_same_v<T, GConSale> )
393 return this->gconsale;
394 else if constexpr ( std::is_same_v<T, GConSump> )
395 return this->gconsump;
396 else if constexpr ( std::is_same_v<T, GroupEconProductionLimits> )
398 else if constexpr ( std::is_same_v<T, WListManager> )
399 return this->wlist_manager;
400 else if constexpr ( std::is_same_v<T, Network::ExtNetwork> )
401 return this->network;
402 else if constexpr ( std::is_same_v<T, Network::Balance> )
403 return this->network_balance;
404 else if constexpr ( std::is_same_v<T, RPTConfig> )
405 return this->rpt_config;
406 else if constexpr ( std::is_same_v<T, Action::Actions> )
407 return this->actions;
408 else if constexpr ( std::is_same_v<T, UDQActive> )
409 return this->udq_active;
410 else if constexpr ( std::is_same_v<T, NameOrder> )
411 return this->well_order;
412 else if constexpr ( std::is_same_v<T, GroupOrder> )
413 return this->group_order;
414 else if constexpr ( std::is_same_v<T, UDQConfig> )
416 else if constexpr ( std::is_same_v<T, GasLiftOpt> )
418 else if constexpr ( std::is_same_v<T, GuideRateConfig> )
419 return this->guide_rate;
420 else if constexpr ( std::is_same_v<T, RFTConfig> )
421 return this->rft_config;
422 else if constexpr ( std::is_same_v<T, RSTConfig> )
423 return this->rst_config;
428 template <
typename T>
429 const ptr_member<T>& get()
const {
430 if constexpr ( std::is_same_v<T, PAvg> )
432 else if constexpr ( std::is_same_v<T, WellTestConfig> )
433 return this->wtest_config;
434 else if constexpr ( std::is_same_v<T, GConSale> )
435 return this->gconsale;
436 else if constexpr ( std::is_same_v<T, GConSump> )
437 return this->gconsump;
438 else if constexpr ( std::is_same_v<T, GroupEconProductionLimits> )
440 else if constexpr ( std::is_same_v<T, WListManager> )
441 return this->wlist_manager;
442 else if constexpr ( std::is_same_v<T, Network::ExtNetwork> )
443 return this->network;
444 else if constexpr ( std::is_same_v<T, Network::Balance> )
445 return this->network_balance;
446 else if constexpr ( std::is_same_v<T, RPTConfig> )
447 return this->rpt_config;
448 else if constexpr ( std::is_same_v<T, Action::Actions> )
449 return this->actions;
450 else if constexpr ( std::is_same_v<T, UDQActive> )
451 return this->udq_active;
452 else if constexpr ( std::is_same_v<T, NameOrder> )
453 return this->well_order;
454 else if constexpr ( std::is_same_v<T, GroupOrder> )
455 return this->group_order;
456 else if constexpr ( std::is_same_v<T, UDQConfig> )
458 else if constexpr ( std::is_same_v<T, GasLiftOpt> )
460 else if constexpr ( std::is_same_v<T, GuideRateConfig> )
461 return this->guide_rate;
462 else if constexpr ( std::is_same_v<T, RFTConfig> )
463 return this->rft_config;
464 else if constexpr ( std::is_same_v<T, RSTConfig> )
465 return this->rst_config;
467 static_assert(always_false1<T>::value,
"Template type <T> not supported in get()");
471 template <
typename K,
typename T>
struct always_false2 : std::false_type {};
472 template <
typename K,
typename T>
474 if constexpr ( std::is_same_v<T, VFPProdTable> )
475 return this->vfpprod;
476 else if constexpr ( std::is_same_v<T, VFPInjTable> )
478 else if constexpr ( std::is_same_v<T, Group> )
480 else if constexpr ( std::is_same_v<T, Well> )
486 map_member<int, VFPProdTable> vfpprod;
487 map_member<int, VFPInjTable> vfpinj;
488 map_member<std::string, Group> groups;
489 map_member<std::string, Well> wells;
491 std::unordered_map<int, SingleAquiferFlux> aqufluxs;
493 std::unordered_map<std::string, double> target_wellpi;
494 std::optional<NextStep> next_tstep;
497 using WellPIMapType = std::unordered_map<std::string, double>;
498 template<
class Serializer>
500 serializer(m_start_time);
501 serializer(m_end_time);
502 serializer(m_sim_step);
503 serializer(m_month_num);
504 serializer(m_year_num);
505 serializer(m_first_in_year);
506 serializer(m_first_in_month);
507 serializer(m_save_step);
508 serializer(m_sumthin);
509 serializer(this->m_rptonly);
510 serializer(this->next_tstep);
511 serializer(m_tuning);
512 serializer(m_nupcol);
513 serializer(m_oilvap);
514 serializer(m_events);
515 serializer(m_wellgroup_events);
516 serializer(m_geo_keywords);
517 serializer(m_message_limits);
518 serializer(m_whistctl_mode);
519 serializer(target_wellpi);
520 serializer(aqufluxs);
526 time_point m_start_time;
527 std::optional<time_point> m_end_time;
529 std::size_t m_sim_step = 0;
530 std::size_t m_month_num = 0;
531 std::size_t m_year_num = 0;
532 bool m_first_in_month;
533 bool m_first_in_year;
534 bool m_save_step{
false};
538 OilVaporizationProperties m_oilvap;
540 WellGroupEvents m_wellgroup_events;
541 std::vector<DeckKeyword> m_geo_keywords;
542 MessageLimits m_message_limits;
543 WellProducerCMode m_whistctl_mode = WellProducerCMode::CMODE_UNDEFINED;
544 std::optional<double> m_sumthin;
545 bool m_rptonly{
false};