My Project
WellTestConfig.hpp
1/*
2 Copyright 2018 Statoil 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 WELLTEST_CONFIG_H
20#define WELLTEST_CONFIG_H
21
22#include <cstddef>
23#include <string>
24#include <unordered_map>
25
26
27namespace Opm {
28
29namespace RestartIO {
30struct RstState;
31}
32
33namespace WTest {
34/*
35 Different numerical values are used in the restart file to enumarate the
36 possible WTEST modes and the actual reason a well has been closed.
37*/
38
39namespace EclConfigReason {
40constexpr int PHYSICAL = 2;
41constexpr int ECONOMIC = 3;
42constexpr int GCON = 5;
43constexpr int THPLimit = 7;
44constexpr int CONNECTION = 11;
45}
46
47namespace EclCloseReason {
48constexpr int PHYSICAL = 3;
49constexpr int ECONOMIC = 5;
50constexpr int GCON = 6;
51constexpr int THPLimit = 9;
52}
53
54}
55
57
58public:
59 enum class Reason {
60 PHYSICAL = 1,
61 ECONOMIC = 2,
62 GROUP = 4,
63 THP_DESIGN=8,
64 COMPLETION=16,
65 };
66
67 struct WTESTWell {
68 std::string name;
69 int reasons;
70 double test_interval;
71 int num_test;
72 double startup_time;
73 // the related WTEST keywords is entered and will begin
74 // taking effects since this report step
75 int begin_report_step;
76
77 bool operator==(const WTESTWell& data) const {
78 return name == data.name &&
79 reasons == data.reasons &&
80 test_interval == data.test_interval &&
81 num_test == data.num_test &&
82 startup_time == data.startup_time &&
83 begin_report_step == data.begin_report_step;
84 }
85
86 WTESTWell() = default;
87 WTESTWell(const std::string& name, int reasons, double test_interval, int num_test, double startup_time, int begin_report_step);
88 bool test_well(int num_attempt, double elapsed) const;
89
90 static int inverse_ecl_reasons(int ecl_reasons);
91 static WTESTWell serializationTestObject();
92 int ecl_reasons() const;
93
94 template<class Serializer>
95 void serializeOp(Serializer& serializer)
96 {
97 serializer(name);
98 serializer(reasons);
99 serializer(test_interval);
100 serializer(num_test);
101 serializer(startup_time);
102 serializer(begin_report_step);
103 }
104 };
105
106 static WellTestConfig serializationTestObject();
107
108 WellTestConfig() = default;
109 WellTestConfig(const RestartIO::RstState& rst_state, int report_step);
110 void add_well(const std::string& well, int reasons, double test_interval,
111 int num_test, double startup_time, int current_step);
112 void add_well(const std::string& well, const std::string& reasons, double test_interval,
113 int num_test, double startup_time, int current_step);
114 void drop_well(const std::string& well);
115 bool has(const std::string& well) const;
116 bool has(const std::string& well, Reason reason) const;
117 const WTESTWell& get(const std::string& well) const;
118
119 static std::string reasonToString(const Reason reason);
120 bool empty() const;
121
122 bool operator==(const WellTestConfig& data) const;
123
124 template<class Serializer>
125 void serializeOp(Serializer& serializer)
126 {
127 serializer(wells);
128 }
129
130private:
131 std::unordered_map<std::string, WTESTWell> wells;
132};
133}
134
135#endif
136
Class for (de-)serializing.
Definition: Serializer.hpp:75
Definition: WellTestConfig.hpp:56
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: state.hpp:54
Definition: WellTestConfig.hpp:67