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>
31#include <initializer_list>
36#include <unordered_map>
55 enum class opt : uint32_t {
62 dissolved_gas = (1 << 6),
63 vaporized_oil = (1 << 7),
64 reservoir_water = (1 << 8),
65 reservoir_oil = (1 << 9),
66 reservoir_gas = (1 << 10),
67 productivity_index_water = (1 << 11),
68 productivity_index_oil = (1 << 12),
69 productivity_index_gas = (1 << 13),
70 well_potential_water = (1 << 14),
71 well_potential_oil = (1 << 15),
72 well_potential_gas = (1 << 16),
77 vaporized_water = (1 << 21)
80 using enum_size = std::underlying_type< opt >::type;
83 inline bool has( opt )
const;
87 inline double get( opt m )
const;
90 inline double get( opt m,
double default_value )
const;
91 inline double get( opt m,
double default_value ,
const std::string& tracer_name )
const;
95 inline Rates&
set( opt m,
double value );
96 inline Rates&
set( opt m,
double value ,
const std::string& tracer_name );
101 template <
class MessageBufferType>
102 void write(MessageBufferType& buffer)
const;
103 template <
class MessageBufferType>
104 void read(MessageBufferType& buffer);
106 bool operator==(
const Rates& rat2)
const;
110 template<
class Serializer>
120 serializer(dissolved_gas);
121 serializer(vaporized_oil);
122 serializer(reservoir_water);
123 serializer(reservoir_oil);
124 serializer(reservoir_gas);
125 serializer(productivity_index_water);
126 serializer(productivity_index_oil);
127 serializer(productivity_index_gas);
128 serializer(well_potential_water);
129 serializer(well_potential_oil);
130 serializer(well_potential_gas);
135 serializer(vaporized_water);
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.tracer.insert({
"test_tracer", 1.0});
168 double& get_ref( opt );
169 double& get_ref( opt,
const std::string& tracer_name );
170 const double& get_ref( opt )
const;
171 const double& get_ref( opt,
const std::string& tracer_name )
const;
173 opt mask =
static_cast< opt
>( 0 );
178 double polymer = 0.0;
179 double solvent = 0.0;
181 double dissolved_gas = 0.0;
182 double vaporized_oil = 0.0;
183 double reservoir_water = 0.0;
184 double reservoir_oil = 0.0;
185 double reservoir_gas = 0.0;
186 double productivity_index_water = 0.0;
187 double productivity_index_oil = 0.0;
188 double productivity_index_gas = 0.0;
189 double well_potential_water = 0.0;
190 double well_potential_oil = 0.0;
191 double well_potential_gas = 0.0;
194 std::map<std::string, double> tracer;
196 double vaporized_water = 0.0;
200 using global_index = size_t;
201 static const constexpr int restart_size = 6;
206 double reservoir_rate;
207 double cell_pressure;
208 double cell_saturation_water;
209 double cell_saturation_gas;
213 bool operator==(
const Connection& conn2)
const
215 return index == conn2.index &&
216 rates == conn2.rates &&
217 pressure == conn2.pressure &&
218 reservoir_rate == conn2.reservoir_rate &&
219 cell_pressure == conn2.cell_pressure &&
220 cell_saturation_water == conn2.cell_saturation_water &&
221 cell_saturation_gas == conn2.cell_saturation_gas &&
222 effective_Kh == conn2.effective_Kh &&
223 trans_factor == conn2.trans_factor;
226 template <
class MessageBufferType>
227 void write(MessageBufferType& buffer)
const;
228 template <
class MessageBufferType>
229 void read(MessageBufferType& buffer);
233 template<
class Serializer>
238 serializer(pressure);
239 serializer(reservoir_rate);
240 serializer(cell_pressure);
241 serializer(cell_saturation_water);
242 serializer(cell_saturation_gas);
243 serializer(effective_Kh);
244 serializer(trans_factor);
249 return Connection{1, Rates::serializationTestObject(),
257 enum class Value : std::size_t {
258 Pressure, PDrop, PDropHydrostatic, PDropAccel, PDropFriction,
261 double& operator[](
const Value i)
263 return this->values_[this->index(i)];
266 double operator[](
const Value i)
const
268 return this->values_[this->index(i)];
273 return this->values_ == segpres2.values_;
276 template <
class MessageBufferType>
277 void write(MessageBufferType& buffer)
const
279 for (
const auto& value : this->values_) {
284 template <
class MessageBufferType>
285 void read(MessageBufferType& buffer)
287 for (
auto& value : this->values_) {
292 template<
class Serializer>
301 spres[Value::Pressure] = 1.0;
302 spres[Value::PDrop] = 2.0;
303 spres[Value::PDropHydrostatic] = 3.0;
304 spres[Value::PDropAccel] = 4.0;
305 spres[Value::PDropFriction] = 5.0;
311 constexpr static std::size_t numvals = 5;
313 std::array<double, numvals> values_ = {0};
315 std::size_t index(
const Value ix)
const
317 return static_cast<std::size_t
>(ix);
324 enum class Item : std::size_t {
333 this->has_ =
static_cast<unsigned char>(0);
334 this->value_.fill(0.0);
337 constexpr bool has(
const Item p)
const
339 const auto i = this->index(p);
341 return (i < Size) && this->hasItem(i);
346 return (this->has_ == vec.has_)
347 && (this->value_ == vec.value_);
350 double get(
const Item p)
const
352 if (! this->has(p)) {
353 throw std::invalid_argument {
354 "Request for Unset Item Value for " + this->itemName(p)
358 return this->value_[ this->index(p) ];
363 const auto i = this->index(p);
366 throw std::invalid_argument {
367 "Cannot Assign Item Value for Unsupported Item '"
368 + this->itemName(p) +
'\''
372 this->has_ |= 1 << i;
373 this->value_[i] = value;
378 template <
class MessageBufferType>
379 void write(MessageBufferType& buffer)
const
381 buffer.write(this->has_);
383 for (
const auto& x : this->value_) {
388 template <
class MessageBufferType>
389 void read(MessageBufferType& buffer)
392 buffer.read(this->has_);
394 for (
auto& x : this->value_) {
399 template <
class Serializer>
402 serializer(this->has_);
403 serializer(this->value_);
409 .set(Item::Oil , 1.0)
410 .set(Item::Gas , 7.0)
411 .set(Item::Water, 2.9);
415 enum { Size =
static_cast<std::size_t
>(Item::NumItems) };
419 unsigned char has_{};
422 std::array<double, Size> value_{};
424 constexpr std::size_t index(
const Item p)
const noexcept
426 return static_cast<std::size_t
>(p);
429 bool hasItem(
const std::size_t i)
const
431 return (this->has_ & (1 << i)) != 0;
434 std::string itemName(
const Item p)
const
437 case Item::Oil:
return "Oil";
438 case Item::Gas:
return "Gas";
439 case Item::Water:
return "Water";
442 return "Out of bounds (NumItems)";
445 return "Unknown (" + std::to_string(this->index(p)) +
')';
456 std::size_t segNumber{};
458 bool operator==(
const Segment& seg2)
const
460 return (rates == seg2.rates)
461 && (pressures == seg2.pressures)
462 && (velocity == seg2.velocity)
463 && (holdup == seg2.holdup)
464 && (viscosity == seg2.viscosity)
465 && (segNumber == seg2.segNumber);
468 template <
class MessageBufferType>
469 void write(MessageBufferType& buffer)
const;
471 template <
class MessageBufferType>
472 void read(MessageBufferType& buffer);
474 template <
class Serializer>
477 serializer(this->rates);
478 serializer(this->pressures);
479 serializer(this->velocity);
480 serializer(this->holdup);
481 serializer(this->viscosity);
482 serializer(this->segNumber);
485 static Segment serializationTestObject()
488 Rates::serializationTestObject(),
489 SegmentPressures::serializationTestObject(),
490 SegmentPhaseQuantity::serializationTestObject(),
491 SegmentPhaseQuantity::serializationTestObject(),
492 SegmentPhaseQuantity::serializationTestObject(),
499 bool isProducer{
true};
501 ::Opm::WellProducerCMode prod {
502 ::Opm::WellProducerCMode::CMODE_UNDEFINED
505 ::Opm::WellInjectorCMode inj {
506 ::Opm::WellInjectorCMode::CMODE_UNDEFINED
511 return (this->isProducer == rhs.isProducer)
512 && ((this->isProducer && (this->prod == rhs.prod)) ||
513 (!this->isProducer && (this->inj == rhs.inj)));
518 if (this->inj == ::Opm::WellInjectorCMode::CMODE_UNDEFINED)
519 json_data.add_item(
"inj",
"CMODE_UNDEFINED");
521 json_data.add_item(
"inj", ::Opm::WellInjectorCMode2String(this->inj));
523 if (this->prod == ::Opm::WellProducerCMode::CMODE_UNDEFINED)
524 json_data.add_item(
"prod",
"CMODE_UNDEFINED");
526 json_data.add_item(
"prod", ::Opm::WellProducerCMode2String(this->prod));
529 template <
class MessageBufferType>
530 void write(MessageBufferType& buffer)
const;
532 template <
class MessageBufferType>
533 void read(MessageBufferType& buffer);
535 template<
class Serializer>
538 serializer(isProducer);
546 ::Opm::WellProducerCMode::BHP,
547 ::Opm::WellInjectorCMode::GRUP
556 double temperature{0.0};
559 ::Opm::WellStatus dynamicStatus { Opm::WellStatus::OPEN };
561 std::vector< Connection > connections{};
562 std::unordered_map<std::size_t, Segment> segments{};
566 inline bool flowing()
const noexcept;
567 template <
class MessageBufferType>
568 void write(MessageBufferType& buffer)
const;
569 template <
class MessageBufferType>
570 void read(MessageBufferType& buffer);
574 const Connection* find_connection(Connection::global_index connection_grid_index)
const {
575 const auto connection = std::find_if( this->connections.begin() ,
576 this->connections.end() ,
578 return c.index == connection_grid_index; });
580 if( connection == this->connections.end() )
586 Connection* find_connection(Connection::global_index connection_grid_index) {
587 auto connection = std::find_if( this->connections.begin() ,
588 this->connections.end() ,
590 return c.index == connection_grid_index; });
592 if( connection == this->connections.end() )
598 bool operator==(
const Well& well2)
const
600 return rates == well2.rates &&
603 temperature == well2.temperature &&
604 control == well2.control &&
605 dynamicStatus == well2.dynamicStatus &&
606 connections == well2.connections &&
607 segments == well2.segments &&
608 current_control == well2.current_control &&
609 guide_rates == well2.guide_rates;
612 template<
class Serializer>
618 serializer(temperature);
620 serializer(dynamicStatus);
621 serializer(connections);
622 serializer(segments);
623 serializer(current_control);
624 serializer(guide_rates);
627 static Well serializationTestObject()
629 return Well{Rates::serializationTestObject(),
634 ::Opm::WellStatus::SHUT,
635 {Connection::serializationTestObject()},
636 {{0, Segment::serializationTestObject()}},
637 CurrentControl::serializationTestObject(),
638 GuideRateValue::serializationTestObject()
644 class Wells:
public std::map<std::string , Well> {
647 double get(
const std::string& well_name , Rates::opt m)
const {
648 const auto& well = this->find( well_name );
649 if( well == this->end() )
return 0.0;
651 return well->second.rates.get( m, 0.0 );
654 double get(
const std::string& well_name , Rates::opt m,
const std::string& tracer_name)
const {
655 const auto& well = this->find( well_name );
656 if( well == this->end() )
return 0.0;
658 return well->second.rates.get( m, 0.0, tracer_name);
661 double get(
const std::string& well_name , Connection::global_index connection_grid_index, Rates::opt m)
const {
662 const auto& witr = this->find( well_name );
663 if( witr == this->end() )
return 0.0;
665 const auto& well = witr->second;
666 const auto& connection = std::find_if( well.connections.begin() ,
667 well.connections.end() ,
669 return c.index == connection_grid_index; });
671 if( connection == well.connections.end() )
674 return connection->rates.get( m, 0.0 );
677 template <
class MessageBufferType>
678 void write(MessageBufferType& buffer)
const {
679 unsigned int size = this->size();
681 for (
const auto& witr : *
this) {
682 const std::string& name = witr.first;
684 const Well& well = witr.second;
689 template <
class MessageBufferType>
690 void read(MessageBufferType& buffer) {
693 for (
size_t i = 0; i < size; ++i) {
698 this->emplace(name, well);
703 for (
const auto& [wname, well] : *
this) {
704 auto json_well = json_data.add_object(wname);
705 well.init_json(json_well);
712 this->init_json(json_data);
716 template<
class Serializer>
719 serializer(
static_cast<std::map<std::string,Well>&
>(*
this));
722 static Wells serializationTestObject()
725 w.insert({
"test_well", Well::serializationTestObject()});
735 const auto mand =
static_cast< enum_size
>( this->mask )
736 &
static_cast< enum_size
>( m );
738 return static_cast< opt
>( mand ) == m;
742 if( !this->
has( m ) )
743 throw std::invalid_argument(
"Uninitialized value." );
745 return this->get_ref( m );
748 inline double Rates::get( opt m,
double default_value )
const {
749 if( !this->
has( m ) )
return default_value;
751 return this->get_ref( m );
754 inline double Rates::get( opt m,
double default_value,
const std::string& tracer_name)
const {
755 if( !this->
has( m ) )
return default_value;
757 if( m == opt::tracer && this->tracer.find(tracer_name) == this->tracer.end())
return default_value;
759 return this->get_ref( m, tracer_name);
763 this->get_ref( m ) = value;
766 this->mask =
static_cast< opt
>(
767 static_cast< enum_size
>( this->mask ) |
768 static_cast< enum_size
>( m )
774 inline Rates&
Rates::set( opt m,
double value ,
const std::string& tracer_name ) {
775 this->get_ref( m , tracer_name) = value;
778 this->mask =
static_cast< opt
>(
779 static_cast< enum_size
>( this->mask ) |
780 static_cast< enum_size
>( m )
786 inline bool Rates::operator==(
const Rates& rate)
const
788 return mask == rate.mask &&
792 polymer == rate.polymer &&
793 solvent == rate.solvent &&
794 energy == rate.energy &&
795 dissolved_gas == rate.dissolved_gas &&
796 vaporized_oil == rate.vaporized_oil &&
797 reservoir_water == rate.reservoir_water &&
798 reservoir_oil == rate.reservoir_oil &&
799 reservoir_gas == rate.reservoir_gas &&
800 productivity_index_water == rate.productivity_index_water &&
801 productivity_index_gas == rate.productivity_index_gas &&
802 productivity_index_oil == rate.productivity_index_oil &&
803 well_potential_water == rate.well_potential_water &&
804 well_potential_oil == rate.well_potential_oil &&
805 well_potential_gas == rate.well_potential_gas &&
806 brine == rate.brine &&
808 tracer == rate.tracer &&
810 vaporized_water == rate.vaporized_water;
823 inline const double& Rates::get_ref( opt m )
const {
825 case opt::wat:
return this->wat;
826 case opt::oil:
return this->oil;
827 case opt::gas:
return this->gas;
828 case opt::polymer:
return this->polymer;
829 case opt::solvent:
return this->solvent;
830 case opt::energy:
return this->energy;
831 case opt::dissolved_gas:
return this->dissolved_gas;
832 case opt::vaporized_oil:
return this->vaporized_oil;
833 case opt::reservoir_water:
return this->reservoir_water;
834 case opt::reservoir_oil:
return this->reservoir_oil;
835 case opt::reservoir_gas:
return this->reservoir_gas;
836 case opt::productivity_index_water:
return this->productivity_index_water;
837 case opt::productivity_index_oil:
return this->productivity_index_oil;
838 case opt::productivity_index_gas:
return this->productivity_index_gas;
839 case opt::well_potential_water:
return this->well_potential_water;
840 case opt::well_potential_oil:
return this->well_potential_oil;
841 case opt::well_potential_gas:
return this->well_potential_gas;
842 case opt::brine:
return this->brine;
843 case opt::alq:
return this->alq;
846 case opt::micp:
return this->micp;
847 case opt::vaporized_water:
return this->vaporized_water;
850 throw std::invalid_argument(
851 "Unknown value type '"
852 + std::to_string(
static_cast< enum_size
>( m ) )
857 inline const double& Rates::get_ref( opt m,
const std::string& tracer_name )
const {
858 if (m != opt::tracer)
859 throw std::logic_error(
"Logic error - should be called with tracer argument");
861 return this->tracer.at(tracer_name);
864 inline double& Rates::get_ref( opt m ) {
865 return const_cast< double&
>(
866 static_cast< const Rates*
>( this )->get_ref( m )
870 inline double& Rates::get_ref( opt m,
const std::string& tracer_name ) {
871 if (m == opt::tracer) this->tracer.emplace(tracer_name, 0.0);
872 return this->tracer.at(tracer_name);
877 if (this->
has(opt::wat))
878 json_data.add_item(
"wat", this->
get(opt::wat));
880 if (this->
has(opt::oil))
881 json_data.add_item(
"oil", this->
get(opt::oil));
883 if (this->
has(opt::gas))
884 json_data.add_item(
"gas", this->
get(opt::gas));
889 return ((this->wat != 0) ||
894 inline bool Well::flowing() const noexcept {
898 template <
class MessageBufferType>
899 void Rates::write(MessageBufferType& buffer)
const {
900 buffer.write(this->mask);
901 buffer.write(this->wat);
902 buffer.write(this->oil);
903 buffer.write(this->gas);
904 buffer.write(this->polymer);
905 buffer.write(this->solvent);
906 buffer.write(this->energy);
907 buffer.write(this->dissolved_gas);
908 buffer.write(this->vaporized_oil);
909 buffer.write(this->reservoir_water);
910 buffer.write(this->reservoir_oil);
911 buffer.write(this->reservoir_gas);
912 buffer.write(this->productivity_index_water);
913 buffer.write(this->productivity_index_oil);
914 buffer.write(this->productivity_index_gas);
915 buffer.write(this->well_potential_water);
916 buffer.write(this->well_potential_oil);
917 buffer.write(this->well_potential_gas);
918 buffer.write(this->brine);
919 buffer.write(this->alq);
921 unsigned int size = this->tracer.size();
923 for (
const auto& [name, rate] : this->tracer) {
927 buffer.write(this->micp);
928 buffer.write(this->vaporized_water);
931 template <
class MessageBufferType>
932 void Connection::write(MessageBufferType& buffer)
const {
933 buffer.write(this->index);
934 this->rates.write(buffer);
935 buffer.write(this->pressure);
936 buffer.write(this->reservoir_rate);
937 buffer.write(this->cell_pressure);
938 buffer.write(this->cell_saturation_water);
939 buffer.write(this->cell_saturation_gas);
940 buffer.write(this->effective_Kh);
941 buffer.write(this->trans_factor);
945 auto json_rates = json_data.add_object(
"rates");
946 this->rates.init_json(json_rates);
948 json_data.add_item(
"global_index",
static_cast<int>(this->index));
949 json_data.add_item(
"pressure", this->pressure);
950 json_data.add_item(
"reservoir_rate", this->reservoir_rate);
951 json_data.add_item(
"cell_pressure", this->cell_pressure);
952 json_data.add_item(
"swat", this->cell_saturation_water);
953 json_data.add_item(
"sgas", this->cell_saturation_gas);
954 json_data.add_item(
"Kh", this->effective_Kh);
955 json_data.add_item(
"trans_factor", this->trans_factor);
958 template <
class MessageBufferType>
959 void Segment::write(MessageBufferType& buffer)
const
961 buffer.write(this->segNumber);
962 this->rates.write(buffer);
963 this->pressures.write(buffer);
964 this->velocity.write(buffer);
965 this->holdup.write(buffer);
966 this->viscosity.write(buffer);
969 template <
class MessageBufferType>
970 void CurrentControl::write(MessageBufferType& buffer)
const
972 buffer.write(this->isProducer);
973 if (this->isProducer) {
974 buffer.write(this->prod);
977 buffer.write(this->inj);
981 template <
class MessageBufferType>
982 void Well::write(MessageBufferType& buffer)
const {
983 this->rates.write(buffer);
984 buffer.write(this->bhp);
985 buffer.write(this->thp);
986 buffer.write(this->temperature);
987 buffer.write(this->control);
990 const auto status = ::Opm::WellStatus2String(this->dynamicStatus);
991 buffer.write(status);
994 unsigned int size = this->connections.size();
996 for (
const Connection& comp : this->connections)
1001 static_cast<unsigned int>(this->segments.size());
1004 for (
const auto& seg : this->segments) {
1005 seg.second.write(buffer);
1009 this->current_control.write(buffer);
1010 this->guide_rates.write(buffer);
1013 template <
class MessageBufferType>
1014 void Rates::read(MessageBufferType& buffer) {
1015 buffer.read(this->mask);
1016 buffer.read(this->wat);
1017 buffer.read(this->oil);
1018 buffer.read(this->gas);
1019 buffer.read(this->polymer);
1020 buffer.read(this->solvent);
1021 buffer.read(this->energy);
1022 buffer.read(this->dissolved_gas);
1023 buffer.read(this->vaporized_oil);
1024 buffer.read(this->reservoir_water);
1025 buffer.read(this->reservoir_oil);
1026 buffer.read(this->reservoir_gas);
1027 buffer.read(this->productivity_index_water);
1028 buffer.read(this->productivity_index_oil);
1029 buffer.read(this->productivity_index_gas);
1030 buffer.read(this->well_potential_water);
1031 buffer.read(this->well_potential_oil);
1032 buffer.read(this->well_potential_gas);
1033 buffer.read(this->brine);
1034 buffer.read(this->alq);
1038 for (
size_t i = 0; i < size; ++i) {
1039 std::string tracer_name;
1040 buffer.read(tracer_name);
1042 buffer.read(tracer_rate);
1043 this->tracer.emplace(tracer_name, tracer_rate);
1045 buffer.read(this->micp);
1046 buffer.read(this->vaporized_water);
1049 template <
class MessageBufferType>
1050 void Connection::read(MessageBufferType& buffer) {
1051 buffer.read(this->index);
1052 this->rates.read(buffer);
1053 buffer.read(this->pressure);
1054 buffer.read(this->reservoir_rate);
1055 buffer.read(this->cell_pressure);
1056 buffer.read(this->cell_saturation_water);
1057 buffer.read(this->cell_saturation_gas);
1058 buffer.read(this->effective_Kh);
1059 buffer.read(this->trans_factor);
1062 template <
class MessageBufferType>
1063 void Segment::read(MessageBufferType& buffer)
1065 buffer.read(this->segNumber);
1066 this->rates.read(buffer);
1067 this->pressures.read(buffer);
1068 this->velocity.read(buffer);
1069 this->holdup.read(buffer);
1070 this->viscosity.read(buffer);
1073 template <
class MessageBufferType>
1074 void CurrentControl::read(MessageBufferType& buffer)
1076 buffer.read(this->isProducer);
1077 if (this->isProducer) {
1078 buffer.read(this->prod);
1081 buffer.read(this->inj);
1085 template <
class MessageBufferType>
1086 void Well::read(MessageBufferType& buffer) {
1087 this->rates.read(buffer);
1088 buffer.read(this->bhp);
1089 buffer.read(this->thp);
1090 buffer.read(this->temperature);
1091 buffer.read(this->control);
1094 auto status = std::string{};
1095 buffer.read(status);
1096 this->dynamicStatus = ::Opm::WellStatusFromString(status);
1100 unsigned int size = 0.0;
1102 this->connections.resize(size);
1103 for (
size_t i = 0; i < size; ++i)
1105 auto& comp = this->connections[ i ];
1110 const auto nSeg = [&buffer]() ->
unsigned int
1118 for (
auto segID = 0*nSeg; segID < nSeg; ++segID) {
1119 auto seg = Segment{};
1122 const auto segNumber = seg.segNumber;
1123 this->segments.emplace(segNumber, std::move(seg));
1126 this->current_control.read(buffer);
1127 this->guide_rates.read(buffer);
1131 auto json_connections = json_data.add_array(
"connections");
1132 for (
const auto& conn : this->connections) {
1133 auto json_conn = json_connections.add_object();
1134 conn.init_json(json_conn);
1136 auto json_rates = json_data.add_object(
"rates");
1137 this->rates.init_json(json_rates);
1139 json_data.add_item(
"bhp", this->bhp);
1140 json_data.add_item(
"thp", this->thp);
1141 json_data.add_item(
"temperature", this->temperature);
1142 json_data.add_item(
"status", ::Opm::WellStatus2String(this->dynamicStatus));
1144 auto json_control = json_data.add_object(
"control");
1145 this->current_control.init_json(json_control);
1147 auto json_guiderate = json_data.add_object(
"guiderate");
1148 this->guide_rates.init_json(json_guiderate);
Definition: JsonObject.hpp:32
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:888
double get(opt m) const
Read the value indicated by m.
Definition: Wells.hpp:741
Rates & set(opt m, double value)
Set the value specified by m.
Definition: Wells.hpp:762
bool has(opt) const
Query if a value is set.
Definition: Wells.hpp:734
Definition: Wells.hpp:322
Definition: Wells.hpp:255
Definition: Wells.hpp:644
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: Wells.hpp:199
Definition: Wells.hpp:498
Definition: Wells.hpp:450
Definition: Wells.hpp:552