20#ifndef OPM_OUTPUT_WELLS_HPP
21#define OPM_OUTPUT_WELLS_HPP
23#include <opm/output/data/GuideRateValue.hpp>
24#include <opm/input/eclipse/Schedule/Well/WellEnums.hpp>
26#include <opm/json/JsonObject.hpp>
36#include <unordered_map>
39namespace Opm {
namespace data {
53 enum class opt : uint32_t {
60 dissolved_gas = (1 << 6),
61 vaporized_oil = (1 << 7),
62 reservoir_water = (1 << 8),
63 reservoir_oil = (1 << 9),
64 reservoir_gas = (1 << 10),
65 productivity_index_water = (1 << 11),
66 productivity_index_oil = (1 << 12),
67 productivity_index_gas = (1 << 13),
68 well_potential_water = (1 << 14),
69 well_potential_oil = (1 << 15),
70 well_potential_gas = (1 << 16),
75 vaporized_water = (1 << 21),
79 using enum_size = std::underlying_type< opt >::type;
82 inline bool has( opt )
const;
86 inline double get( opt m )
const;
89 inline double get( opt m,
double default_value )
const;
90 inline double get( opt m,
double default_value ,
const std::string& tracer_name )
const;
94 inline Rates&
set( opt m,
double value );
95 inline Rates&
set( opt m,
double value ,
const std::string& tracer_name );
100 template <
class MessageBufferType>
101 void write(MessageBufferType& buffer)
const;
102 template <
class MessageBufferType>
103 void read(MessageBufferType& buffer);
105 bool operator==(
const Rates& rat2)
const;
109 template<
class Serializer>
119 serializer(dissolved_gas);
120 serializer(vaporized_oil);
121 serializer(reservoir_water);
122 serializer(reservoir_oil);
123 serializer(reservoir_gas);
124 serializer(productivity_index_water);
125 serializer(productivity_index_oil);
126 serializer(productivity_index_gas);
127 serializer(well_potential_water);
128 serializer(well_potential_oil);
129 serializer(well_potential_gas);
134 serializer(vaporized_water);
135 serializer(mass_gas);
138 static Rates serializationTestObject()
141 rat1.
set(opt::wat, 1.0);
142 rat1.
set(opt::oil, 2.0);
143 rat1.
set(opt::gas, 3.0);
144 rat1.
set(opt::polymer, 4.0);
145 rat1.
set(opt::solvent, 5.0);
146 rat1.
set(opt::energy, 6.0);
147 rat1.
set(opt::dissolved_gas, 7.0);
148 rat1.
set(opt::vaporized_oil, 8.0);
149 rat1.
set(opt::reservoir_water, 9.0);
150 rat1.
set(opt::reservoir_oil, 10.0);
151 rat1.
set(opt::reservoir_gas, 11.0);
152 rat1.
set(opt::productivity_index_water, 12.0);
153 rat1.
set(opt::productivity_index_oil, 13.0);
154 rat1.
set(opt::productivity_index_gas, 14.0);
155 rat1.
set(opt::well_potential_water, 15.0);
156 rat1.
set(opt::well_potential_oil, 16.0);
157 rat1.
set(opt::well_potential_gas, 17.0);
158 rat1.
set(opt::brine, 18.0);
159 rat1.
set(opt::alq, 19.0);
160 rat1.
set(opt::micp, 21.0);
161 rat1.
set(opt::vaporized_water, 22.0);
162 rat1.
set(opt::mass_gas, 23.0);
163 rat1.tracer.insert({
"test_tracer", 1.0});
169 double& get_ref( opt );
170 double& get_ref( opt,
const std::string& tracer_name );
171 const double& get_ref( opt )
const;
172 const double& get_ref( opt,
const std::string& tracer_name )
const;
174 opt mask =
static_cast< opt
>( 0 );
179 double polymer = 0.0;
180 double solvent = 0.0;
182 double dissolved_gas = 0.0;
183 double vaporized_oil = 0.0;
184 double reservoir_water = 0.0;
185 double reservoir_oil = 0.0;
186 double reservoir_gas = 0.0;
187 double productivity_index_water = 0.0;
188 double productivity_index_oil = 0.0;
189 double productivity_index_gas = 0.0;
190 double well_potential_water = 0.0;
191 double well_potential_oil = 0.0;
192 double well_potential_gas = 0.0;
195 std::map<std::string, double> tracer{};
197 double vaporized_water = 0.0;
198 double mass_gas = 0.0;
212 template<
class Serializer>
216 serializer(skin_factor);
217 serializer(thickness);
221 serializer(area_of_flow);
226 return this->rate == filtrate.rate &&
227 this->total == filtrate.total &&
228 this->skin_factor == filtrate.skin_factor &&
229 this->thickness == filtrate.thickness &&
230 this->perm == filtrate.perm &&
231 this->poro == filtrate.poro &&
232 this->radius == filtrate.radius &&
233 this->area_of_flow == filtrate.area_of_flow;
238 return {0.8, 100., -1., 2., 1.e-9,
242 template <
class MessageBufferType>
243 void write(MessageBufferType& buffer)
const;
245 template <
class MessageBufferType>
246 void read(MessageBufferType& buffer);
251 using global_index = std::size_t;
252 static const constexpr int restart_size = 6;
254 global_index index{};
257 double reservoir_rate{};
258 double cell_pressure{};
259 double cell_saturation_water{};
260 double cell_saturation_gas{};
261 double effective_Kh{};
262 double trans_factor{};
264 double compact_mult{1.0};
268 bool operator==(
const Connection& conn2)
const
270 return (index == conn2.index)
271 && (rates == conn2.rates)
272 && (pressure == conn2.pressure)
273 && (reservoir_rate == conn2.reservoir_rate)
274 && (cell_pressure == conn2.cell_pressure)
275 && (cell_saturation_water == conn2.cell_saturation_water)
276 && (cell_saturation_gas == conn2.cell_saturation_gas)
277 && (effective_Kh == conn2.effective_Kh)
278 && (trans_factor == conn2.trans_factor)
279 && (d_factor == conn2.d_factor)
280 && (compact_mult == conn2.compact_mult)
281 && (filtrate == conn2.filtrate)
285 template <
class MessageBufferType>
286 void write(MessageBufferType& buffer)
const;
287 template <
class MessageBufferType>
288 void read(MessageBufferType& buffer);
292 template<
class Serializer>
297 serializer(pressure);
298 serializer(reservoir_rate);
299 serializer(cell_pressure);
300 serializer(cell_saturation_water);
301 serializer(cell_saturation_gas);
302 serializer(effective_Kh);
303 serializer(trans_factor);
304 serializer(d_factor);
305 serializer(compact_mult);
306 serializer(filtrate);
312 1, Rates::serializationTestObject(),
314 6.0, 7.0, 8.0, 9.0, 0.987,
315 ConnectionFiltrate::serializationTestObject()
323 enum class Value : std::size_t {
324 Pressure, PDrop, PDropHydrostatic, PDropAccel, PDropFriction,
327 double& operator[](
const Value i)
329 return this->values_[this->index(i)];
332 double operator[](
const Value i)
const
334 return this->values_[this->index(i)];
339 return this->values_ == segpres2.values_;
342 template <
class MessageBufferType>
343 void write(MessageBufferType& buffer)
const
345 for (
const auto& value : this->values_) {
350 template <
class MessageBufferType>
351 void read(MessageBufferType& buffer)
353 for (
auto& value : this->values_) {
358 template<
class Serializer>
367 spres[Value::Pressure] = 1.0;
368 spres[Value::PDrop] = 2.0;
369 spres[Value::PDropHydrostatic] = 3.0;
370 spres[Value::PDropAccel] = 4.0;
371 spres[Value::PDropFriction] = 5.0;
377 constexpr static std::size_t numvals = 5;
379 std::array<double, numvals> values_ = {0};
381 std::size_t index(
const Value ix)
const
383 return static_cast<std::size_t
>(ix);
387 template <
typename Items>
391 using Item =
typename Items::Item;
395 this->has_ =
static_cast<unsigned char>(0);
396 this->value_.fill(0.0);
399 constexpr bool has(
const Item p)
const
401 const auto i = this->index(p);
403 return (i < Size) && this->hasItem(i);
408 return (this->has_ == that.has_)
409 && (this->value_ == that.value_);
412 double get(
const Item p)
const
414 if (! this->has(p)) {
415 throw std::invalid_argument {
416 "Request for Unset Item Value for " + Items::itemName(p)
420 return this->value_[ this->index(p) ];
425 const auto i = this->index(p);
428 throw std::invalid_argument {
429 "Cannot Assign Item Value for Unsupported Item '"
430 + Items::itemName(p) +
'\''
434 this->has_ |= 1 << i;
435 this->value_[i] = value;
440 template <
class MessageBufferType>
441 void write(MessageBufferType& buffer)
const
443 buffer.write(this->has_);
445 for (
const auto& x : this->value_) {
450 template <
class MessageBufferType>
451 void read(MessageBufferType& buffer)
454 buffer.read(this->has_);
456 for (
auto& x : this->value_) {
461 template <
class Serializer>
464 serializer(this->has_);
465 serializer(this->value_);
472 for (
const auto& [item, value] : Items::serializationTestItems()) {
473 quant.set(item, value);
480 enum { Size =
static_cast<std::size_t
>(Item::NumItems) };
482 static_assert(Size <= static_cast<std::size_t>(CHAR_BIT),
483 "Number of items must not exceed CHAR_BIT");
487 unsigned char has_{};
490 std::array<double, Size> value_{};
492 constexpr std::size_t index(
const Item p)
const noexcept
494 return static_cast<std::size_t
>(p);
497 bool hasItem(
const std::size_t i)
const
499 return (this->has_ & (1 << i)) != 0;
512 static std::string itemName(
const Item p)
515 case Item::Oil:
return "Oil";
516 case Item::Gas:
return "Gas";
517 case Item::Water:
return "Water";
520 return "Out of bounds (NumItems)";
523 return "Unknown (" + std::to_string(
static_cast<int>(p)) +
')';
526 static auto serializationTestItems()
529 std::pair { Item::Oil , 1.0 },
530 std::pair { Item::Gas , 7.0 },
531 std::pair { Item::Water, 2.9 },
539 Oil, Gas, Water, Mixture, MixtureWithExponents,
545 static std::string itemName(
const Item p)
548 case Item::Oil:
return "Oil";
549 case Item::Gas:
return "Gas";
550 case Item::Water:
return "Water";
551 case Item::Mixture:
return "Mixture";
552 case Item::MixtureWithExponents:
return "MixtureWithExponents";
555 return "Out of bounds (NumItems)";
558 return "Unknown (" + std::to_string(
static_cast<int>(p)) +
')';
561 static auto serializationTestItems()
564 std::pair { Item::Oil , 876.54 },
565 std::pair { Item::Gas , 321.09 },
566 std::pair { Item::Water , 987.65 },
567 std::pair { Item::Mixture , 975.31 },
568 std::pair { Item::MixtureWithExponents, 765.43 },
584 std::size_t segNumber{};
586 bool operator==(
const Segment& seg2)
const
588 return (rates == seg2.rates)
589 && (pressures == seg2.pressures)
590 && (velocity == seg2.velocity)
591 && (holdup == seg2.holdup)
592 && (viscosity == seg2.viscosity)
593 && (density == seg2.density)
594 && (segNumber == seg2.segNumber);
597 template <
class MessageBufferType>
598 void write(MessageBufferType& buffer)
const;
600 template <
class MessageBufferType>
601 void read(MessageBufferType& buffer);
603 template <
class Serializer>
606 serializer(this->rates);
607 serializer(this->pressures);
608 serializer(this->velocity);
609 serializer(this->holdup);
610 serializer(this->viscosity);
611 serializer(this->density);
612 serializer(this->segNumber);
615 static Segment serializationTestObject()
618 Rates::serializationTestObject(),
619 SegmentPressures::serializationTestObject(),
620 SegmentPhaseQuantity::serializationTestObject(),
621 SegmentPhaseQuantity::serializationTestObject(),
622 SegmentPhaseQuantity::serializationTestObject(),
623 SegmentPhaseDensity::serializationTestObject(),
631 bool isProducer{
true};
633 ::Opm::WellProducerCMode prod {
634 ::Opm::WellProducerCMode::CMODE_UNDEFINED
637 ::Opm::WellInjectorCMode inj {
638 ::Opm::WellInjectorCMode::CMODE_UNDEFINED
643 return (this->isProducer == rhs.isProducer)
644 && ((this->isProducer && (this->prod == rhs.prod)) ||
645 (!this->isProducer && (this->inj == rhs.inj)));
650 if (this->inj == ::Opm::WellInjectorCMode::CMODE_UNDEFINED)
651 json_data.add_item(
"inj",
"CMODE_UNDEFINED");
653 json_data.add_item(
"inj", ::Opm::WellInjectorCMode2String(this->inj));
655 if (this->prod == ::Opm::WellProducerCMode::CMODE_UNDEFINED)
656 json_data.add_item(
"prod",
"CMODE_UNDEFINED");
658 json_data.add_item(
"prod", ::Opm::WellProducerCMode2String(this->prod));
661 template <
class MessageBufferType>
662 void write(MessageBufferType& buffer)
const;
664 template <
class MessageBufferType>
665 void read(MessageBufferType& buffer);
667 template<
class Serializer>
670 serializer(isProducer);
678 ::Opm::WellProducerCMode::BHP,
679 ::Opm::WellInjectorCMode::GRUP
687 enum class Quantity { WBP, WBP4, WBP5, WBP9 };
689 double& operator[](
const Quantity q)
691 return this->wbp_[
static_cast<std::size_t
>(q)];
694 double operator[](
const Quantity q)
const
696 return this->wbp_[
static_cast<std::size_t
>(q)];
701 return this->wbp_ == that.wbp_;
704 template <
class MessageBufferType>
705 void write(MessageBufferType& buffer)
const;
707 template <
class MessageBufferType>
708 void read(MessageBufferType& buffer);
710 template <
class Serializer>
713 serializer(this->wbp_);
720 wbp[Quantity::WBP] = 17.29;
721 wbp[Quantity::WBP4] = 2.718;
722 wbp[Quantity::WBP5] = 3.1415;
723 wbp[Quantity::WBP9] = 1.618;
729 static constexpr auto NumQuantities =
730 static_cast<std::size_t
>(Quantity::WBP9) + 1;
732 std::array<double, NumQuantities> wbp_{};
739 double concentration{0.};
741 template<
class Serializer>
745 serializer(concentration);
749 return this->rate == filtrate.rate
750 && this->total == filtrate.total
751 && this->concentration == filtrate.concentration;
758 res.concentration = 0.;
762 template <
class MessageBufferType>
763 void write(MessageBufferType& buffer)
const;
765 template <
class MessageBufferType>
766 void read(MessageBufferType& buffer);
772 Bhp, OilRate, WaterRate, GasRate, ResVRate, LiquidRate,
778 static std::string itemName(
const Item p)
781 case Item::Bhp:
return "Bhp";
782 case Item::OilRate:
return "OilRate";
783 case Item::WaterRate:
return "WaterRate";
784 case Item::GasRate:
return "GasRate";
785 case Item::ResVRate:
return "ResVRate";
786 case Item::LiquidRate:
return "LiquidRate";
789 return "Out of bounds (NumItems)";
792 return "Unknown (" + std::to_string(
static_cast<int>(p)) +
')';
795 static auto serializationTestItems()
798 std::pair { Item::Bhp , 321.09 },
799 std::pair { Item::OilRate , 987.65 },
800 std::pair { Item::WaterRate , 975.31 },
801 std::pair { Item::GasRate , 765.43 },
802 std::pair { Item::ResVRate , 876.54 },
803 std::pair { Item::LiquidRate, 54.32 },
816 double temperature{0.0};
821 ::Opm::WellStatus dynamicStatus { Opm::WellStatus::OPEN };
823 std::vector<Connection> connections{};
824 std::unordered_map<std::size_t, Segment> segments{};
829 inline bool flowing()
const noexcept;
831 template <
class MessageBufferType>
832 void write(MessageBufferType& buffer)
const;
834 template <
class MessageBufferType>
835 void read(MessageBufferType& buffer);
840 find_connection(
const Connection::global_index connection_grid_index)
const
842 auto connection = std::find_if(this->connections.begin(),
843 this->connections.end(),
845 { return c.index == connection_grid_index; });
847 if (connection == this->connections.end()) {
855 find_connection(
const Connection::global_index connection_grid_index)
857 auto connection = std::find_if(this->connections.begin(),
858 this->connections.end(),
860 { return c.index == connection_grid_index; });
862 if (connection == this->connections.end()) {
869 bool operator==(
const Well& well2)
const
871 return (this->rates == well2.rates)
872 && (this->bhp == well2.bhp)
873 && (this->thp == well2.thp)
874 && (this->temperature == well2.temperature)
875 && (this->filtrate == well2.filtrate)
876 && (this->control == well2.control)
877 && (this->dynamicStatus == well2.dynamicStatus)
878 && (this->connections == well2.connections)
879 && (this->segments == well2.segments)
880 && (this->current_control == well2.current_control)
881 && (this->guide_rates == well2.guide_rates)
882 && (this->limits == well2.limits)
886 template<
class Serializer>
892 serializer(temperature);
894 serializer(filtrate);
895 serializer(dynamicStatus);
896 serializer(connections);
897 serializer(segments);
898 serializer(current_control);
899 serializer(guide_rates);
903 static Well serializationTestObject()
906 Rates::serializationTestObject(),
911 WellFiltrate::serializationTestObject(),
912 ::Opm::WellStatus::SHUT,
913 {Connection::serializationTestObject()},
914 {{0, Segment::serializationTestObject()}},
915 CurrentControl::serializationTestObject(),
916 GuideRateValue::serializationTestObject(),
917 WellControlLimits::serializationTestObject()
922 class Wells:
public std::map<std::string , Well> {
925 double get(
const std::string& well_name , Rates::opt m)
const {
926 const auto& well = this->find( well_name );
927 if( well == this->end() )
return 0.0;
929 return well->second.rates.get( m, 0.0 );
932 double get(
const std::string& well_name , Rates::opt m,
const std::string& tracer_name)
const {
933 const auto& well = this->find( well_name );
934 if( well == this->end() )
return 0.0;
936 return well->second.rates.get( m, 0.0, tracer_name);
939 double get(
const std::string& well_name , Connection::global_index connection_grid_index, Rates::opt m)
const {
940 const auto& witr = this->find( well_name );
941 if( witr == this->end() )
return 0.0;
943 const auto& well = witr->second;
944 const auto& connection = std::find_if( well.connections.begin() ,
945 well.connections.end() ,
947 return c.index == connection_grid_index; });
949 if( connection == well.connections.end() )
952 return connection->rates.get( m, 0.0 );
955 template <
class MessageBufferType>
956 void write(MessageBufferType& buffer)
const {
957 unsigned int size = this->size();
959 for (
const auto& witr : *
this) {
960 const std::string& name = witr.first;
962 const Well& well = witr.second;
967 template <
class MessageBufferType>
968 void read(MessageBufferType& buffer) {
971 for (
size_t i = 0; i < size; ++i) {
976 this->emplace(name, well);
981 for (
const auto& [wname, well] : *
this) {
982 auto json_well = json_data.add_object(wname);
983 well.init_json(json_well);
990 this->init_json(json_data);
994 template<
class Serializer>
997 serializer(
static_cast<std::map<std::string,Well>&
>(*
this));
1000 static Wells serializationTestObject()
1003 w.insert({
"test_well", Well::serializationTestObject()});
1011 std::unordered_map<std::string, WellBlockAvgPress> values{};
1013 template <
class MessageBufferType>
1014 void write(MessageBufferType& buffer)
const;
1016 template <
class MessageBufferType>
1017 void read(MessageBufferType& buffer);
1021 return this->values == that.values;
1024 template <
class Serializer>
1027 serializer(this->values);
1033 { {
"I-45", WellBlockAvgPress::serializationTestObject() } },
1041 const auto mand =
static_cast< enum_size
>( this->mask )
1042 &
static_cast< enum_size
>( m );
1044 return static_cast< opt
>( mand ) == m;
1048 if( !this->
has( m ) )
1049 throw std::invalid_argument(
"Uninitialized value." );
1051 return this->get_ref( m );
1055 if( !this->
has( m ) )
return default_value;
1057 return this->get_ref( m );
1060 inline double Rates::get( opt m,
double default_value,
const std::string& tracer_name)
const {
1061 if( !this->
has( m ) )
return default_value;
1063 if( m == opt::tracer && this->tracer.find(tracer_name) == this->tracer.end())
return default_value;
1065 return this->get_ref( m, tracer_name);
1069 this->get_ref( m ) = value;
1072 this->mask =
static_cast< opt
>(
1073 static_cast< enum_size
>( this->mask ) |
1074 static_cast< enum_size
>( m )
1080 inline Rates&
Rates::set( opt m,
double value ,
const std::string& tracer_name ) {
1081 this->get_ref( m , tracer_name) = value;
1084 this->mask =
static_cast< opt
>(
1085 static_cast< enum_size
>( this->mask ) |
1086 static_cast< enum_size
>( m )
1092 inline bool Rates::operator==(
const Rates& rate)
const
1094 return mask == rate.mask &&
1098 polymer == rate.polymer &&
1099 solvent == rate.solvent &&
1100 energy == rate.energy &&
1101 dissolved_gas == rate.dissolved_gas &&
1102 vaporized_oil == rate.vaporized_oil &&
1103 reservoir_water == rate.reservoir_water &&
1104 reservoir_oil == rate.reservoir_oil &&
1105 reservoir_gas == rate.reservoir_gas &&
1106 productivity_index_water == rate.productivity_index_water &&
1107 productivity_index_gas == rate.productivity_index_gas &&
1108 productivity_index_oil == rate.productivity_index_oil &&
1109 well_potential_water == rate.well_potential_water &&
1110 well_potential_oil == rate.well_potential_oil &&
1111 well_potential_gas == rate.well_potential_gas &&
1112 brine == rate.brine &&
1114 tracer == rate.tracer &&
1115 micp == rate.micp &&
1116 vaporized_water == rate.vaporized_water &&
1117 mass_gas == rate.mass_gas;
1130 inline const double& Rates::get_ref( opt m )
const {
1132 case opt::wat:
return this->wat;
1133 case opt::oil:
return this->oil;
1134 case opt::gas:
return this->gas;
1135 case opt::polymer:
return this->polymer;
1136 case opt::solvent:
return this->solvent;
1137 case opt::energy:
return this->energy;
1138 case opt::dissolved_gas:
return this->dissolved_gas;
1139 case opt::vaporized_oil:
return this->vaporized_oil;
1140 case opt::reservoir_water:
return this->reservoir_water;
1141 case opt::reservoir_oil:
return this->reservoir_oil;
1142 case opt::reservoir_gas:
return this->reservoir_gas;
1143 case opt::productivity_index_water:
return this->productivity_index_water;
1144 case opt::productivity_index_oil:
return this->productivity_index_oil;
1145 case opt::productivity_index_gas:
return this->productivity_index_gas;
1146 case opt::well_potential_water:
return this->well_potential_water;
1147 case opt::well_potential_oil:
return this->well_potential_oil;
1148 case opt::well_potential_gas:
return this->well_potential_gas;
1149 case opt::brine:
return this->brine;
1150 case opt::alq:
return this->alq;
1153 case opt::micp:
return this->micp;
1154 case opt::vaporized_water:
return this->vaporized_water;
1155 case opt::mass_gas:
return this->mass_gas;
1158 throw std::invalid_argument(
1159 "Unknown value type '"
1160 + std::to_string(
static_cast< enum_size
>( m ) )
1165 inline const double& Rates::get_ref( opt m,
const std::string& tracer_name )
const {
1166 if (m != opt::tracer)
1167 throw std::logic_error(
"Logic error - should be called with tracer argument");
1169 return this->tracer.at(tracer_name);
1172 inline double& Rates::get_ref( opt m ) {
1173 return const_cast< double&
>(
1174 static_cast< const Rates*
>( this )->get_ref( m )
1178 inline double& Rates::get_ref( opt m,
const std::string& tracer_name ) {
1179 if (m == opt::tracer) this->tracer.emplace(tracer_name, 0.0);
1180 return this->tracer.at(tracer_name);
1185 if (this->
has(opt::wat))
1186 json_data.add_item(
"wat", this->
get(opt::wat));
1188 if (this->
has(opt::oil))
1189 json_data.add_item(
"oil", this->
get(opt::oil));
1191 if (this->
has(opt::gas))
1192 json_data.add_item(
"gas", this->
get(opt::gas));
1197 return ((this->wat != 0) ||
1202 inline bool Well::flowing() const noexcept {
1206 template <
class MessageBufferType>
1207 void Rates::write(MessageBufferType& buffer)
const {
1208 buffer.write(this->mask);
1209 buffer.write(this->wat);
1210 buffer.write(this->oil);
1211 buffer.write(this->gas);
1212 buffer.write(this->polymer);
1213 buffer.write(this->solvent);
1214 buffer.write(this->energy);
1215 buffer.write(this->dissolved_gas);
1216 buffer.write(this->vaporized_oil);
1217 buffer.write(this->reservoir_water);
1218 buffer.write(this->reservoir_oil);
1219 buffer.write(this->reservoir_gas);
1220 buffer.write(this->productivity_index_water);
1221 buffer.write(this->productivity_index_oil);
1222 buffer.write(this->productivity_index_gas);
1223 buffer.write(this->well_potential_water);
1224 buffer.write(this->well_potential_oil);
1225 buffer.write(this->well_potential_gas);
1226 buffer.write(this->brine);
1227 buffer.write(this->alq);
1230 unsigned int size = this->tracer.size();
1232 for (
const auto& [name, rate] : this->tracer) {
1237 buffer.write(this->micp);
1238 buffer.write(this->vaporized_water);
1239 buffer.write(this->mass_gas);
1242 template <
class MessageBufferType>
1243 void ConnectionFiltrate::write(MessageBufferType& buffer)
const {
1244 buffer.write(this->rate);
1245 buffer.write(this->total);
1246 buffer.write(this->skin_factor);
1247 buffer.write(this->thickness);
1248 buffer.write(this->perm);
1249 buffer.write(this->poro);
1250 buffer.write(this->radius);
1251 buffer.write(this->area_of_flow);
1254 template <
class MessageBufferType>
1255 void Connection::write(MessageBufferType& buffer)
const {
1256 buffer.write(this->index);
1257 this->rates.write(buffer);
1258 buffer.write(this->pressure);
1259 buffer.write(this->reservoir_rate);
1260 buffer.write(this->cell_pressure);
1261 buffer.write(this->cell_saturation_water);
1262 buffer.write(this->cell_saturation_gas);
1263 buffer.write(this->effective_Kh);
1264 buffer.write(this->trans_factor);
1265 buffer.write(this->d_factor);
1266 buffer.write(this->compact_mult);
1267 this->filtrate.write(buffer);
1271 auto json_rates = json_data.add_object(
"rates");
1272 this->rates.init_json(json_rates);
1274 json_data.add_item(
"global_index",
static_cast<int>(this->index));
1275 json_data.add_item(
"pressure", this->pressure);
1276 json_data.add_item(
"reservoir_rate", this->reservoir_rate);
1277 json_data.add_item(
"cell_pressure", this->cell_pressure);
1278 json_data.add_item(
"swat", this->cell_saturation_water);
1279 json_data.add_item(
"sgas", this->cell_saturation_gas);
1280 json_data.add_item(
"Kh", this->effective_Kh);
1281 json_data.add_item(
"trans_factor", this->trans_factor);
1282 json_data.add_item(
"d_factor", this->d_factor);
1283 json_data.add_item(
"compact_mult", this->compact_mult);
1286 template <
class MessageBufferType>
1287 void Segment::write(MessageBufferType& buffer)
const
1289 buffer.write(this->segNumber);
1290 this->rates.write(buffer);
1291 this->pressures.write(buffer);
1292 this->velocity.write(buffer);
1293 this->holdup.write(buffer);
1294 this->viscosity.write(buffer);
1295 this->density.write(buffer);
1298 template <
class MessageBufferType>
1299 void CurrentControl::write(MessageBufferType& buffer)
const
1301 buffer.write(this->isProducer);
1302 if (this->isProducer) {
1303 buffer.write(this->prod);
1306 buffer.write(this->inj);
1310 template <
class MessageBufferType>
1311 void WellBlockAvgPress::write(MessageBufferType& buffer)
const
1313 for (
const auto& quantity : this->wbp_) {
1314 buffer.write(quantity);
1318 template <
class MessageBufferType>
1319 void WellFiltrate::write(MessageBufferType& buffer)
const
1321 buffer.write(this->rate);
1322 buffer.write(this->total);
1323 buffer.write(this->concentration);
1326 template <
class MessageBufferType>
1327 void Well::write(MessageBufferType& buffer)
const
1329 this->rates.write(buffer);
1331 buffer.write(this->bhp);
1332 buffer.write(this->thp);
1333 buffer.write(this->temperature);
1334 buffer.write(this->control);
1336 this->filtrate.write(buffer);
1339 const auto status = ::Opm::WellStatus2String(this->dynamicStatus);
1340 buffer.write(status);
1344 const unsigned int size = this->connections.size();
1347 for (
const Connection& comp : this->connections) {
1354 static_cast<unsigned int>(this->segments.size());
1357 for (
const auto& seg : this->segments) {
1358 seg.second.write(buffer);
1362 this->current_control.write(buffer);
1363 this->guide_rates.write(buffer);
1364 this->limits.write(buffer);
1367 template <
class MessageBufferType>
1368 void WellBlockAveragePressures::write(MessageBufferType& buffer)
const
1370 buffer.write(this->values.size());
1372 for (
const auto& [well, value] : this->values) {
1374 value.write(buffer);
1378 template <
class MessageBufferType>
1379 void Rates::read(MessageBufferType& buffer) {
1380 buffer.read(this->mask);
1381 buffer.read(this->wat);
1382 buffer.read(this->oil);
1383 buffer.read(this->gas);
1384 buffer.read(this->polymer);
1385 buffer.read(this->solvent);
1386 buffer.read(this->energy);
1387 buffer.read(this->dissolved_gas);
1388 buffer.read(this->vaporized_oil);
1389 buffer.read(this->reservoir_water);
1390 buffer.read(this->reservoir_oil);
1391 buffer.read(this->reservoir_gas);
1392 buffer.read(this->productivity_index_water);
1393 buffer.read(this->productivity_index_oil);
1394 buffer.read(this->productivity_index_gas);
1395 buffer.read(this->well_potential_water);
1396 buffer.read(this->well_potential_oil);
1397 buffer.read(this->well_potential_gas);
1398 buffer.read(this->brine);
1399 buffer.read(this->alq);
1404 for (
size_t i = 0; i < size; ++i) {
1405 std::string tracer_name;
1406 buffer.read(tracer_name);
1408 buffer.read(tracer_rate);
1409 this->tracer.emplace(tracer_name, tracer_rate);
1412 buffer.read(this->micp);
1413 buffer.read(this->vaporized_water);
1414 buffer.read(this->mass_gas);
1417 template <
class MessageBufferType>
1418 void ConnectionFiltrate::read(MessageBufferType& buffer) {
1419 buffer.read(this->rate);
1420 buffer.read(this->total);
1421 buffer.read(this->skin_factor);
1422 buffer.read(this->thickness);
1423 buffer.read(this->perm);
1424 buffer.read(this->poro);
1425 buffer.read(this->radius);
1426 buffer.read(this->area_of_flow);
1429 template <
class MessageBufferType>
1430 void Connection::read(MessageBufferType& buffer) {
1431 buffer.read(this->index);
1432 this->rates.read(buffer);
1433 buffer.read(this->pressure);
1434 buffer.read(this->reservoir_rate);
1435 buffer.read(this->cell_pressure);
1436 buffer.read(this->cell_saturation_water);
1437 buffer.read(this->cell_saturation_gas);
1438 buffer.read(this->effective_Kh);
1439 buffer.read(this->trans_factor);
1440 buffer.read(this->d_factor);
1441 buffer.read(this->compact_mult);
1442 this->filtrate.read(buffer);
1445 template <
class MessageBufferType>
1446 void Segment::read(MessageBufferType& buffer)
1448 buffer.read(this->segNumber);
1449 this->rates.read(buffer);
1450 this->pressures.read(buffer);
1451 this->velocity.read(buffer);
1452 this->holdup.read(buffer);
1453 this->viscosity.read(buffer);
1454 this->density.read(buffer);
1457 template <
class MessageBufferType>
1458 void CurrentControl::read(MessageBufferType& buffer)
1460 buffer.read(this->isProducer);
1461 if (this->isProducer) {
1462 buffer.read(this->prod);
1465 buffer.read(this->inj);
1469 template <
class MessageBufferType>
1470 void WellBlockAvgPress::read(MessageBufferType& buffer)
1472 for (
auto& quantity : this->wbp_) {
1473 buffer.read(quantity);
1477 template <
class MessageBufferType>
1478 void WellFiltrate::read(MessageBufferType& buffer)
1480 buffer.read(this->rate);
1481 buffer.read(this->total);
1482 buffer.read(this->concentration);
1485 template <
class MessageBufferType>
1486 void Well::read(MessageBufferType& buffer)
1488 this->rates.read(buffer);
1490 buffer.read(this->bhp);
1491 buffer.read(this->thp);
1492 buffer.read(this->temperature);
1493 buffer.read(this->control);
1495 this->filtrate.read(buffer);
1498 auto status = std::string{};
1499 buffer.read(status);
1500 this->dynamicStatus = ::Opm::WellStatusFromString(status);
1505 unsigned int size = 0;
1508 this->connections.resize(size);
1509 for (
auto& connection : this->connections) {
1510 connection.read(buffer);
1515 const auto nSeg = [&buffer]() ->
unsigned int
1523 for (
auto segID = 0*nSeg; segID < nSeg; ++segID) {
1524 auto seg = Segment{};
1527 const auto segNumber = seg.segNumber;
1528 this->segments.emplace(segNumber, std::move(seg));
1531 this->current_control.read(buffer);
1532 this->guide_rates.read(buffer);
1533 this->limits.read(buffer);
1536 template <
class MessageBufferType>
1537 void WellBlockAveragePressures::read(MessageBufferType& buffer)
1539 const auto numWells = [&buffer,
this]()
1541 auto size = 0*this->values.size();
1547 auto wellName = std::string{};
1548 for (
auto well = 0*numWells; well < numWells; ++well) {
1549 buffer.read(wellName);
1551 this->values[wellName].read(buffer);
1556 auto json_connections = json_data.add_array(
"connections");
1557 for (
const auto& conn : this->connections) {
1558 auto json_conn = json_connections.add_object();
1559 conn.init_json(json_conn);
1561 auto json_rates = json_data.add_object(
"rates");
1562 this->rates.init_json(json_rates);
1564 json_data.add_item(
"bhp", this->bhp);
1565 json_data.add_item(
"thp", this->thp);
1566 json_data.add_item(
"temperature", this->temperature);
1567 json_data.add_item(
"status", ::Opm::WellStatus2String(this->dynamicStatus));
1569 auto json_control = json_data.add_object(
"control");
1570 this->current_control.init_json(json_control);
1572 auto json_guiderate = json_data.add_object(
"guiderate");
1573 this->guide_rates.init_json(json_guiderate);
Definition JsonObject.hpp:31
Class for (de-)serializing.
Definition Serializer.hpp:91
Definition GuideRateValue.hpp:32
bool flowing() const
Returns true if any of the rates oil, gas, water is nonzero.
Definition Wells.hpp:1196
double get(opt m) const
Read the value indicated by m.
Definition Wells.hpp:1047
Rates & set(opt m, double value)
Set the value specified by m.
Definition Wells.hpp:1068
bool has(opt) const
Query if a value is set.
Definition Wells.hpp:1040
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition Wells.hpp:1010