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);
57 json_data.add_item(
"prod", Opm::Group::ProductionCMode2String(this->currentProdConstraint));
58 json_data.add_item(
"water_inj", Opm::Group::InjectionCMode2String(this->currentGasInjectionConstraint));
59 json_data.add_item(
"gas_inj", Opm::Group::InjectionCMode2String(this->currentWaterInjectionConstraint));
62 template<
class Serializer>
65 serializer(currentProdConstraint);
66 serializer(currentGasInjectionConstraint);
67 serializer(currentWaterInjectionConstraint);
73 Group::InjectionCMode::RATE,
74 Group::InjectionCMode::RESV};
82 template <
class MessageBufferType>
83 void write(MessageBufferType& buffer)
const
85 this->production.write(buffer);
86 this->injection .write(buffer);
89 template <
class MessageBufferType>
90 void read(MessageBufferType& buffer)
92 this->production.read(buffer);
93 this->injection .read(buffer);
98 return this->production == other.production
99 && this->injection == other.injection;
103 auto json_prod = json_data.add_object(
"production");
104 this->production.init_json(json_prod);
106 auto json_inj = json_data.add_object(
"injection");
107 this->injection.init_json(json_inj);
110 template<
class Serializer>
113 serializer(production);
114 serializer(injection);
120 GuideRateValue::serializationTestObject()};
128 template <
class MessageBufferType>
129 void write(MessageBufferType& buffer)
const
131 this->currentControl.write(buffer);
132 this->guideRates .write(buffer);
135 template <
class MessageBufferType>
136 void read(MessageBufferType& buffer)
138 this->currentControl.read(buffer);
139 this->guideRates .read(buffer);
142 bool operator==(
const GroupData& other)
const
144 return this->currentControl == other.currentControl
145 && this->guideRates == other.guideRates;
150 auto json_constraints = json_data.add_object(
"constraints");
151 this->currentControl.init_json(json_constraints);
153 auto json_gr = json_data.add_object(
"guide_rate");
154 this->guideRates.init_json(json_gr);
157 template<
class Serializer>
160 serializer(currentControl);
161 serializer(guideRates);
164 static GroupData serializationTestObject()
166 return GroupData{GroupConstraints::serializationTestObject(),
167 GroupGuideRates::serializationTestObject()};
172 double pressure { 0.0 };
173 double converged_pressure { 0.0 };
175 template <
class MessageBufferType>
176 void write(MessageBufferType& buffer)
const
178 buffer.write(this->pressure);
179 buffer.write(this->converged_pressure);
182 template <
class MessageBufferType>
183 void read(MessageBufferType& buffer)
185 buffer.read(this->pressure);
186 buffer.read(this->converged_pressure);
189 bool operator==(
const NodeData& other)
const
191 return this->pressure == other.pressure && this->converged_pressure == other.converged_pressure;
195 json_data.add_item(
"pressure", this->pressure);
196 json_data.add_item(
"converged_pressure", this->converged_pressure);
199 template<
class Serializer>
202 serializer(pressure);
203 serializer(converged_pressure);
206 static NodeData serializationTestObject()
214 std::map<std::string, GroupData> groupData {};
215 std::map<std::string, NodeData> nodeData {};
217 template <
class MessageBufferType>
218 void write(MessageBufferType& buffer)
const
220 this->writeMap(this->groupData, buffer);
221 this->writeMap(this->nodeData, buffer);
224 template <
class MessageBufferType>
225 void read(MessageBufferType& buffer)
227 this->readMap(buffer, this->groupData);
228 this->readMap(buffer, this->nodeData);
233 return (this->groupData == other.groupData)
234 && (this->nodeData == other.nodeData);
239 this->groupData.clear();
240 this->nodeData.clear();
244 auto group_data = json_data.add_object(
"group_data");
245 for (
const auto& [gname, gdata] : this->groupData) {
246 auto group_json_data = group_data.add_object(gname);
247 gdata.init_json( group_json_data );
250 auto node_data = json_data.add_object(
"node_data");
251 for (
const auto& [gname, ndata] : this->nodeData) {
252 auto node_json_data = node_data.add_object(gname);
253 ndata.init_json( node_json_data );
259 this->init_json(json_data);
263 template<
class Serializer>
266 serializer(groupData);
267 serializer(nodeData);
273 {{
"test_data", GroupData::serializationTestObject()}},
274 {{
"test_node", NodeData::serializationTestObject()}}
279 template <
class MessageBufferType,
class ValueType>
280 void writeMap(
const std::map<std::string, ValueType>& map,
281 MessageBufferType& buffer)
const
283 const unsigned int size = map.size();
286 for (
const auto& [name, elm] : map) {
292 template <
class MessageBufferType,
class ValueType>
293 void readMap(MessageBufferType& buffer,
294 std::map<std::string, ValueType>& map)
299 for (std::size_t i = 0; i < size; ++i) {
303 auto elm = ValueType{};
306 map.emplace(name, std::move(elm));
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30