RFTConfig.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef RFT_CONFIG_HPP
20#define RFT_CONFIG_HPP
21
22#include <cstddef>
23#include <string>
24#include <unordered_map>
25#include <utility>
26
30
31namespace Opm {
32
33class RFTConfig {
34public:
35 enum class RFT {
36 YES = 1,
37 REPT = 2,
38 TIMESTEP = 3,
39 FOPN = 4,
40 NO = 5
41 };
42 static std::string RFT2String(RFT enumValue);
43 static RFT RFTFromString(const std::string &stringValue);
44
45 enum class PLT {
46 YES = 1,
47 REPT = 2,
48 TIMESTEP = 3,
49 NO = 4
50 };
51 static std::string PLT2String(PLT enumValue);
52 static PLT PLTFromString( const std::string& stringValue);
53
54 template <typename Value>
55 using ConfigMap = std::unordered_map<
57 >;
58
59 using WellOpenTimeMap = std::unordered_map<std::string, std::size_t>;
60
62 explicit RFTConfig(const TimeMap& time_map);
63
65
66 bool rft(const std::string& well, std::size_t report_step) const;
67 bool plt(const std::string& well, std::size_t report_step) const;
68 bool getWellOpenRFT(const std::string& well_name, std::size_t report_step) const;
69 void setWellOpenRFT(std::size_t report_step);
70 void setWellOpenRFT(const std::string& well_name);
71
72 bool active(std::size_t report_step) const;
73 std::size_t firstRFTOutput() const { return this->first_rft_event; }
74 void updateRFT(const std::string& well, std::size_t report_step, RFT value);
75 void updatePLT(const std::string& well, std::size_t report_step, PLT value);
76 void addWellOpen(const std::string& well, std::size_t report_step);
77
78 const TimeMap& timeMap() const;
79
80 bool operator==(const RFTConfig& data) const;
81
82 template<class Serializer>
83 void serializeOp(Serializer& serializer)
84 {
85 tm.serializeOp(serializer);
86 serializer(first_rft_event);
87 serializer(well_open_rft_time);
88 serializer(well_open_rft_name);
89 serializer(well_open);
90 serializer.template map<ConfigMap<RFT>,false>(rft_config);
91 serializer.template map<ConfigMap<PLT>,false>(plt_config);
92 }
93
94private:
95 TimeMap tm;
96 std::size_t first_rft_event;
97 std::pair<bool, std::size_t> well_open_rft_time;
98 WellOpenTimeMap well_open_rft_name;
99 WellOpenTimeMap well_open;
100 ConfigMap<RFT> rft_config;
101 ConfigMap<PLT> plt_config;
102
103 bool outputRftAtWellopen(WellOpenTimeMap::const_iterator well, const std::size_t report_step) const;
104 std::size_t firstWellopenStepNotBefore(const std::size_t report_step) const;
105 void updateFirstIfNotShut(const std::string& well_name, const std::size_t report_step);
106 void updateFirst(const std::size_t report_step);
107
108 void setWellOpenRFT(const std::string& well_name, const std::size_t report_step);
109
110 template <typename Value>
111 void updateConfig(const std::string& well_name,
112 const std::size_t report_step,
113 const Value value,
114 ConfigMap<Value>& cfgmap);
115};
116
117}
118
119#endif
const char *const string
Definition: cJSON.h:170
Definition: DynamicState.hpp:58
Definition: RFTConfig.hpp:33
void serializeOp(Serializer &serializer)
Definition: RFTConfig.hpp:83
bool active(std::size_t report_step) const
bool getWellOpenRFT(const std::string &well_name, std::size_t report_step) const
bool plt(const std::string &well, std::size_t report_step) const
PLT
Definition: RFTConfig.hpp:45
static std::string PLT2String(PLT enumValue)
std::unordered_map< std::string, DynamicState< std::pair< Value, std::size_t > > > ConfigMap
Definition: RFTConfig.hpp:57
void updateRFT(const std::string &well, std::size_t report_step, RFT value)
void setWellOpenRFT(const std::string &well_name)
const TimeMap & timeMap() const
void addWellOpen(const std::string &well, std::size_t report_step)
std::unordered_map< std::string, std::size_t > WellOpenTimeMap
Definition: RFTConfig.hpp:59
void updatePLT(const std::string &well, std::size_t report_step, PLT value)
static std::string RFT2String(RFT enumValue)
void setWellOpenRFT(std::size_t report_step)
static RFTConfig serializeObject()
bool operator==(const RFTConfig &data) const
static RFT RFTFromString(const std::string &stringValue)
static PLT PLTFromString(const std::string &stringValue)
RFTConfig(const TimeMap &time_map)
bool rft(const std::string &well, std::size_t report_step) const
std::size_t firstRFTOutput() const
Definition: RFTConfig.hpp:73
RFT
Definition: RFTConfig.hpp:35
Definition: Serializer.hpp:38
Definition: TimeMap.hpp:40
void serializeOp(Serializer &serializer)
Definition: TimeMap.hpp:81
Definition: Value.hpp:39
Definition: A.hpp:4
T value(details::expression_node< T > *n)
Definition: exprtk.hpp:12955
static std::string data()
Definition: exprtk.hpp:40022