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>
35#include <unordered_map>
38namespace Opm {
namespace data {
52 enum class opt : uint32_t {
59 dissolved_gas = (1 << 6),
60 vaporized_oil = (1 << 7),
61 reservoir_water = (1 << 8),
62 reservoir_oil = (1 << 9),
63 reservoir_gas = (1 << 10),
64 productivity_index_water = (1 << 11),
65 productivity_index_oil = (1 << 12),
66 productivity_index_gas = (1 << 13),
67 well_potential_water = (1 << 14),
68 well_potential_oil = (1 << 15),
69 well_potential_gas = (1 << 16),
74 vaporized_water = (1 << 21)
77 using enum_size = std::underlying_type< opt >::type;
80 inline bool has( opt )
const;
84 inline double get( opt m )
const;
87 inline double get( opt m,
double default_value )
const;
88 inline double get( opt m,
double default_value ,
const std::string& tracer_name )
const;
92 inline Rates&
set( opt m,
double value );
93 inline Rates&
set( opt m,
double value ,
const std::string& tracer_name );
98 template <
class MessageBufferType>
99 void write(MessageBufferType& buffer)
const;
100 template <
class MessageBufferType>
101 void read(MessageBufferType& buffer);
103 bool operator==(
const Rates& rat2)
const;
107 template<
class Serializer>
117 serializer(dissolved_gas);
118 serializer(vaporized_oil);
119 serializer(reservoir_water);
120 serializer(reservoir_oil);
121 serializer(reservoir_gas);
122 serializer(productivity_index_water);
123 serializer(productivity_index_oil);
124 serializer(productivity_index_gas);
125 serializer(well_potential_water);
126 serializer(well_potential_oil);
127 serializer(well_potential_gas);
132 serializer(vaporized_water);
135 static Rates serializationTestObject()
138 rat1.
set(opt::wat, 1.0);
139 rat1.
set(opt::oil, 2.0);
140 rat1.
set(opt::gas, 3.0);
141 rat1.
set(opt::polymer, 4.0);
142 rat1.
set(opt::solvent, 5.0);
143 rat1.
set(opt::energy, 6.0);
144 rat1.
set(opt::dissolved_gas, 7.0);
145 rat1.
set(opt::vaporized_oil, 8.0);
146 rat1.
set(opt::reservoir_water, 9.0);
147 rat1.
set(opt::reservoir_oil, 10.0);
148 rat1.
set(opt::reservoir_gas, 11.0);
149 rat1.
set(opt::productivity_index_water, 12.0);
150 rat1.
set(opt::productivity_index_oil, 13.0);
151 rat1.
set(opt::productivity_index_gas, 14.0);
152 rat1.
set(opt::well_potential_water, 15.0);
153 rat1.
set(opt::well_potential_oil, 16.0);
154 rat1.
set(opt::well_potential_gas, 17.0);
155 rat1.
set(opt::brine, 18.0);
156 rat1.
set(opt::alq, 19.0);
157 rat1.
set(opt::micp, 21.0);
158 rat1.
set(opt::vaporized_water, 22.0);
159 rat1.tracer.insert({
"test_tracer", 1.0});
165 double& get_ref( opt );
166 double& get_ref( opt,
const std::string& tracer_name );
167 const double& get_ref( opt )
const;
168 const double& get_ref( opt,
const std::string& tracer_name )
const;
170 opt mask =
static_cast< opt
>( 0 );
175 double polymer = 0.0;
176 double solvent = 0.0;
178 double dissolved_gas = 0.0;
179 double vaporized_oil = 0.0;
180 double reservoir_water = 0.0;
181 double reservoir_oil = 0.0;
182 double reservoir_gas = 0.0;
183 double productivity_index_water = 0.0;
184 double productivity_index_oil = 0.0;
185 double productivity_index_gas = 0.0;
186 double well_potential_water = 0.0;
187 double well_potential_oil = 0.0;
188 double well_potential_gas = 0.0;
191 std::map<std::string, double> tracer;
193 double vaporized_water = 0.0;
206 template<
class Serializer>
210 serializer(skin_factor);
211 serializer(thickness);
215 serializer(area_of_flow);
220 return this->rate == filtrate.rate &&
221 this->total == filtrate.total &&
222 this->skin_factor == filtrate.skin_factor &&
223 this->thickness == filtrate.thickness &&
224 this->perm == filtrate.perm &&
225 this->poro == filtrate.poro &&
226 this->radius == filtrate.radius &&
227 this->area_of_flow == filtrate.area_of_flow;
232 return {0.8, 100., -1., 2., 1.e-9,
236 template <
class MessageBufferType>
237 void write(MessageBufferType& buffer)
const;
239 template <
class MessageBufferType>
240 void read(MessageBufferType& buffer);
244 using global_index = size_t;
245 static const constexpr int restart_size = 6;
250 double reservoir_rate;
251 double cell_pressure;
252 double cell_saturation_water;
253 double cell_saturation_gas;
257 double compact_mult{1.0};
261 bool operator==(
const Connection& conn2)
const
263 return (index == conn2.index)
264 && (rates == conn2.rates)
265 && (pressure == conn2.pressure)
266 && (reservoir_rate == conn2.reservoir_rate)
267 && (cell_pressure == conn2.cell_pressure)
268 && (cell_saturation_water == conn2.cell_saturation_water)
269 && (cell_saturation_gas == conn2.cell_saturation_gas)
270 && (effective_Kh == conn2.effective_Kh)
271 && (trans_factor == conn2.trans_factor)
272 && (d_factor == conn2.d_factor)
273 && (compact_mult == conn2.compact_mult)
274 && (filtrate == conn2.filtrate)
278 template <
class MessageBufferType>
279 void write(MessageBufferType& buffer)
const;
280 template <
class MessageBufferType>
281 void read(MessageBufferType& buffer);
285 template<
class Serializer>
290 serializer(pressure);
291 serializer(reservoir_rate);
292 serializer(cell_pressure);
293 serializer(cell_saturation_water);
294 serializer(cell_saturation_gas);
295 serializer(effective_Kh);
296 serializer(trans_factor);
297 serializer(d_factor);
298 serializer(compact_mult);
299 serializer(filtrate);
305 1, Rates::serializationTestObject(),
307 6.0, 7.0, 8.0, 9.0, 0.987,
308 ConnectionFiltrate::serializationTestObject()
315 enum class Value : std::size_t {
316 Pressure, PDrop, PDropHydrostatic, PDropAccel, PDropFriction,
319 double& operator[](
const Value i)
321 return this->values_[this->index(i)];
324 double operator[](
const Value i)
const
326 return this->values_[this->index(i)];
331 return this->values_ == segpres2.values_;
334 template <
class MessageBufferType>
335 void write(MessageBufferType& buffer)
const
337 for (
const auto& value : this->values_) {
342 template <
class MessageBufferType>
343 void read(MessageBufferType& buffer)
345 for (
auto& value : this->values_) {
350 template<
class Serializer>
359 spres[Value::Pressure] = 1.0;
360 spres[Value::PDrop] = 2.0;
361 spres[Value::PDropHydrostatic] = 3.0;
362 spres[Value::PDropAccel] = 4.0;
363 spres[Value::PDropFriction] = 5.0;
369 constexpr static std::size_t numvals = 5;
371 std::array<double, numvals> values_ = {0};
373 std::size_t index(
const Value ix)
const
375 return static_cast<std::size_t
>(ix);
379 template <
typename Items>
383 using Item =
typename Items::Item;
387 this->has_ =
static_cast<unsigned char>(0);
388 this->value_.fill(0.0);
391 constexpr bool has(
const Item p)
const
393 const auto i = this->index(p);
395 return (i < Size) && this->hasItem(i);
400 return (this->has_ == vec.has_)
401 && (this->value_ == vec.value_);
404 double get(
const Item p)
const
406 if (! this->has(p)) {
407 throw std::invalid_argument {
408 "Request for Unset Item Value for " + Items::itemName(p)
412 return this->value_[ this->index(p) ];
417 const auto i = this->index(p);
420 throw std::invalid_argument {
421 "Cannot Assign Item Value for Unsupported Item '"
422 + Items::itemName(p) +
'\''
426 this->has_ |= 1 << i;
427 this->value_[i] = value;
432 template <
class MessageBufferType>
433 void write(MessageBufferType& buffer)
const
435 buffer.write(this->has_);
437 for (
const auto& x : this->value_) {
442 template <
class MessageBufferType>
443 void read(MessageBufferType& buffer)
446 buffer.read(this->has_);
448 for (
auto& x : this->value_) {
453 template <
class Serializer>
456 serializer(this->has_);
457 serializer(this->value_);
464 for (
const auto& [item, value] : Items::serializationTestItems()) {
465 quant.set(item, value);
472 enum { Size =
static_cast<std::size_t
>(Item::NumItems) };
476 unsigned char has_{};
479 std::array<double, Size> value_{};
481 constexpr std::size_t index(
const Item p)
const noexcept
483 return static_cast<std::size_t
>(p);
486 bool hasItem(
const std::size_t i)
const
488 return (this->has_ & (1 << i)) != 0;
501 static std::string itemName(
const Item p)
504 case Item::Oil:
return "Oil";
505 case Item::Gas:
return "Gas";
506 case Item::Water:
return "Water";
509 return "Out of bounds (NumItems)";
512 return "Unknown (" + std::to_string(
static_cast<int>(p)) +
')';
515 static auto serializationTestItems()
518 std::pair { Item::Oil , 1.0 },
519 std::pair { Item::Gas , 7.0 },
520 std::pair { Item::Water, 2.9 },
528 Oil, Gas, Water, Mixture, MixtureWithExponents,
534 static std::string itemName(
const Item p)
537 case Item::Oil:
return "Oil";
538 case Item::Gas:
return "Gas";
539 case Item::Water:
return "Water";
540 case Item::Mixture:
return "Mixture";
541 case Item::MixtureWithExponents:
return "MixtureWithExponents";
544 return "Out of bounds (NumItems)";
547 return "Unknown (" + std::to_string(
static_cast<int>(p)) +
')';
550 static auto serializationTestItems()
553 std::pair { Item::Oil , 876.54 },
554 std::pair { Item::Gas , 321.09 },
555 std::pair { Item::Water , 987.65 },
556 std::pair { Item::Mixture , 975.31 },
557 std::pair { Item::MixtureWithExponents, 765.43 },
573 std::size_t segNumber{};
575 bool operator==(
const Segment& seg2)
const
577 return (rates == seg2.rates)
578 && (pressures == seg2.pressures)
579 && (velocity == seg2.velocity)
580 && (holdup == seg2.holdup)
581 && (viscosity == seg2.viscosity)
582 && (density == seg2.density)
583 && (segNumber == seg2.segNumber);
586 template <
class MessageBufferType>
587 void write(MessageBufferType& buffer)
const;
589 template <
class MessageBufferType>
590 void read(MessageBufferType& buffer);
592 template <
class Serializer>
595 serializer(this->rates);
596 serializer(this->pressures);
597 serializer(this->velocity);
598 serializer(this->holdup);
599 serializer(this->viscosity);
600 serializer(this->density);
601 serializer(this->segNumber);
604 static Segment serializationTestObject()
607 Rates::serializationTestObject(),
608 SegmentPressures::serializationTestObject(),
609 SegmentPhaseQuantity::serializationTestObject(),
610 SegmentPhaseQuantity::serializationTestObject(),
611 SegmentPhaseQuantity::serializationTestObject(),
612 SegmentPhaseDensity::serializationTestObject(),
619 bool isProducer{
true};
621 ::Opm::WellProducerCMode prod {
622 ::Opm::WellProducerCMode::CMODE_UNDEFINED
625 ::Opm::WellInjectorCMode inj {
626 ::Opm::WellInjectorCMode::CMODE_UNDEFINED
631 return (this->isProducer == rhs.isProducer)
632 && ((this->isProducer && (this->prod == rhs.prod)) ||
633 (!this->isProducer && (this->inj == rhs.inj)));
638 if (this->inj == ::Opm::WellInjectorCMode::CMODE_UNDEFINED)
639 json_data.add_item(
"inj",
"CMODE_UNDEFINED");
641 json_data.add_item(
"inj", ::Opm::WellInjectorCMode2String(this->inj));
643 if (this->prod == ::Opm::WellProducerCMode::CMODE_UNDEFINED)
644 json_data.add_item(
"prod",
"CMODE_UNDEFINED");
646 json_data.add_item(
"prod", ::Opm::WellProducerCMode2String(this->prod));
649 template <
class MessageBufferType>
650 void write(MessageBufferType& buffer)
const;
652 template <
class MessageBufferType>
653 void read(MessageBufferType& buffer);
655 template<
class Serializer>
658 serializer(isProducer);
666 ::Opm::WellProducerCMode::BHP,
667 ::Opm::WellInjectorCMode::GRUP
675 enum class Quantity { WBP, WBP4, WBP5, WBP9 };
677 double& operator[](
const Quantity q)
679 return this->wbp_[
static_cast<std::size_t
>(q)];
682 double operator[](
const Quantity q)
const
684 return this->wbp_[
static_cast<std::size_t
>(q)];
689 return this->wbp_ == that.wbp_;
692 template <
class MessageBufferType>
693 void write(MessageBufferType& buffer)
const;
695 template <
class MessageBufferType>
696 void read(MessageBufferType& buffer);
698 template <
class Serializer>
701 serializer(this->wbp_);
708 wbp[Quantity::WBP] = 17.29;
709 wbp[Quantity::WBP4] = 2.718;
710 wbp[Quantity::WBP5] = 3.1415;
711 wbp[Quantity::WBP9] = 1.618;
717 static constexpr auto NumQuantities =
718 static_cast<std::size_t
>(Quantity::WBP9) + 1;
720 std::array<double, NumQuantities> wbp_{};
726 double concentration{0.};
728 template<
class Serializer>
732 serializer(concentration);
736 return this->rate == filtrate.rate
737 && this->total == filtrate.total
738 && this->concentration == filtrate.concentration;
745 res.concentration = 0.;
749 template <
class MessageBufferType>
750 void write(MessageBufferType& buffer)
const;
752 template <
class MessageBufferType>
753 void read(MessageBufferType& buffer);
760 double temperature{0.0};
765 ::Opm::WellStatus dynamicStatus { Opm::WellStatus::OPEN };
767 std::vector< Connection > connections{};
768 std::unordered_map<std::size_t, Segment> segments{};
772 inline bool flowing()
const noexcept;
773 template <
class MessageBufferType>
774 void write(MessageBufferType& buffer)
const;
775 template <
class MessageBufferType>
776 void read(MessageBufferType& buffer);
780 const Connection* find_connection(Connection::global_index connection_grid_index)
const {
781 const auto connection = std::find_if( this->connections.begin() ,
782 this->connections.end() ,
784 return c.index == connection_grid_index; });
786 if( connection == this->connections.end() )
792 Connection* find_connection(Connection::global_index connection_grid_index) {
793 auto connection = std::find_if( this->connections.begin() ,
794 this->connections.end() ,
796 return c.index == connection_grid_index; });
798 if( connection == this->connections.end() )
804 bool operator==(
const Well& well2)
const
806 return (this->rates == well2.rates)
807 && (this->bhp == well2.bhp)
808 && (this->thp == well2.thp)
809 && (this->temperature == well2.temperature)
810 && (this->filtrate == well2.filtrate)
811 && (this->control == well2.control)
812 && (this->dynamicStatus == well2.dynamicStatus)
813 && (this->connections == well2.connections)
814 && (this->segments == well2.segments)
815 && (this->current_control == well2.current_control)
816 && (this->guide_rates == well2.guide_rates)
820 template<
class Serializer>
826 serializer(temperature);
828 serializer(filtrate);
829 serializer(dynamicStatus);
830 serializer(connections);
831 serializer(segments);
832 serializer(current_control);
833 serializer(guide_rates);
836 static Well serializationTestObject()
839 Rates::serializationTestObject(),
844 WellFiltrate::serializationTestObject(),
845 ::Opm::WellStatus::SHUT,
846 {Connection::serializationTestObject()},
847 {{0, Segment::serializationTestObject()}},
848 CurrentControl::serializationTestObject(),
849 GuideRateValue::serializationTestObject()
854 class Wells:
public std::map<std::string , Well> {
857 double get(
const std::string& well_name , Rates::opt m)
const {
858 const auto& well = this->find( well_name );
859 if( well == this->end() )
return 0.0;
861 return well->second.rates.get( m, 0.0 );
864 double get(
const std::string& well_name , Rates::opt m,
const std::string& tracer_name)
const {
865 const auto& well = this->find( well_name );
866 if( well == this->end() )
return 0.0;
868 return well->second.rates.get( m, 0.0, tracer_name);
871 double get(
const std::string& well_name , Connection::global_index connection_grid_index, Rates::opt m)
const {
872 const auto& witr = this->find( well_name );
873 if( witr == this->end() )
return 0.0;
875 const auto& well = witr->second;
876 const auto& connection = std::find_if( well.connections.begin() ,
877 well.connections.end() ,
879 return c.index == connection_grid_index; });
881 if( connection == well.connections.end() )
884 return connection->rates.get( m, 0.0 );
887 template <
class MessageBufferType>
888 void write(MessageBufferType& buffer)
const {
889 unsigned int size = this->size();
891 for (
const auto& witr : *
this) {
892 const std::string& name = witr.first;
894 const Well& well = witr.second;
899 template <
class MessageBufferType>
900 void read(MessageBufferType& buffer) {
903 for (
size_t i = 0; i < size; ++i) {
908 this->emplace(name, well);
913 for (
const auto& [wname, well] : *
this) {
914 auto json_well = json_data.add_object(wname);
915 well.init_json(json_well);
922 this->init_json(json_data);
926 template<
class Serializer>
929 serializer(
static_cast<std::map<std::string,Well>&
>(*
this));
932 static Wells serializationTestObject()
935 w.insert({
"test_well", Well::serializationTestObject()});
943 std::unordered_map<std::string, WellBlockAvgPress> values{};
945 template <
class MessageBufferType>
946 void write(MessageBufferType& buffer)
const;
948 template <
class MessageBufferType>
949 void read(MessageBufferType& buffer);
953 return this->values == that.values;
956 template <
class Serializer>
959 serializer(this->values);
965 { {
"I-45", WellBlockAvgPress::serializationTestObject() } },
973 const auto mand =
static_cast< enum_size
>( this->mask )
974 &
static_cast< enum_size
>( m );
976 return static_cast< opt
>( mand ) == m;
980 if( !this->
has( m ) )
981 throw std::invalid_argument(
"Uninitialized value." );
983 return this->get_ref( m );
986 inline double Rates::get( opt m,
double default_value )
const {
987 if( !this->
has( m ) )
return default_value;
989 return this->get_ref( m );
992 inline double Rates::get( opt m,
double default_value,
const std::string& tracer_name)
const {
993 if( !this->
has( m ) )
return default_value;
995 if( m == opt::tracer && this->tracer.find(tracer_name) == this->tracer.end())
return default_value;
997 return this->get_ref( m, tracer_name);
1001 this->get_ref( m ) = value;
1004 this->mask =
static_cast< opt
>(
1005 static_cast< enum_size
>( this->mask ) |
1006 static_cast< enum_size
>( m )
1012 inline Rates&
Rates::set( opt m,
double value ,
const std::string& tracer_name ) {
1013 this->get_ref( m , tracer_name) = value;
1016 this->mask =
static_cast< opt
>(
1017 static_cast< enum_size
>( this->mask ) |
1018 static_cast< enum_size
>( m )
1024 inline bool Rates::operator==(
const Rates& rate)
const
1026 return mask == rate.mask &&
1030 polymer == rate.polymer &&
1031 solvent == rate.solvent &&
1032 energy == rate.energy &&
1033 dissolved_gas == rate.dissolved_gas &&
1034 vaporized_oil == rate.vaporized_oil &&
1035 reservoir_water == rate.reservoir_water &&
1036 reservoir_oil == rate.reservoir_oil &&
1037 reservoir_gas == rate.reservoir_gas &&
1038 productivity_index_water == rate.productivity_index_water &&
1039 productivity_index_gas == rate.productivity_index_gas &&
1040 productivity_index_oil == rate.productivity_index_oil &&
1041 well_potential_water == rate.well_potential_water &&
1042 well_potential_oil == rate.well_potential_oil &&
1043 well_potential_gas == rate.well_potential_gas &&
1044 brine == rate.brine &&
1046 tracer == rate.tracer &&
1047 micp == rate.micp &&
1048 vaporized_water == rate.vaporized_water;
1061 inline const double& Rates::get_ref( opt m )
const {
1063 case opt::wat:
return this->wat;
1064 case opt::oil:
return this->oil;
1065 case opt::gas:
return this->gas;
1066 case opt::polymer:
return this->polymer;
1067 case opt::solvent:
return this->solvent;
1068 case opt::energy:
return this->energy;
1069 case opt::dissolved_gas:
return this->dissolved_gas;
1070 case opt::vaporized_oil:
return this->vaporized_oil;
1071 case opt::reservoir_water:
return this->reservoir_water;
1072 case opt::reservoir_oil:
return this->reservoir_oil;
1073 case opt::reservoir_gas:
return this->reservoir_gas;
1074 case opt::productivity_index_water:
return this->productivity_index_water;
1075 case opt::productivity_index_oil:
return this->productivity_index_oil;
1076 case opt::productivity_index_gas:
return this->productivity_index_gas;
1077 case opt::well_potential_water:
return this->well_potential_water;
1078 case opt::well_potential_oil:
return this->well_potential_oil;
1079 case opt::well_potential_gas:
return this->well_potential_gas;
1080 case opt::brine:
return this->brine;
1081 case opt::alq:
return this->alq;
1084 case opt::micp:
return this->micp;
1085 case opt::vaporized_water:
return this->vaporized_water;
1088 throw std::invalid_argument(
1089 "Unknown value type '"
1090 + std::to_string(
static_cast< enum_size
>( m ) )
1095 inline const double& Rates::get_ref( opt m,
const std::string& tracer_name )
const {
1096 if (m != opt::tracer)
1097 throw std::logic_error(
"Logic error - should be called with tracer argument");
1099 return this->tracer.at(tracer_name);
1102 inline double& Rates::get_ref( opt m ) {
1103 return const_cast< double&
>(
1104 static_cast< const Rates*
>( this )->get_ref( m )
1108 inline double& Rates::get_ref( opt m,
const std::string& tracer_name ) {
1109 if (m == opt::tracer) this->tracer.emplace(tracer_name, 0.0);
1110 return this->tracer.at(tracer_name);
1115 if (this->
has(opt::wat))
1116 json_data.add_item(
"wat", this->
get(opt::wat));
1118 if (this->
has(opt::oil))
1119 json_data.add_item(
"oil", this->
get(opt::oil));
1121 if (this->
has(opt::gas))
1122 json_data.add_item(
"gas", this->
get(opt::gas));
1127 return ((this->wat != 0) ||
1132 inline bool Well::flowing() const noexcept {
1136 template <
class MessageBufferType>
1137 void Rates::write(MessageBufferType& buffer)
const {
1138 buffer.write(this->mask);
1139 buffer.write(this->wat);
1140 buffer.write(this->oil);
1141 buffer.write(this->gas);
1142 buffer.write(this->polymer);
1143 buffer.write(this->solvent);
1144 buffer.write(this->energy);
1145 buffer.write(this->dissolved_gas);
1146 buffer.write(this->vaporized_oil);
1147 buffer.write(this->reservoir_water);
1148 buffer.write(this->reservoir_oil);
1149 buffer.write(this->reservoir_gas);
1150 buffer.write(this->productivity_index_water);
1151 buffer.write(this->productivity_index_oil);
1152 buffer.write(this->productivity_index_gas);
1153 buffer.write(this->well_potential_water);
1154 buffer.write(this->well_potential_oil);
1155 buffer.write(this->well_potential_gas);
1156 buffer.write(this->brine);
1157 buffer.write(this->alq);
1159 unsigned int size = this->tracer.size();
1161 for (
const auto& [name, rate] : this->tracer) {
1165 buffer.write(this->micp);
1166 buffer.write(this->vaporized_water);
1169 template <
class MessageBufferType>
1170 void ConnectionFiltrate::write(MessageBufferType& buffer)
const {
1171 buffer.write(this->rate);
1172 buffer.write(this->total);
1173 buffer.write(this->skin_factor);
1174 buffer.write(this->thickness);
1175 buffer.write(this->perm);
1176 buffer.write(this->poro);
1177 buffer.write(this->radius);
1178 buffer.write(this->area_of_flow);
1181 template <
class MessageBufferType>
1182 void Connection::write(MessageBufferType& buffer)
const {
1183 buffer.write(this->index);
1184 this->rates.write(buffer);
1185 buffer.write(this->pressure);
1186 buffer.write(this->reservoir_rate);
1187 buffer.write(this->cell_pressure);
1188 buffer.write(this->cell_saturation_water);
1189 buffer.write(this->cell_saturation_gas);
1190 buffer.write(this->effective_Kh);
1191 buffer.write(this->trans_factor);
1192 buffer.write(this->d_factor);
1193 buffer.write(this->compact_mult);
1194 this->filtrate.write(buffer);
1198 auto json_rates = json_data.add_object(
"rates");
1199 this->rates.init_json(json_rates);
1201 json_data.add_item(
"global_index",
static_cast<int>(this->index));
1202 json_data.add_item(
"pressure", this->pressure);
1203 json_data.add_item(
"reservoir_rate", this->reservoir_rate);
1204 json_data.add_item(
"cell_pressure", this->cell_pressure);
1205 json_data.add_item(
"swat", this->cell_saturation_water);
1206 json_data.add_item(
"sgas", this->cell_saturation_gas);
1207 json_data.add_item(
"Kh", this->effective_Kh);
1208 json_data.add_item(
"trans_factor", this->trans_factor);
1209 json_data.add_item(
"d_factor", this->d_factor);
1210 json_data.add_item(
"compact_mult", this->compact_mult);
1213 template <
class MessageBufferType>
1214 void Segment::write(MessageBufferType& buffer)
const
1216 buffer.write(this->segNumber);
1217 this->rates.write(buffer);
1218 this->pressures.write(buffer);
1219 this->velocity.write(buffer);
1220 this->holdup.write(buffer);
1221 this->viscosity.write(buffer);
1222 this->density.write(buffer);
1225 template <
class MessageBufferType>
1226 void CurrentControl::write(MessageBufferType& buffer)
const
1228 buffer.write(this->isProducer);
1229 if (this->isProducer) {
1230 buffer.write(this->prod);
1233 buffer.write(this->inj);
1237 template <
class MessageBufferType>
1238 void WellBlockAvgPress::write(MessageBufferType& buffer)
const
1240 for (
const auto& quantity : this->wbp_) {
1241 buffer.write(quantity);
1245 template <
class MessageBufferType>
1246 void WellFiltrate::write(MessageBufferType& buffer)
const
1248 buffer.write(this->rate);
1249 buffer.write(this->total);
1250 buffer.write(this->concentration);
1253 template <
class MessageBufferType>
1254 void Well::write(MessageBufferType& buffer)
const {
1255 this->rates.write(buffer);
1256 buffer.write(this->bhp);
1257 buffer.write(this->thp);
1258 buffer.write(this->temperature);
1259 buffer.write(this->control);
1260 this->filtrate.write(buffer);
1263 const auto status = ::Opm::WellStatus2String(this->dynamicStatus);
1264 buffer.write(status);
1267 unsigned int size = this->connections.size();
1269 for (
const Connection& comp : this->connections)
1274 static_cast<unsigned int>(this->segments.size());
1277 for (
const auto& seg : this->segments) {
1278 seg.second.write(buffer);
1282 this->current_control.write(buffer);
1283 this->guide_rates.write(buffer);
1286 template <
class MessageBufferType>
1287 void WellBlockAveragePressures::write(MessageBufferType& buffer)
const
1289 buffer.write(this->values.size());
1291 for (
const auto& [well, value] : this->values) {
1293 value.write(buffer);
1297 template <
class MessageBufferType>
1298 void Rates::read(MessageBufferType& buffer) {
1299 buffer.read(this->mask);
1300 buffer.read(this->wat);
1301 buffer.read(this->oil);
1302 buffer.read(this->gas);
1303 buffer.read(this->polymer);
1304 buffer.read(this->solvent);
1305 buffer.read(this->energy);
1306 buffer.read(this->dissolved_gas);
1307 buffer.read(this->vaporized_oil);
1308 buffer.read(this->reservoir_water);
1309 buffer.read(this->reservoir_oil);
1310 buffer.read(this->reservoir_gas);
1311 buffer.read(this->productivity_index_water);
1312 buffer.read(this->productivity_index_oil);
1313 buffer.read(this->productivity_index_gas);
1314 buffer.read(this->well_potential_water);
1315 buffer.read(this->well_potential_oil);
1316 buffer.read(this->well_potential_gas);
1317 buffer.read(this->brine);
1318 buffer.read(this->alq);
1322 for (
size_t i = 0; i < size; ++i) {
1323 std::string tracer_name;
1324 buffer.read(tracer_name);
1326 buffer.read(tracer_rate);
1327 this->tracer.emplace(tracer_name, tracer_rate);
1329 buffer.read(this->micp);
1330 buffer.read(this->vaporized_water);
1333 template <
class MessageBufferType>
1334 void ConnectionFiltrate::read(MessageBufferType& buffer) {
1335 buffer.read(this->rate);
1336 buffer.read(this->total);
1337 buffer.read(this->skin_factor);
1338 buffer.read(this->thickness);
1339 buffer.read(this->perm);
1340 buffer.read(this->poro);
1341 buffer.read(this->radius);
1342 buffer.read(this->area_of_flow);
1345 template <
class MessageBufferType>
1346 void Connection::read(MessageBufferType& buffer) {
1347 buffer.read(this->index);
1348 this->rates.read(buffer);
1349 buffer.read(this->pressure);
1350 buffer.read(this->reservoir_rate);
1351 buffer.read(this->cell_pressure);
1352 buffer.read(this->cell_saturation_water);
1353 buffer.read(this->cell_saturation_gas);
1354 buffer.read(this->effective_Kh);
1355 buffer.read(this->trans_factor);
1356 buffer.read(this->d_factor);
1357 buffer.read(this->compact_mult);
1358 this->filtrate.read(buffer);
1361 template <
class MessageBufferType>
1362 void Segment::read(MessageBufferType& buffer)
1364 buffer.read(this->segNumber);
1365 this->rates.read(buffer);
1366 this->pressures.read(buffer);
1367 this->velocity.read(buffer);
1368 this->holdup.read(buffer);
1369 this->viscosity.read(buffer);
1370 this->density.read(buffer);
1373 template <
class MessageBufferType>
1374 void CurrentControl::read(MessageBufferType& buffer)
1376 buffer.read(this->isProducer);
1377 if (this->isProducer) {
1378 buffer.read(this->prod);
1381 buffer.read(this->inj);
1385 template <
class MessageBufferType>
1386 void WellBlockAvgPress::read(MessageBufferType& buffer)
1388 for (
auto& quantity : this->wbp_) {
1389 buffer.read(quantity);
1393 template <
class MessageBufferType>
1394 void WellFiltrate::read(MessageBufferType& buffer)
1396 buffer.read(this->rate);
1397 buffer.read(this->total);
1398 buffer.read(this->concentration);
1401 template <
class MessageBufferType>
1402 void Well::read(MessageBufferType& buffer) {
1403 this->rates.read(buffer);
1404 buffer.read(this->bhp);
1405 buffer.read(this->thp);
1406 buffer.read(this->temperature);
1407 buffer.read(this->control);
1408 this->filtrate.read(buffer);
1411 auto status = std::string{};
1412 buffer.read(status);
1413 this->dynamicStatus = ::Opm::WellStatusFromString(status);
1417 unsigned int size = 0.0;
1419 this->connections.resize(size);
1420 for (
size_t i = 0; i < size; ++i)
1422 auto& comp = this->connections[ i ];
1427 const auto nSeg = [&buffer]() ->
unsigned int
1435 for (
auto segID = 0*nSeg; segID < nSeg; ++segID) {
1436 auto seg = Segment{};
1439 const auto segNumber = seg.segNumber;
1440 this->segments.emplace(segNumber, std::move(seg));
1443 this->current_control.read(buffer);
1444 this->guide_rates.read(buffer);
1447 template <
class MessageBufferType>
1448 void WellBlockAveragePressures::read(MessageBufferType& buffer)
1450 const auto numWells = [&buffer,
this]()
1452 auto size = 0*this->values.size();
1458 auto wellName = std::string{};
1459 for (
auto well = 0*numWells; well < numWells; ++well) {
1460 buffer.read(wellName);
1462 this->values[wellName].read(buffer);
1467 auto json_connections = json_data.add_array(
"connections");
1468 for (
const auto& conn : this->connections) {
1469 auto json_conn = json_connections.add_object();
1470 conn.init_json(json_conn);
1472 auto json_rates = json_data.add_object(
"rates");
1473 this->rates.init_json(json_rates);
1475 json_data.add_item(
"bhp", this->bhp);
1476 json_data.add_item(
"thp", this->thp);
1477 json_data.add_item(
"temperature", this->temperature);
1478 json_data.add_item(
"status", ::Opm::WellStatus2String(this->dynamicStatus));
1480 auto json_control = json_data.add_object(
"control");
1481 this->current_control.init_json(json_control);
1483 auto json_guiderate = json_data.add_object(
"guiderate");
1484 this->guide_rates.init_json(json_guiderate);
Definition JsonObject.hpp:31
Class for (de-)serializing.
Definition Serializer.hpp:84
Definition GuideRateValue.hpp:32
bool flowing() const
Returns true if any of the rates oil, gas, water is nonzero.
Definition Wells.hpp:1126
double get(opt m) const
Read the value indicated by m.
Definition Wells.hpp:979
Rates & set(opt m, double value)
Set the value specified by m.
Definition Wells.hpp:1000
bool has(opt) const
Query if a value is set.
Definition Wells.hpp:972
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30