My Project
Loading...
Searching...
No Matches
UDQActive.hpp
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
20#ifndef UDQ_USAGE_HPP
21#define UDQ_USAGE_HPP
22
23#include <opm/input/eclipse/EclipseState/Phase.hpp>
24
25#include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
26
27#include <opm/input/eclipse/Deck/UDAValue.hpp>
28
29#include <cstddef>
30#include <cstdlib>
31#include <optional>
32#include <string>
33#include <vector>
34
35namespace Opm {
36
37class UDQConfig;
38class UnitSystem;
39
40} // namespace Opm
41
42namespace Opm::RestartIO {
43 struct RstState;
44} // namespace Opm::RestartIO
45
46namespace Opm {
47
50{
51public:
53 struct RstRecord
54 {
67 RstRecord(const UDAControl control_arg,
68 const UDAValue value_arg,
69 const std::string& wgname_arg)
70 : control { control_arg }
71 , value { value_arg }
72 , wgname { wgname_arg }
73 {}
74
88 RstRecord(const UDAControl control_arg,
89 const UDAValue value_arg,
90 const std::string& wgname_arg,
91 const Phase phase)
92 : RstRecord { control_arg, value_arg, wgname_arg }
93 {
94 this->ig_phase = phase;
95 }
96
99 UDAControl control;
100
105
107 std::string wgname;
108
112 std::optional<Phase> ig_phase{};
113 };
114
121 {
122 public:
127 OutputRecord();
128
144 OutputRecord(const std::string& udq_arg,
145 const std::size_t input_index_arg,
146 const std::string& wgname_arg,
147 const UDAControl control_arg);
148
156 bool operator==(const OutputRecord& other) const;
157
165 bool operator!=(const OutputRecord& other) const
166 {
167 return ! (*this == other);
168 }
169
175 template<class Serializer>
176 void serializeOp(Serializer& serializer)
177 {
178 serializer(udq);
179 serializer(input_index);
180 serializer(wgname);
181 serializer(control);
182 serializer(uda_code);
183 serializer(use_count);
184 }
185
187 std::string udq;
188
191 std::size_t input_index;
192
195 UDAControl control;
196
198 int uda_code{};
199
203 const std::string& wg_name() const
204 {
205 return this->wgname;
206 }
207
211 std::size_t use_count{};
212
213 private:
217 std::string wgname{};
218 };
219
222 {
223 public:
228 InputRecord();
229
242 InputRecord(const std::size_t input_index_arg,
243 const std::string& udq_arg,
244 const std::string& wgname_arg,
245 const UDAControl control_arg);
246
254 bool operator==(const InputRecord& other) const;
255
261 template<class Serializer>
262 void serializeOp(Serializer& serializer)
263 {
264 serializer(input_index);
265 serializer(udq);
266 serializer(wgname);
267 serializer(control);
268 }
269
272 std::size_t input_index;
273
275 std::string udq;
276
278 std::string wgname;
279
282 UDAControl control;
283 };
284
287
293 UDQActive() = default;
294
307 static std::vector<RstRecord>
308 load_rst(const UnitSystem& units,
309 const UDQConfig& udq_config,
310 const RestartIO::RstState& rst_state,
311 const std::vector<std::string>& well_names,
312 const std::vector<std::string>& group_names);
313
336 int update(const UDQConfig& udq_config,
337 const UDAValue& uda,
338 const std::string& wgname,
339 const UDAControl control);
340
345 explicit operator bool() const;
346
351 const std::vector<OutputRecord>& iuad() const;
352
361 std::vector<InputRecord> iuap() const;
362
369 bool operator==(const UDQActive& data) const;
370
376 template<class Serializer>
377 void serializeOp(Serializer& serializer)
378 {
379 serializer(input_data);
380 serializer(output_data);
381 }
382
383private:
385 std::vector<InputRecord> input_data{};
386
394 mutable std::vector<OutputRecord> output_data{};
395
397 void constructOutputRecords() const;
398};
399
400} // namespace Opm
401
402#endif // UDQ_USAGE_HPP
Class for (de-)serializing.
Definition Serializer.hpp:94
Definition UDAValue.hpp:31
Internalised representation of a UDA from the input file.
Definition UDQActive.hpp:222
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition UDQActive.hpp:262
UDAControl control
Constraint keyword and item/limit for which this UDA supplies the numeric value.
Definition UDQActive.hpp:282
std::string wgname
Well or group affected by this UDA.
Definition UDQActive.hpp:278
std::string udq
Name of the UDQ used in this UDA.
Definition UDQActive.hpp:275
std::size_t input_index
Zero-based index in order of appearance of the UDQ use for this UDA.
Definition UDQActive.hpp:272
InputRecord()
Default constructor.
Definition UDQActive.cpp:162
bool operator==(const InputRecord &other) const
Equality predicate.
Definition UDQActive.cpp:177
Single UDA with use counts and IUAP start offsets for restart file output purposes.
Definition UDQActive.hpp:121
bool operator!=(const OutputRecord &other) const
Inequality predicate.
Definition UDQActive.hpp:165
int uda_code
Restart file integer representation of control.
Definition UDQActive.hpp:198
std::size_t input_index
Zero-based index in order of appearance of the UDQ use for this UDA.
Definition UDQActive.hpp:191
const std::string & wg_name() const
Name of well/group affected by this UDA.
Definition UDQActive.hpp:203
UDAControl control
Constraint keyword and item/limit for which this UDA supplies the numeric value.
Definition UDQActive.hpp:195
std::string udq
Name of UDQ from which this UDA derives its numeric value.
Definition UDQActive.hpp:187
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition UDQActive.hpp:176
bool operator==(const OutputRecord &other) const
Equality predicate.
Definition UDQActive.cpp:149
std::size_t use_count
Number of times this UDA is mentioned in this particular combination of constraint keyword and item/l...
Definition UDQActive.hpp:211
OutputRecord()
Default constructor.
Definition UDQActive.cpp:130
Internalised representation of all UDAs in a simulation run.
Definition UDQActive.hpp:50
const std::vector< OutputRecord > & iuad() const
Retrieve current set of UDAs, condensed by use counts and IUAP offsets.
Definition UDQActive.cpp:326
int update(const UDQConfig &udq_config, const UDAValue &uda, const std::string &wgname, const UDAControl control)
Amend collection of input UDAs to account for a new entry.
Definition UDQActive.cpp:261
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition UDQActive.hpp:377
static std::vector< RstRecord > load_rst(const UnitSystem &units, const UDQConfig &udq_config, const RestartIO::RstState &rst_state, const std::vector< std::string > &well_names, const std::vector< std::string > &group_names)
Load UDAs from restart file.
Definition UDQActive.cpp:199
UDQActive()=default
Default constructor.
std::vector< InputRecord > iuap() const
Retrieve current set of UDAs from which to form IUAP restart file array.
Definition UDQActive.cpp:335
bool operator==(const UDQActive &data) const
Equality predicate.
Definition UDQActive.cpp:365
static UDQActive serializationTestObject()
Create a serialisation test object.
Definition UDQActive.cpp:188
Collection of all user-defined quantities in the current simulation run.
Definition UDQConfig.hpp:69
Definition UnitSystem.hpp:34
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition state.hpp:56
Single UDA created from restart file information.
Definition UDQActive.hpp:54
UDAValue value
UDA value.
Definition UDQActive.hpp:104
std::string wgname
Name of well/group affected by this UDA.
Definition UDQActive.hpp:107
RstRecord(const UDAControl control_arg, const UDAValue value_arg, const std::string &wgname_arg, const Phase phase)
Constructor.
Definition UDQActive.hpp:88
RstRecord(const UDAControl control_arg, const UDAValue value_arg, const std::string &wgname_arg)
Constructor.
Definition UDQActive.hpp:67
std::optional< Phase > ig_phase
Injected phase in group level injection.
Definition UDQActive.hpp:112
UDAControl control
Item/limit of constraint keyword for which this UDA supplies the numeric value.
Definition UDQActive.hpp:99