20 #ifndef OPM_OUTPUT_GROUPS_HPP
21 #define OPM_OUTPUT_GROUPS_HPP
30 #include <opm/output/data/GuideRateValue.hpp>
31 #include <opm/json/JsonObject.hpp>
32 #include <opm/input/eclipse/Schedule/Group/Group.hpp>
34 namespace Opm {
namespace data {
37 Opm::Group::ProductionCMode currentProdConstraint;
38 Opm::Group::InjectionCMode currentGasInjectionConstraint;
39 Opm::Group::InjectionCMode currentWaterInjectionConstraint;
41 template <
class MessageBufferType>
42 void write(MessageBufferType& buffer)
const;
44 template <
class MessageBufferType>
45 void read(MessageBufferType& buffer);
49 return this->currentProdConstraint == other.currentProdConstraint &&
50 this->currentGasInjectionConstraint == other.currentGasInjectionConstraint &&
51 this->currentWaterInjectionConstraint == other.currentWaterInjectionConstraint;
55 Opm::Group::InjectionCMode cgic,
56 Opm::Group::InjectionCMode cwic);
59 json_data.add_item(
"prod", Opm::Group::ProductionCMode2String(this->currentProdConstraint));
60 json_data.add_item(
"water_inj", Opm::Group::InjectionCMode2String(this->currentGasInjectionConstraint));
61 json_data.add_item(
"gas_inj", Opm::Group::InjectionCMode2String(this->currentWaterInjectionConstraint));
69 template <
class MessageBufferType>
70 void write(MessageBufferType& buffer)
const
72 this->production.write(buffer);
73 this->injection .write(buffer);
76 template <
class MessageBufferType>
77 void read(MessageBufferType& buffer)
79 this->production.read(buffer);
80 this->injection .read(buffer);
85 return this->production == other.production
86 && this->injection == other.injection;
90 auto json_prod = json_data.add_object(
"production");
91 this->production.init_json(json_prod);
93 auto json_inj = json_data.add_object(
"injection");
94 this->injection.init_json(json_inj);
102 template <
class MessageBufferType>
103 void write(MessageBufferType& buffer)
const
105 this->currentControl.write(buffer);
106 this->guideRates .write(buffer);
109 template <
class MessageBufferType>
110 void read(MessageBufferType& buffer)
112 this->currentControl.read(buffer);
113 this->guideRates .read(buffer);
116 bool operator==(
const GroupData& other)
const
118 return this->currentControl == other.currentControl
119 && this->guideRates == other.guideRates;
124 auto json_constraints = json_data.add_object(
"constraints");
125 this->currentControl.init_json(json_constraints);
127 auto json_gr = json_data.add_object(
"guide_rate");
128 this->guideRates.init_json(json_gr);
133 double pressure { 0.0 };
135 template <
class MessageBufferType>
136 void write(MessageBufferType& buffer)
const
138 buffer.write(this->pressure);
141 template <
class MessageBufferType>
142 void read(MessageBufferType& buffer)
144 buffer.read(this->pressure);
147 bool operator==(
const NodeData& other)
const
149 return this->pressure == other.pressure;
153 json_data.add_item(
"pressure", this->pressure);
159 std::map<std::string, GroupData> groupData {};
160 std::map<std::string, NodeData> nodeData {};
162 template <
class MessageBufferType>
163 void write(MessageBufferType& buffer)
const
165 this->writeMap(this->groupData, buffer);
166 this->writeMap(this->nodeData, buffer);
169 template <
class MessageBufferType>
170 void read(MessageBufferType& buffer)
172 this->readMap(buffer, this->groupData);
173 this->readMap(buffer, this->nodeData);
178 return (this->groupData == other.groupData)
179 && (this->nodeData == other.nodeData);
184 this->groupData.clear();
185 this->nodeData.clear();
189 auto group_data = json_data.add_object(
"group_data");
190 for (
const auto& [gname, gdata] : this->groupData) {
191 auto group_json_data = group_data.add_object(gname);
192 gdata.init_json( group_json_data );
195 auto node_data = json_data.add_object(
"node_data");
196 for (
const auto& [gname, ndata] : this->nodeData) {
197 auto node_json_data = node_data.add_object(gname);
198 ndata.init_json( node_json_data );
204 this->init_json(json_data);
209 template <
class MessageBufferType,
class ValueType>
210 void writeMap(
const std::map<std::string, ValueType>& map,
211 MessageBufferType& buffer)
const
213 const unsigned int size = map.size();
216 for (
const auto& [name, elm] : map) {
222 template <
class MessageBufferType,
class ValueType>
223 void readMap(MessageBufferType& buffer,
224 std::map<std::string, ValueType>& map)
229 for (std::size_t i = 0; i < size; ++i) {
233 auto elm = ValueType{};
236 map.emplace(name, std::move(elm));
243 template <
class MessageBufferType>
244 void GroupConstraints::write(MessageBufferType& buffer)
const {
245 buffer.write(this->currentProdConstraint);
246 buffer.write(this->currentGasInjectionConstraint);
247 buffer.write(this->currentWaterInjectionConstraint);
250 template <
class MessageBufferType>
251 void GroupConstraints::read(MessageBufferType& buffer) {
252 buffer.read(this->currentProdConstraint);
253 buffer.read(this->currentGasInjectionConstraint);
254 buffer.read(this->currentWaterInjectionConstraint);
257 inline GroupConstraints&
258 GroupConstraints::set(Opm::Group::ProductionCMode cpc,
259 Opm::Group::InjectionCMode cgic,
260 Opm::Group::InjectionCMode cwic)
262 this->currentGasInjectionConstraint = cgic;
263 this->currentWaterInjectionConstraint = cwic;
264 this->currentProdConstraint = cpc;
Definition: JsonObject.hpp:32
Definition: Groups.hpp:157
Definition: GuideRateValue.hpp:32
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: Groups.hpp:36
Definition: Groups.hpp:98
Definition: Groups.hpp:65
Definition: Groups.hpp:132