19 #ifndef WELLTEST_STATE_H
20 #define WELLTEST_STATE_H
25 #include <unordered_map>
27 #include <opm/io/eclipse/rst/state.hpp>
29 #include <opm/input/eclipse/Schedule/Well/WellTestConfig.hpp>
30 #include <opm/input/eclipse/Schedule/Well/Well.hpp>
36 template<
class BufferType,
class M>
37 void pack_map(BufferType& buffer,
const M& m) {
38 buffer.write(m.size());
39 for (
const auto& [k,v] : m) {
45 template<
class BufferType,
class M>
46 void unpack_map(BufferType& buffer, M& m) {
47 typename M::size_type size;
49 for (std::size_t i = 0; i < size; i++) {
50 typename M::key_type k;
51 typename M::mapped_type v;
54 m.emplace(std::move(k), std::move(v));
83 RestartWell(
const std::string& wname,
double ti,
int num,
double st,
int r1,
int r2)
95 WellTestConfig::Reason reason;
100 std::optional<int> wtest_report_step;
103 WTestWell(
const std::string& wname, WellTestConfig::Reason reason_,
double last_test);
105 int int_reason()
const;
106 static WellTestConfig::Reason inverse_ecl_reason(
int ecl_reason);
108 bool operator==(
const WTestWell& other)
const {
109 return this->name == other.name &&
110 this->reason == other.reason &&
111 this->last_test == other.last_test &&
112 this->num_attempt == other.num_attempt &&
113 this->closed == other.closed &&
114 this->wtest_report_step == other.wtest_report_step;
119 template<
class Serializer>
122 serializer(this->name);
123 serializer(this->reason);
124 serializer(this->last_test);
125 serializer(this->num_attempt);
126 serializer(this->closed);
127 serializer(this->wtest_report_step);
130 template<
class BufferType>
131 void pack(BufferType& buffer)
const {
132 buffer.write(this->name);
133 buffer.write(this->reason);
134 buffer.write(this->last_test);
135 buffer.write(this->num_attempt);
136 buffer.write(this->closed);
137 buffer.write(this->wtest_report_step);
140 template<
class BufferType>
141 void unpack(BufferType& buffer) {
142 buffer.read(this->name);
143 buffer.read(this->reason);
144 buffer.read(this->last_test);
145 buffer.read(this->num_attempt);
146 buffer.read(this->closed);
147 buffer.read(this->wtest_report_step);
153 std::string wellName;
159 return this->wellName == other.wellName &&
160 this->complnum == other.complnum &&
161 this->last_test == other.last_test &&
162 this->num_attempt == other.num_attempt;
167 template<
class Serializer>
170 serializer(this->wellName);
171 serializer(this->complnum);
172 serializer(this->last_test);
173 serializer(this->num_attempt);
176 template<
class BufferType>
177 void pack(BufferType& buffer)
const {
178 buffer.write(this->wellName);
179 buffer.write(this->complnum);
180 buffer.write(this->last_test);
181 buffer.write(this->num_attempt);
184 template<
class BufferType>
185 void unpack(BufferType& buffer) {
186 buffer.read(this->wellName);
187 buffer.read(this->complnum);
188 buffer.read(this->last_test);
189 buffer.read(this->num_attempt);
197 std::vector<std::string> test_wells(
const WellTestConfig& config,
double sim_time);
198 void filter_wells(
const std::vector<std::string>& existing_wells);
215 void close_well(
const std::string& well_name, WellTestConfig::Reason reason,
double sim_time);
216 bool well_is_closed(
const std::string& well_name)
const;
217 void open_well(
const std::string& well_name);
218 std::size_t num_closed_wells()
const;
219 double lastTestTime(
const std::string& well_name)
const;
221 void close_completion(
const std::string& well_name,
int complnum,
double sim_time);
222 void open_completion(
const std::string& well_name,
int complnum);
223 void open_completions(
const std::string& well_name);
224 bool completion_is_closed(
const std::string& well_name,
const int complnum)
const;
225 std::size_t num_closed_completions()
const;
230 template<
class BufferType>
231 void pack(BufferType& buffer)
const {
232 pack_map(buffer, this->wells);
234 buffer.write(this->completions.size());
235 for (
const auto& [well, cmap] : this->completions) {
237 pack_map(buffer, cmap);
241 template<
class BufferType>
242 void unpack(BufferType& buffer) {
243 unpack_map(buffer, this->wells);
246 for (std::size_t i = 0; i < size; i++) {
248 std::unordered_map<int, ClosedCompletion> cmap;
251 unpack_map(buffer, cmap);
252 this->completions.emplace(std::move(well), std::move(cmap));
256 template<
class Serializer>
257 void serializeOp(Serializer& serializer)
259 serializer.map(this->wells);
260 if (serializer.isSerializing()) {
261 std::size_t size = this->completions.size();
263 for (
auto& [well, comp_map] : this->completions) {
265 serializer.map(comp_map);
270 for (std::size_t i=0; i < size; i++) {
272 std::unordered_map<int, ClosedCompletion> comp_map;
275 serializer.map(comp_map);
276 this->completions.emplace(well, std::move(comp_map));
282 static WellTestState serializeObject();
283 bool operator==(
const WellTestState& other)
const;
285 std::optional<WellTestState::RestartWell> restart_well(
const Opm::WellTestConfig& config,
const std::string& wname)
const;
288 std::unordered_map<std::string, WTestWell> wells;
289 std::unordered_map<std::string, std::unordered_map<int, ClosedCompletion>> completions;
291 std::vector<std::pair<std::string, int>> updateCompletion(
const WellTestConfig& config,
double sim_time);
Definition: Serializer.hpp:38
Definition: WellTestConfig.hpp:56
Definition: WellTestState.hpp:62
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: WellTestState.hpp:152
Definition: WellTestState.hpp:74
Definition: WellTestState.hpp:93