120 template <
typename T>
123 const T& get()
const {
124 return *this->m_data;
131 void update(T
object)
133 this->m_data = std::make_shared<T>( std::move(
object) );
142 this->m_data = other.m_data;
145 const T& operator()()
const {
146 return *this->m_data;
149 template<
class Serializer>
156 std::shared_ptr<T> m_data;
171 template <
typename K,
typename T>
174 std::vector<K> keys()
const {
175 std::vector<K> key_vector;
176 std::transform( this->m_data.begin(), this->m_data.end(), std::back_inserter(key_vector), [](
const auto& pair) { return pair.first; });
181 template <
typename Predicate>
182 const T* find(Predicate&& predicate)
const {
183 auto iter = std::find_if( this->m_data.begin(), this->m_data.end(), std::forward<Predicate>(predicate));
184 if (iter == this->m_data.end())
187 return iter->second.get();
191 const std::shared_ptr<T> get_ptr(
const K& key)
const {
192 auto iter = this->m_data.find(key);
193 if (iter != this->m_data.end())
200 bool has(
const K& key)
const {
201 auto ptr = this->get_ptr(key);
202 return (ptr !=
nullptr);
205 void update(
const K& key, std::shared_ptr<T> value) {
206 this->m_data.insert_or_assign(key, std::move(value));
209 void update(T
object) {
210 auto key =
object.name();
211 this->m_data[key] = std::make_shared<T>( std::move(
object) );
215 auto other_ptr = other.get_ptr(key);
217 this->m_data[key] = other.get_ptr(key);
219 throw std::logic_error(std::string{
"Tried to update member: "} + as_string(key) + std::string{
"with uninitialized object"});
222 const T& operator()(
const K& key)
const {
223 return this->get(key);
226 const T& get(
const K& key)
const {
227 return *this->m_data.at(key);
230 T& get(
const K& key) {
231 return *this->m_data.at(key);
235 std::vector<std::reference_wrapper<const T>> operator()()
const {
236 std::vector<std::reference_wrapper<const T>> as_vector;
237 for (
const auto& [_, elm_ptr] : this->m_data) {
239 as_vector.push_back( std::cref(*elm_ptr));
245 std::vector<std::reference_wrapper<T>> operator()() {
246 std::vector<std::reference_wrapper<T>> as_vector;
247 for (
const auto& [_, elm_ptr] : this->m_data) {
249 as_vector.push_back( std::ref(*elm_ptr));
256 if (this->m_data.size() != other.m_data.size())
259 for (
const auto& [key1, ptr1] : this->m_data) {
260 const auto& ptr2 = other.get_ptr(key1);
264 if (!(*ptr1 == *ptr2))
271 std::size_t size()
const {
272 return this->m_data.size();
275 typename std::unordered_map<K, std::shared_ptr<T>>::const_iterator begin()
const {
276 return this->m_data.begin();
279 typename std::unordered_map<K, std::shared_ptr<T>>::const_iterator end()
const {
280 return this->m_data.end();
286 T value_object = T::serializationTestObject();
287 K key = value_object.name();
288 map_object.m_data.emplace( key, std::make_shared<T>( std::move(value_object) ));
292 template<
class Serializer>
299 std::unordered_map<K, std::shared_ptr<T>> m_data;
303 std::optional<double> prod_target;
304 std::optional<double> inj_limit;
313 return this->prod_target == rhs.prod_target
314 && this->inj_limit == rhs.inj_limit;
317 template<
class Serializer>
320 serializer(prod_target);
321 serializer(inj_limit);
327 ScheduleState(
const time_point& start_time,
const time_point& end_time);
332 time_point start_time()
const;
333 time_point end_time()
const;
339 std::size_t sim_step()
const;
343 std::size_t month_num()
const;
344 std::size_t year_num()
const;
345 bool first_in_month()
const;
346 bool first_in_year()
const;
351 void update_tuning(
Tuning tuning);
353 const Tuning& tuning()
const;
354 double max_next_tstep(
const bool enableTUNING =
false)
const;
356 void init_nupcol(
Nupcol nupcol);
357 void update_nupcol(
int nupcol);
364 void update_events(
Events events);
366 const Events& events()
const;
372 void update_geo_keywords(std::vector<DeckKeyword> geo_keywords);
373 std::vector<DeckKeyword>& geo_keywords();
374 const std::vector<DeckKeyword>& geo_keywords()
const;
380 WellProducerCMode whistctl()
const;
381 void update_whistctl(WellProducerCMode whistctl);
383 bool rst_file(
const RSTConfig& rst_config,
const time_point& previous_restart_output_time)
const;
384 void update_date(
const time_point& prev_time);
385 void updateSAVE(
bool save);
388 const std::optional<double>& sumthin()
const;
389 void update_sumthin(
double sumthin);
391 bool rptonly()
const;
392 void rptonly(
const bool only);
394 bool has_gpmaint()
const;
396 bool hasAnalyticalAquifers()
const
398 return ! this->aqufluxs.empty();
403 ptr_member<GConSale> gconsale;
404 ptr_member<GConSump> gconsump;
405 ptr_member<GSatProd> gsatprod;
406 ptr_member<GroupEconProductionLimits> gecon;
407 ptr_member<GuideRateConfig> guide_rate;
409 ptr_member<WListManager> wlist_manager;
410 ptr_member<NameOrder> well_order;
411 ptr_member<GroupOrder> group_order;
413 ptr_member<Action::Actions> actions;
414 ptr_member<UDQConfig> udq;
415 ptr_member<UDQActive> udq_active;
417 ptr_member<PAvg> pavg;
418 ptr_member<WellTestConfig> wtest_config;
419 ptr_member<GasLiftOpt> glo;
420 ptr_member<Network::ExtNetwork> network;
421 ptr_member<Network::Balance> network_balance;
422 ptr_member<ReservoirCoupling::CouplingInfo> rescoup;
424 ptr_member<RPTConfig> rpt_config;
425 ptr_member<RFTConfig> rft_config;
426 ptr_member<RSTConfig> rst_config;
428 ptr_member<BHPDefaults> bhp_defaults;
429 ptr_member<Source> source;
430 ptr_member<WCYCLE> wcycle;
432 template <
typename T>
433 ptr_member<T>& get() {
434 return const_cast<ptr_member<T>&
>(std::as_const(*this).template get<T>());
437 template <
typename T>
438 const ptr_member<T>& get()
const
440 struct always_false1 : std::false_type {};
442 if constexpr ( std::is_same_v<T, PAvg> )
444 else if constexpr ( std::is_same_v<T, WellTestConfig> )
445 return this->wtest_config;
446 else if constexpr ( std::is_same_v<T, GConSale> )
447 return this->gconsale;
448 else if constexpr ( std::is_same_v<T, GConSump> )
449 return this->gconsump;
450 else if constexpr ( std::is_same_v<T, GSatProd> )
451 return this->gsatprod;
452 else if constexpr ( std::is_same_v<T, GroupEconProductionLimits> )
454 else if constexpr ( std::is_same_v<T, WListManager> )
455 return this->wlist_manager;
456 else if constexpr ( std::is_same_v<T, Network::ExtNetwork> )
457 return this->network;
458 else if constexpr ( std::is_same_v<T, Network::Balance> )
459 return this->network_balance;
460 else if constexpr ( std::is_same_v<T, ReservoirCoupling::CouplingInfo> )
461 return this->rescoup;
462 else if constexpr ( std::is_same_v<T, RPTConfig> )
463 return this->rpt_config;
464 else if constexpr ( std::is_same_v<T, Action::Actions> )
465 return this->actions;
466 else if constexpr ( std::is_same_v<T, UDQActive> )
467 return this->udq_active;
468 else if constexpr ( std::is_same_v<T, NameOrder> )
469 return this->well_order;
470 else if constexpr ( std::is_same_v<T, GroupOrder> )
471 return this->group_order;
472 else if constexpr ( std::is_same_v<T, UDQConfig> )
474 else if constexpr ( std::is_same_v<T, GasLiftOpt> )
476 else if constexpr ( std::is_same_v<T, GuideRateConfig> )
477 return this->guide_rate;
478 else if constexpr ( std::is_same_v<T, RFTConfig> )
479 return this->rft_config;
480 else if constexpr ( std::is_same_v<T, RSTConfig> )
481 return this->rst_config;
482 else if constexpr ( std::is_same_v<T, BHPDefaults> )
483 return this->bhp_defaults;
484 else if constexpr ( std::is_same_v<T, Source> )
486 else if constexpr ( std::is_same_v<T, WCYCLE> )
489 #if !OPM_IS_COMPILING_WITH_GPU_COMPILER
490 static_assert(always_false1::value,
"Template type <T> not supported in get()");
496 template <
typename K,
typename T>
497 map_member<K,T>& get_map()
499 struct always_false2 : std::false_type {};
500 if constexpr ( std::is_same_v<T, VFPProdTable> )
501 return this->vfpprod;
502 else if constexpr ( std::is_same_v<T, VFPInjTable> )
504 else if constexpr ( std::is_same_v<T, Group> )
506 else if constexpr ( std::is_same_v<T, Well> )
509 #if !OPM_IS_COMPILING_WITH_GPU_COMPILER
510 static_assert(always_false2::value,
"Template type <K,T> not supported in get_map()");
515 map_member<int, VFPProdTable> vfpprod;
516 map_member<int, VFPInjTable> vfpinj;
517 map_member<std::string, Group> groups;
518 map_member<std::string, Well> wells;
520 std::unordered_map<int, SingleAquiferFlux> aqufluxs;
523 map_member<std::string, std::vector<double>> inj_streams;
525 std::unordered_map<std::string, double> target_wellpi;
526 std::optional<NextStep> next_tstep;
529 using WellPIMapType = std::unordered_map<std::string, double>;
530 template<
class Serializer>
531 void serializeOp(Serializer& serializer)
533 serializer(gconsale);
534 serializer(gconsump);
535 serializer(gsatprod);
537 serializer(guide_rate);
538 serializer(wlist_manager);
539 serializer(well_order);
540 serializer(group_order);
543 serializer(udq_active);
545 serializer(wtest_config);
548 serializer(network_balance);
550 serializer(rpt_config);
551 serializer(rft_config);
552 serializer(rst_config);
553 serializer(bhp_defaults);
560 serializer(aqufluxs);
562 serializer(inj_streams);
563 serializer(target_wellpi);
564 serializer(this->next_tstep);
565 serializer(m_start_time);
566 serializer(m_end_time);
567 serializer(m_sim_step);
568 serializer(m_month_num);
569 serializer(m_year_num);
570 serializer(m_first_in_year);
571 serializer(m_first_in_month);
572 serializer(m_save_step);
573 serializer(m_tuning);
574 serializer(m_nupcol);
575 serializer(m_oilvap);
576 serializer(m_events);
577 serializer(m_wellgroup_events);
578 serializer(m_geo_keywords);
579 serializer(m_message_limits);
580 serializer(m_whistctl_mode);
581 serializer(m_sumthin);
582 serializer(this->m_rptonly);
586 time_point m_start_time{};
587 std::optional<time_point> m_end_time{};
589 std::size_t m_sim_step = 0;
590 std::size_t m_month_num = 0;
591 std::size_t m_year_num = 0;
592 bool m_first_in_month{
false};
593 bool m_first_in_year{
false};
594 bool m_save_step{
false};
598 OilVaporizationProperties m_oilvap{};
600 WellGroupEvents m_wellgroup_events{};
601 std::vector<DeckKeyword> m_geo_keywords{};
602 MessageLimits m_message_limits{};
603 WellProducerCMode m_whistctl_mode = WellProducerCMode::CMODE_UNDEFINED;
604 std::optional<double> m_sumthin{};
605 bool m_rptonly{
false};