20 #ifndef OPM_OUTPUT_GROUPS_HPP 21 #define OPM_OUTPUT_GROUPS_HPP 28 #include <opm/input/eclipse/EclipseState/Phase.hpp> 29 #include <opm/output/data/GuideRateValue.hpp> 30 #include <opm/input/eclipse/Schedule/Group/Group.hpp> 32 namespace Opm {
namespace data {
35 Opm::Group::ProductionCMode currentProdConstraint;
36 Opm::Group::InjectionCMode currentGasInjectionConstraint;
37 Opm::Group::InjectionCMode currentWaterInjectionConstraint;
39 template <
class MessageBufferType>
40 void write(MessageBufferType& buffer)
const;
42 template <
class MessageBufferType>
43 void read(MessageBufferType& buffer);
47 return this->currentProdConstraint == other.currentProdConstraint &&
48 this->currentGasInjectionConstraint == other.currentGasInjectionConstraint &&
49 this->currentWaterInjectionConstraint == other.currentWaterInjectionConstraint;
53 Opm::Group::InjectionCMode cgic,
54 Opm::Group::InjectionCMode cwic);
56 template<
class Serializer>
59 serializer(currentProdConstraint);
60 serializer(currentGasInjectionConstraint);
61 serializer(currentWaterInjectionConstraint);
67 Group::InjectionCMode::RATE,
68 Group::InjectionCMode::RESV};
76 template <
class MessageBufferType>
77 void write(MessageBufferType& buffer)
const 79 this->production.write(buffer);
80 this->injection .write(buffer);
83 template <
class MessageBufferType>
84 void read(MessageBufferType& buffer)
86 this->production.read(buffer);
87 this->injection .read(buffer);
92 return this->production == other.production
93 && this->injection == other.injection;
96 template<
class Serializer>
99 serializer(production);
100 serializer(injection);
106 GuideRateValue::serializationTestObject()};
114 template <
class MessageBufferType>
115 void write(MessageBufferType& buffer)
const 117 this->currentControl.write(buffer);
118 this->guideRates .write(buffer);
121 template <
class MessageBufferType>
122 void read(MessageBufferType& buffer)
124 this->currentControl.read(buffer);
125 this->guideRates .read(buffer);
128 bool operator==(
const GroupData& other)
const 130 return this->currentControl == other.currentControl
131 && this->guideRates == other.guideRates;
134 template<
class Serializer>
137 serializer(currentControl);
138 serializer(guideRates);
141 static GroupData serializationTestObject()
143 return GroupData{GroupConstraints::serializationTestObject(),
144 GroupGuideRates::serializationTestObject()};
149 double pressure { 0.0 };
150 double converged_pressure { 0.0 };
152 template <
class MessageBufferType>
153 void write(MessageBufferType& buffer)
const 155 buffer.write(this->pressure);
156 buffer.write(this->converged_pressure);
159 template <
class MessageBufferType>
160 void read(MessageBufferType& buffer)
162 buffer.read(this->pressure);
163 buffer.read(this->converged_pressure);
166 bool operator==(
const NodeData& other)
const 168 return this->pressure == other.pressure && this->converged_pressure == other.converged_pressure;
171 template<
class Serializer>
174 serializer(pressure);
175 serializer(converged_pressure);
178 static NodeData serializationTestObject()
185 double pressure_drop { 0.0 };
186 double oil_rate { 0.0 };
187 double water_rate { 0.0 };
188 double gas_rate { 0.0 };
190 template <
class MessageBufferType>
191 void write(MessageBufferType& buffer)
const 193 buffer.write(this->pressure_drop);
194 buffer.write(this->oil_rate);
195 buffer.write(this->water_rate);
196 buffer.write(this->gas_rate);
199 template <
class MessageBufferType>
200 void read(MessageBufferType& buffer)
202 buffer.read(this->pressure_drop);
203 buffer.read(this->oil_rate);
204 buffer.read(this->water_rate);
205 buffer.read(this->gas_rate);
208 bool operator==(
const BranchData& other)
const 210 return this->pressure_drop == other.pressure_drop
211 && this->oil_rate == other.oil_rate
212 && this->water_rate == other.water_rate
213 && this->gas_rate == other.gas_rate;
216 template<
class Serializer>
219 serializer(pressure_drop);
220 serializer(oil_rate);
221 serializer(water_rate);
222 serializer(gas_rate);
227 return BranchData{10.0, 100.0, 200.0, 20000.0};
234 std::map<std::string, GroupData> groupData {};
235 std::map<std::string, NodeData> nodeData {};
236 std::map<std::string, BranchData> branchData {};
237 std::map<std::string, BranchData> convergedBranchData {};
239 template <
class MessageBufferType>
240 void write(MessageBufferType& buffer)
const 242 this->writeMap(this->groupData, buffer);
243 this->writeMap(this->nodeData, buffer);
244 this->writeMap(this->branchData, buffer);
245 this->writeMap(this->convergedBranchData, buffer);
248 template <
class MessageBufferType>
249 void read(MessageBufferType& buffer)
251 this->readMap(buffer, this->groupData);
252 this->readMap(buffer, this->nodeData);
253 this->readMap(buffer, this->branchData);
254 this->readMap(buffer, this->convergedBranchData);
259 return (this->groupData == other.groupData)
260 && (this->nodeData == other.nodeData)
261 && (this->branchData == other.branchData)
262 && (this->convergedBranchData == other.convergedBranchData);
267 this->groupData.clear();
268 this->nodeData.clear();
269 this->branchData.clear();
270 this->convergedBranchData.clear();
273 template<
class Serializer>
276 serializer(groupData);
277 serializer(nodeData);
278 serializer(branchData);
279 serializer(convergedBranchData);
285 {{
"test_data", GroupData::serializationTestObject()}},
286 {{
"test_node", NodeData::serializationTestObject()}},
287 {{
"test_branch", BranchData::serializationTestObject()}},
288 {{
"test_converged_branch", BranchData::serializationTestObject()}}
293 template <
class MessageBufferType,
class ValueType>
294 void writeMap(
const std::map<std::string, ValueType>& map,
295 MessageBufferType& buffer)
const 297 const unsigned int size = map.size();
300 for (
const auto& [name, elm] : map) {
306 template <
class MessageBufferType,
class ValueType>
307 void readMap(MessageBufferType& buffer,
308 std::map<std::string, ValueType>& map)
313 for (std::size_t i = 0; i < size; ++i) {
317 auto elm = ValueType{};
320 map.emplace(name, std::move(elm));
327 template <
class MessageBufferType>
328 void GroupConstraints::write(MessageBufferType& buffer)
const {
329 buffer.write(this->currentProdConstraint);
330 buffer.write(this->currentGasInjectionConstraint);
331 buffer.write(this->currentWaterInjectionConstraint);
334 template <
class MessageBufferType>
335 void GroupConstraints::read(MessageBufferType& buffer) {
336 buffer.read(this->currentProdConstraint);
337 buffer.read(this->currentGasInjectionConstraint);
338 buffer.read(this->currentWaterInjectionConstraint);
341 inline GroupConstraints&
342 GroupConstraints::set(Opm::Group::ProductionCMode cpc,
343 Opm::Group::InjectionCMode cgic,
344 Opm::Group::InjectionCMode cwic)
346 this->currentGasInjectionConstraint = cgic;
347 this->currentWaterInjectionConstraint = cwic;
348 this->currentProdConstraint = cpc;
359 double oil{0}, gas{0}, water{0}, resv{0};
362 double surface{0}, reservoir{0};
367 std::map<std::string, std::map<Opm::Phase, InjectionRates>>
injection;
372 #endif //OPM_OUTPUT_GROUPS_HPP std::map< std::string, ProductionRates > production
Per master-group production rates (positive values, SI units).
Definition: Groups.hpp:365
Definition: Groups.hpp:72
Definition: Groups.hpp:232
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: Groups.hpp:110
Definition: GuideRateValue.hpp:31
Definition: Groups.hpp:34
Definition: Groups.hpp:148
Definition: Groups.hpp:358
std::map< std::string, std::map< Opm::Phase, InjectionRates > > injection
Per master-group, per-phase injection rates (SI units).
Definition: Groups.hpp:367
Production and injection rates for reservoir coupling master groups.
Definition: Groups.hpp:357
Definition: Groups.hpp:361
Definition: Groups.hpp:184
Class for (de-)serializing.
Definition: Serializer.hpp:95