20 #ifndef OPM_OUTPUT_WELLS_HPP 21 #define OPM_OUTPUT_WELLS_HPP 23 #include <opm/common/ErrorMacros.hpp> 24 #include <opm/common/OpmLog/OpmLog.hpp> 25 #include <opm/output/data/GuideRateValue.hpp> 26 #include <opm/input/eclipse/Schedule/Well/WellEnums.hpp> 36 #include <type_traits> 37 #include <unordered_map> 40 namespace Opm {
namespace data {
54 enum class opt : std::uint32_t {
61 dissolved_gas = (1 << 6),
62 vaporized_oil = (1 << 7),
63 reservoir_water = (1 << 8),
64 reservoir_oil = (1 << 9),
65 reservoir_gas = (1 << 10),
66 productivity_index_water = (1 << 11),
67 productivity_index_oil = (1 << 12),
68 productivity_index_gas = (1 << 13),
69 well_potential_water = (1 << 14),
70 well_potential_oil = (1 << 15),
71 well_potential_gas = (1 << 16),
75 microbial = (1 << 20),
78 vaporized_water = (1 << 23),
84 using enum_size = std::underlying_type< opt >::type;
87 inline bool has( opt )
const;
91 inline double get( opt m )
const;
94 inline double get( opt m,
double default_value )
const;
95 inline double get( opt m,
double default_value ,
const std::string& tracer_name )
const;
100 inline Rates&
set( opt m,
double value ,
const std::string& tracer_name );
105 template <
class MessageBufferType>
106 void write(MessageBufferType& buffer)
const;
107 template <
class MessageBufferType>
108 void read(MessageBufferType& buffer);
110 bool operator==(
const Rates& rat2)
const;
112 template<
class Serializer>
122 serializer(dissolved_gas);
123 serializer(vaporized_oil);
124 serializer(reservoir_water);
125 serializer(reservoir_oil);
126 serializer(reservoir_gas);
127 serializer(productivity_index_water);
128 serializer(productivity_index_oil);
129 serializer(productivity_index_gas);
130 serializer(well_potential_water);
131 serializer(well_potential_oil);
132 serializer(well_potential_gas);
136 serializer(microbial);
139 serializer(vaporized_water);
140 serializer(mass_gas);
141 serializer(mass_wat);
142 serializer(wat_frac);
145 static Rates serializationTestObject()
148 rat1.
set(opt::wat, 1.0);
149 rat1.
set(opt::oil, 2.0);
150 rat1.
set(opt::gas, 3.0);
151 rat1.
set(opt::polymer, 4.0);
152 rat1.
set(opt::solvent, 5.0);
153 rat1.
set(opt::energy, 6.0);
154 rat1.
set(opt::dissolved_gas, 7.0);
155 rat1.
set(opt::vaporized_oil, 8.0);
156 rat1.
set(opt::reservoir_water, 9.0);
157 rat1.
set(opt::reservoir_oil, 10.0);
158 rat1.
set(opt::reservoir_gas, 11.0);
159 rat1.
set(opt::productivity_index_water, 12.0);
160 rat1.
set(opt::productivity_index_oil, 13.0);
161 rat1.
set(opt::productivity_index_gas, 14.0);
162 rat1.
set(opt::well_potential_water, 15.0);
163 rat1.
set(opt::well_potential_oil, 16.0);
164 rat1.
set(opt::well_potential_gas, 17.0);
165 rat1.
set(opt::brine, 18.0);
166 rat1.
set(opt::alq, 19.0);
167 rat1.
set(opt::microbial, 20.0);
168 rat1.
set(opt::oxygen, 21.0);
169 rat1.
set(opt::urea, 22.0);
170 rat1.
set(opt::vaporized_water, 23.0);
171 rat1.
set(opt::mass_gas, 24.0);
172 rat1.
set(opt::mass_wat, 25.0);
173 rat1.
set(opt::wat_frac, 26.0);
174 rat1.tracer.insert({
"test_tracer", 1.0});
180 double& get_ref( opt );
181 double& get_ref( opt,
const std::string& tracer_name );
182 const double& get_ref( opt )
const;
183 const double& get_ref( opt,
const std::string& tracer_name )
const;
185 opt mask =
static_cast< opt
>( 0 );
190 double polymer = 0.0;
191 double solvent = 0.0;
193 double dissolved_gas = 0.0;
194 double vaporized_oil = 0.0;
195 double reservoir_water = 0.0;
196 double reservoir_oil = 0.0;
197 double reservoir_gas = 0.0;
198 double productivity_index_water = 0.0;
199 double productivity_index_oil = 0.0;
200 double productivity_index_gas = 0.0;
201 double well_potential_water = 0.0;
202 double well_potential_oil = 0.0;
203 double well_potential_gas = 0.0;
206 std::map<std::string, double> tracer{};
207 double microbial = 0.0;
210 double vaporized_water = 0.0;
211 double mass_gas = 0.0;
212 double mass_wat = 0.0;
213 double wat_frac = 0.0;
220 double skin_factor{};
225 double area_of_flow{};
226 double flow_factor{};
227 double fracture_rate{};
229 template <
class Serializer>
234 serializer(skin_factor);
235 serializer(thickness);
239 serializer(area_of_flow);
240 serializer(flow_factor);
241 serializer(fracture_rate);
246 return (this->rate == filtrate.rate)
247 && (this->total == filtrate.total)
248 && (this->skin_factor == filtrate.skin_factor)
249 && (this->thickness == filtrate.thickness)
250 && (this->perm == filtrate.perm)
251 && (this->poro == filtrate.poro)
252 && (this->radius == filtrate.radius)
253 && (this->area_of_flow == filtrate.area_of_flow)
254 && (this->flow_factor == filtrate.flow_factor)
255 && (this->fracture_rate == filtrate.fracture_rate)
261 return {0.8, 100.0, -1.0, 2.0, 1.0e-9,
262 0.3, 0.05, 0.8, 0.1, 0.7};
265 template <
class MessageBufferType>
266 void write(MessageBufferType& buffer)
const;
268 template <
class MessageBufferType>
269 void read(MessageBufferType& buffer);
280 double filter_volume{};
282 double avg_filter_width{};
283 double inj_pressure{};
285 double inj_wellrate{};
287 template <
class Serializer>
296 serializer(filter_volume);
297 serializer(avg_width);
298 serializer(avg_filter_width);
299 serializer(inj_pressure);
301 serializer(inj_wellrate);
306 return (this->area == fraccon.area)
307 && (this->flux == fraccon.flux)
308 && (this->height == fraccon.height)
309 && (this->length == fraccon.length)
310 && (this->WI == fraccon.WI)
311 && (this->volume == fraccon.volume)
312 && (this->filter_volume == fraccon.filter_volume)
313 && (this->avg_width == fraccon.avg_width)
314 && (this->avg_filter_width == fraccon.avg_filter_width)
315 && (this->inj_pressure == fraccon.inj_pressure)
316 && (this->inj_bhp == fraccon.inj_bhp)
317 && (this->inj_wellrate == fraccon.inj_wellrate)
323 return {0.8, 100.0, 1.3, 1.4, 10.0, 4.0, 0.4, 0.5, 0.05, 200.0, 150.0, 500.0};
326 template <
class MessageBufferType>
327 void write(MessageBufferType& buffer)
const 329 buffer.write(this->area);
330 buffer.write(this->flux);
331 buffer.write(this->height);
332 buffer.write(this->length);
333 buffer.write(this->WI);
334 buffer.write(this->volume);
335 buffer.write(this->filter_volume);
336 buffer.write(this->avg_width);
337 buffer.write(this->avg_filter_width);
338 buffer.write(this->inj_pressure);
339 buffer.write(this->inj_bhp);
340 buffer.write(this->inj_wellrate);
343 template <
class MessageBufferType>
344 void read(MessageBufferType& buffer)
346 buffer.read(this->area);
347 buffer.read(this->flux);
348 buffer.read(this->height);
349 buffer.read(this->length);
350 buffer.read(this->WI);
351 buffer.read(this->volume);
352 buffer.read(this->filter_volume);
353 buffer.read(this->avg_width);
354 buffer.read(this->avg_filter_width);
355 buffer.read(this->inj_pressure);
356 buffer.read(this->inj_bhp);
357 buffer.read(this->inj_wellrate);
385 12.34, 56.78, 9.10, 11.12
394 template <
class Serializer>
397 serializer(this->
avg);
398 serializer(this->
max);
399 serializer(this->
min);
400 serializer(this->
stdev);
412 return (this->
avg == that.
avg)
413 && (this->
max == that.
max)
414 && (this->
min == that.
min)
420 template <
class MessageBufferType>
421 void write(MessageBufferType& buffer)
const 423 buffer.write(this->
avg);
424 buffer.write(this->
max);
425 buffer.write(this->
min);
426 buffer.write(this->
stdev);
430 template <
class MessageBufferType>
431 void read(MessageBufferType& buffer)
433 buffer.read(this->
avg);
434 buffer.read(this->
max);
435 buffer.read(this->
min);
436 buffer.read(this->
stdev);
472 template <
class Serializer>
476 serializer(this->
press);
477 serializer(this->
rate);
478 serializer(this->
width);
498 template <
class MessageBufferType>
499 void write(MessageBufferType& buffer)
const 502 buffer.write(this->
press);
503 buffer.write(this->
rate);
504 buffer.write(this->
width);
508 template <
class MessageBufferType>
509 void read(MessageBufferType& buffer)
512 buffer.read(this->
press);
513 buffer.read(this->
rate);
514 buffer.read(this->
width);
520 using global_index = std::size_t;
521 static const constexpr
int restart_size = 6;
523 global_index index{};
526 double reservoir_rate{};
527 double cell_pressure{};
528 double cell_saturation_water{};
529 double cell_saturation_gas{};
530 double effective_Kh{};
531 double trans_factor{};
533 double compact_mult{1.0};
544 bool operator==(
const Connection& conn2)
const 546 return (index == conn2.index)
547 && (rates == conn2.rates)
548 && (pressure == conn2.pressure)
549 && (reservoir_rate == conn2.reservoir_rate)
550 && (cell_pressure == conn2.cell_pressure)
551 && (cell_saturation_water == conn2.cell_saturation_water)
552 && (cell_saturation_gas == conn2.cell_saturation_gas)
553 && (effective_Kh == conn2.effective_Kh)
554 && (trans_factor == conn2.trans_factor)
555 && (d_factor == conn2.d_factor)
556 && (compact_mult == conn2.compact_mult)
557 && (lgr_grid == conn2.lgr_grid)
558 && (filtrate == conn2.filtrate)
559 && (fracture == conn2.fracture)
564 template <
class MessageBufferType>
565 void write(MessageBufferType& buffer)
const;
566 template <
class MessageBufferType>
567 void read(MessageBufferType& buffer);
569 template<
class Serializer>
574 serializer(pressure);
575 serializer(reservoir_rate);
576 serializer(cell_pressure);
577 serializer(cell_saturation_water);
578 serializer(cell_saturation_gas);
579 serializer(effective_Kh);
580 serializer(trans_factor);
581 serializer(d_factor);
582 serializer(compact_mult);
583 serializer(lgr_grid);
584 serializer(filtrate);
585 serializer(fracture);
586 serializer(this->
fract);
589 static Connection serializationTestObject()
592 1, Rates::serializationTestObject(),
594 6.0, 7.0, 8.0, 9.0, 0.987,
596 ConnectionFiltrate::serializationTestObject(),
597 ConnectionFracture::serializationTestObject(),
606 enum class Value : std::size_t {
607 Pressure, PDrop, PDropHydrostatic, PDropAccel, PDropFriction,
610 double& operator[](
const Value i)
612 return this->values_[this->index(i)];
615 double operator[](
const Value i)
const 617 return this->values_[this->index(i)];
622 return this->values_ == segpres2.values_;
625 template <
class MessageBufferType>
626 void write(MessageBufferType& buffer)
const 628 for (
const auto&
value : this->values_) {
633 template <
class MessageBufferType>
634 void read(MessageBufferType& buffer)
636 for (
auto&
value : this->values_) {
641 template<
class Serializer>
650 spres[Value::Pressure] = 1.0;
651 spres[Value::PDrop] = 2.0;
652 spres[Value::PDropHydrostatic] = 3.0;
653 spres[Value::PDropAccel] = 4.0;
654 spres[Value::PDropFriction] = 5.0;
660 constexpr
static std::size_t numvals = 5;
662 std::array<double, numvals> values_ = {0};
664 std::size_t index(
const Value ix)
const 666 return static_cast<std::size_t
>(ix);
670 template <
typename Items>
674 using Item =
typename Items::Item;
678 this->has_ =
static_cast<unsigned char>(0);
679 this->value_.fill(0.0);
682 constexpr
bool has(
const Item p)
const 684 const auto i = this->index(p);
686 return (i < Size) && this->hasItem(i);
691 return (this->has_ == that.has_)
692 && (this->value_ == that.value_);
695 double get(
const Item p)
const 697 if (! this->has(p)) {
698 throw std::invalid_argument {
699 "Request for Unset Item Value for " + Items::itemName(p)
703 return this->value_[ this->index(p) ];
708 const auto i = this->index(p);
711 throw std::invalid_argument {
712 "Cannot Assign Item Value for Unsupported Item '" 713 + Items::itemName(p) +
'\'' 717 this->has_ |= 1 << i;
718 this->value_[i] =
value;
723 template <
class MessageBufferType>
724 void write(MessageBufferType& buffer)
const 726 buffer.write(this->has_);
728 for (
const auto& x : this->value_) {
733 template <
class MessageBufferType>
734 void read(MessageBufferType& buffer)
737 buffer.read(this->has_);
739 for (
auto& x : this->value_) {
744 template <
class Serializer>
747 serializer(this->has_);
748 serializer(this->value_);
755 for (
const auto& [item,
value] : Items::serializationTestItems()) {
756 quant.set(item,
value);
763 enum { Size =
static_cast<std::size_t
>(Item::NumItems) };
765 static_assert(Size <= static_cast<std::size_t>(CHAR_BIT),
766 "Number of items must not exceed CHAR_BIT");
770 unsigned char has_{};
773 std::array<double, Size> value_{};
775 constexpr std::size_t index(
const Item p)
const noexcept
777 return static_cast<std::size_t
>(p);
780 bool hasItem(
const std::size_t i)
const 782 return (this->has_ & (1 << i)) != 0;
795 static std::string itemName(
const Item p)
798 case Item::Oil:
return "Oil";
799 case Item::Gas:
return "Gas";
800 case Item::Water:
return "Water";
803 return "Out of bounds (NumItems)";
806 return "Unknown (" + std::to_string(static_cast<int>(p)) +
')';
809 static auto serializationTestItems()
812 std::pair { Item::Oil , 1.0 },
813 std::pair { Item::Gas , 7.0 },
814 std::pair { Item::Water, 2.9 },
822 Oil, Gas, Water, Mixture, MixtureWithExponents,
828 static std::string itemName(
const Item p)
831 case Item::Oil:
return "Oil";
832 case Item::Gas:
return "Gas";
833 case Item::Water:
return "Water";
834 case Item::Mixture:
return "Mixture";
835 case Item::MixtureWithExponents:
return "MixtureWithExponents";
838 return "Out of bounds (NumItems)";
841 return "Unknown (" + std::to_string(static_cast<int>(p)) +
')';
844 static auto serializationTestItems()
847 std::pair { Item::Oil , 876.54 },
848 std::pair { Item::Gas , 321.09 },
849 std::pair { Item::Water , 987.65 },
850 std::pair { Item::Mixture , 975.31 },
851 std::pair { Item::MixtureWithExponents, 765.43 },
867 std::size_t segNumber{};
869 bool operator==(
const Segment& seg2)
const 871 return (rates == seg2.rates)
872 && (pressures == seg2.pressures)
873 && (velocity == seg2.velocity)
874 && (holdup == seg2.holdup)
875 && (viscosity == seg2.viscosity)
876 && (density == seg2.density)
877 && (segNumber == seg2.segNumber);
880 template <
class MessageBufferType>
881 void write(MessageBufferType& buffer)
const;
883 template <
class MessageBufferType>
884 void read(MessageBufferType& buffer);
886 template <
class Serializer>
889 serializer(this->rates);
890 serializer(this->pressures);
891 serializer(this->velocity);
892 serializer(this->holdup);
893 serializer(this->viscosity);
894 serializer(this->density);
895 serializer(this->segNumber);
898 static Segment serializationTestObject()
901 Rates::serializationTestObject(),
902 SegmentPressures::serializationTestObject(),
903 SegmentPhaseQuantity::serializationTestObject(),
904 SegmentPhaseQuantity::serializationTestObject(),
905 SegmentPhaseQuantity::serializationTestObject(),
906 SegmentPhaseDensity::serializationTestObject(),
914 bool isProducer{
true};
916 ::Opm::WellProducerCMode
prod {
917 ::Opm::WellProducerCMode::CMODE_UNDEFINED
920 ::Opm::WellInjectorCMode
inj {
921 ::Opm::WellInjectorCMode::CMODE_UNDEFINED
926 return (this->isProducer == rhs.isProducer)
927 && ((this->isProducer && (this->
prod == rhs.prod)) ||
928 (!this->isProducer && (this->
inj == rhs.inj)));
931 template <
class MessageBufferType>
932 void write(MessageBufferType& buffer)
const;
934 template <
class MessageBufferType>
935 void read(MessageBufferType& buffer);
937 template<
class Serializer>
940 serializer(isProducer);
948 ::Opm::WellProducerCMode::BHP,
949 ::Opm::WellInjectorCMode::GRUP
957 enum class Quantity { WBP, WBP4, WBP5, WBP9 };
959 double& operator[](
const Quantity q)
961 return this->wbp_[
static_cast<std::size_t
>(q)];
964 double operator[](
const Quantity q)
const 966 return this->wbp_[
static_cast<std::size_t
>(q)];
971 return this->wbp_ == that.wbp_;
974 template <
class MessageBufferType>
975 void write(MessageBufferType& buffer)
const;
977 template <
class MessageBufferType>
978 void read(MessageBufferType& buffer);
980 template <
class Serializer>
983 serializer(this->wbp_);
990 wbp[Quantity::WBP] = 17.29;
991 wbp[Quantity::WBP4] = 2.718;
992 wbp[Quantity::WBP5] = 3.1415;
993 wbp[Quantity::WBP9] = 1.618;
999 static constexpr
auto NumQuantities =
1000 static_cast<std::size_t
>(Quantity::WBP9) + 1;
1002 std::array<double, NumQuantities> wbp_{};
1009 double concentration{0.};
1011 template<
class Serializer>
1015 serializer(concentration);
1019 return this->rate == filtrate.rate
1020 && this->total == filtrate.total
1021 && this->concentration == filtrate.concentration;
1028 res.concentration = 0.;
1032 template <
class MessageBufferType>
1033 void write(MessageBufferType& buffer)
const;
1035 template <
class MessageBufferType>
1036 void read(MessageBufferType& buffer);
1042 Bhp, OilRate, WaterRate, GasRate, ResVRate, LiquidRate,
1048 static std::string itemName(
const Item p)
1051 case Item::Bhp:
return "Bhp";
1052 case Item::OilRate:
return "OilRate";
1053 case Item::WaterRate:
return "WaterRate";
1054 case Item::GasRate:
return "GasRate";
1055 case Item::ResVRate:
return "ResVRate";
1056 case Item::LiquidRate:
return "LiquidRate";
1058 case Item::NumItems:
1059 return "Out of bounds (NumItems)";
1062 return "Unknown (" + std::to_string(static_cast<int>(p)) +
')';
1065 static auto serializationTestItems()
1067 return std::vector {
1068 std::pair { Item::Bhp , 321.09 },
1069 std::pair { Item::OilRate , 987.65 },
1070 std::pair { Item::WaterRate , 975.31 },
1071 std::pair { Item::GasRate , 765.43 },
1072 std::pair { Item::ResVRate , 876.54 },
1073 std::pair { Item::LiquidRate, 54.32 },
1086 double temperature{0.0};
1088 double efficiency_scaling_factor{1.0};
1092 ::Opm::WellStatus dynamicStatus { Opm::WellStatus::OPEN };
1094 std::vector<Connection> connections{};
1095 std::unordered_map<std::size_t, Segment> segments{};
1100 inline bool flowing()
const noexcept;
1102 template <
class MessageBufferType>
1103 void write(MessageBufferType& buffer)
const;
1105 template <
class MessageBufferType>
1106 void read(MessageBufferType& buffer);
1109 find_connection(
const Connection::global_index connection_grid_index)
const 1111 const auto connection =
1112 std::ranges::find_if(this->connections,
1114 {
return c.index == connection_grid_index; });
1116 if (connection == this->connections.end()) {
1120 return &*connection;
1124 find_connection(
const Connection::global_index connection_grid_index)
1126 const auto connection =
1127 std::ranges::find_if(this->connections,
1129 {
return c.index == connection_grid_index; });
1131 if (connection == this->connections.end()) {
1135 return &*connection;
1138 bool operator==(
const Well& well2)
const 1140 return (this->rates == well2.rates)
1141 && (this->bhp == well2.bhp)
1142 && (this->thp == well2.thp)
1143 && (this->temperature == well2.temperature)
1144 && (this->filtrate == well2.filtrate)
1145 && (this->control == well2.control)
1146 && (this->dynamicStatus == well2.dynamicStatus)
1147 && (this->connections == well2.connections)
1148 && (this->segments == well2.segments)
1149 && (this->current_control == well2.current_control)
1150 && (this->guide_rates == well2.guide_rates)
1151 && (this->limits == well2.limits)
1155 bool operator!=(
const Well& well2)
const 1157 return !(*
this == well2);
1160 template<
class Serializer>
1166 serializer(temperature);
1167 serializer(control);
1168 serializer(efficiency_scaling_factor);
1169 serializer(filtrate);
1170 serializer(dynamicStatus);
1171 serializer(connections);
1172 serializer(segments);
1173 serializer(current_control);
1174 serializer(guide_rates);
1178 static Well serializationTestObject()
1181 Rates::serializationTestObject(),
1187 WellFiltrate::serializationTestObject(),
1188 ::Opm::WellStatus::SHUT,
1189 {Connection::serializationTestObject()},
1190 {{0, Segment::serializationTestObject()}},
1191 CurrentControl::serializationTestObject(),
1192 GuideRateValue::serializationTestObject(),
1193 WellControlLimits::serializationTestObject()
1198 class Wells:
public std::map<std::string , Well> {
1201 double get(
const std::string& well_name , Rates::opt m)
const {
1202 const auto& well = this->find( well_name );
1203 if( well == this->end() )
return 0.0;
1205 return well->second.rates.get( m, 0.0 );
1208 double get(
const std::string& well_name , Rates::opt m,
const std::string& tracer_name)
const {
1209 const auto& well = this->find( well_name );
1210 if( well == this->end() )
return 0.0;
1212 return well->second.rates.get( m, 0.0, tracer_name);
1215 double get(
const std::string& well_name , Connection::global_index connection_grid_index, Rates::opt m)
const {
1216 const auto& witr = this->find( well_name );
1217 if( witr == this->end() )
return 0.0;
1219 const auto& well = witr->second;
1220 const auto connection =
1221 std::ranges::find_if(well.connections,
1223 { return c.index == connection_grid_index; });
1225 if (connection == well.connections.end()) {
1229 return connection->rates.get(m, 0.0);
1232 template <
class MessageBufferType>
1233 void write(MessageBufferType& buffer)
const {
1234 unsigned int size = this->size();
1236 for (
const auto& witr : *
this) {
1237 const std::string& name = witr.first;
1239 const Well& well = witr.second;
1244 template <
class MessageBufferType>
1245 void read(MessageBufferType& buffer) {
1248 for (std::size_t i = 0; i < size; ++i) {
1253 auto result = this->emplace(name, well);
1256 if (!result.second && result.first->second != well) {
1257 OPM_THROW(std::runtime_error,
"Received different output data for well " + name +
" from more than one process, the output of this simulation will be wrong!");
1258 }
else if (!result.second) {
1259 OpmLog::warning(
"Received consistently duplicated output data for well " + name +
" from more than one process - this might be problematic!");
1264 template<
class Serializer>
1267 serializer(
static_cast<std::map<std::string,Well>&
>(*
this));
1270 static Wells serializationTestObject()
1273 w.insert({
"test_well", Well::serializationTestObject()});
1281 std::unordered_map<std::string, WellBlockAvgPress> values{};
1283 template <
class MessageBufferType>
1284 void write(MessageBufferType& buffer)
const;
1286 template <
class MessageBufferType>
1287 void read(MessageBufferType& buffer);
1291 return this->values == that.values;
1294 template <
class Serializer>
1297 serializer(this->values);
1303 { {
"I-45", WellBlockAvgPress::serializationTestObject() } },
1311 const auto mand =
static_cast< enum_size
>( this->mask )
1312 & static_cast< enum_size >( m );
1314 return static_cast< opt
>( mand ) == m;
1318 if( !this->
has( m ) )
1319 throw std::invalid_argument(
"Uninitialized value." );
1321 return this->get_ref( m );
1325 if( !this->
has( m ) )
return default_value;
1327 return this->get_ref( m );
1330 inline double Rates::get( opt m,
double default_value,
const std::string& tracer_name)
const {
1331 if( !this->
has( m ) )
return default_value;
1333 if( m == opt::tracer && this->tracer.find(tracer_name) == this->tracer.end())
return default_value;
1335 return this->get_ref( m, tracer_name);
1339 this->get_ref( m ) =
value;
1342 this->mask =
static_cast< opt
>(
1343 static_cast< enum_size
>( this->mask ) |
1344 static_cast< enum_size >( m )
1351 this->get_ref( m , tracer_name) =
value;
1354 this->mask =
static_cast< opt
>(
1355 static_cast< enum_size
>( this->mask ) |
1356 static_cast< enum_size >( m )
1362 inline bool Rates::operator==(
const Rates& rate)
const 1364 return mask == rate.mask &&
1368 polymer == rate.polymer &&
1369 solvent == rate.solvent &&
1370 energy == rate.energy &&
1371 dissolved_gas == rate.dissolved_gas &&
1372 vaporized_oil == rate.vaporized_oil &&
1373 reservoir_water == rate.reservoir_water &&
1374 reservoir_oil == rate.reservoir_oil &&
1375 reservoir_gas == rate.reservoir_gas &&
1376 productivity_index_water == rate.productivity_index_water &&
1377 productivity_index_gas == rate.productivity_index_gas &&
1378 productivity_index_oil == rate.productivity_index_oil &&
1379 well_potential_water == rate.well_potential_water &&
1380 well_potential_oil == rate.well_potential_oil &&
1381 well_potential_gas == rate.well_potential_gas &&
1382 brine == rate.brine &&
1384 tracer == rate.tracer &&
1385 microbial == rate.microbial &&
1386 oxygen == rate.oxygen &&
1387 urea == rate.urea &&
1388 vaporized_water == rate.vaporized_water &&
1389 mass_gas == rate.mass_gas &&
1390 mass_wat == rate.mass_wat &&
1391 wat_frac == rate.wat_frac;
1404 inline const double& Rates::get_ref( opt m )
const {
1406 case opt::wat:
return this->wat;
1407 case opt::oil:
return this->oil;
1408 case opt::gas:
return this->gas;
1409 case opt::polymer:
return this->polymer;
1410 case opt::solvent:
return this->solvent;
1411 case opt::energy:
return this->energy;
1412 case opt::dissolved_gas:
return this->dissolved_gas;
1413 case opt::vaporized_oil:
return this->vaporized_oil;
1414 case opt::reservoir_water:
return this->reservoir_water;
1415 case opt::reservoir_oil:
return this->reservoir_oil;
1416 case opt::reservoir_gas:
return this->reservoir_gas;
1417 case opt::productivity_index_water:
return this->productivity_index_water;
1418 case opt::productivity_index_oil:
return this->productivity_index_oil;
1419 case opt::productivity_index_gas:
return this->productivity_index_gas;
1420 case opt::well_potential_water:
return this->well_potential_water;
1421 case opt::well_potential_oil:
return this->well_potential_oil;
1422 case opt::well_potential_gas:
return this->well_potential_gas;
1423 case opt::brine:
return this->brine;
1424 case opt::alq:
return this->alq;
1427 case opt::microbial:
return this->microbial;
1428 case opt::oxygen:
return this->oxygen;
1429 case opt::urea:
return this->urea;
1430 case opt::vaporized_water:
return this->vaporized_water;
1431 case opt::mass_gas:
return this->mass_gas;
1432 case opt::mass_wat:
return this->mass_wat;
1433 case opt::wat_frac:
return this->wat_frac;
1436 throw std::invalid_argument(
1437 "Unknown value type '" 1438 + std::to_string( static_cast< enum_size >( m ) )
1443 inline const double& Rates::get_ref( opt m,
const std::string& tracer_name )
const {
1444 if (m != opt::tracer)
1445 throw std::logic_error(
"Logic error - should be called with tracer argument");
1447 return this->tracer.at(tracer_name);
1450 inline double& Rates::get_ref( opt m ) {
1451 return const_cast< double&
>(
1452 static_cast< const Rates*
>( this )->get_ref( m )
1456 inline double& Rates::get_ref( opt m,
const std::string& tracer_name ) {
1457 if (m == opt::tracer) this->tracer.emplace(tracer_name, 0.0);
1458 return this->tracer.at(tracer_name);
1462 return ((this->wat != 0) ||
1467 inline bool Well::flowing() const noexcept {
1471 template <
class MessageBufferType>
1472 void Rates::write(MessageBufferType& buffer)
const {
1473 buffer.write(this->mask);
1474 buffer.write(this->wat);
1475 buffer.write(this->oil);
1476 buffer.write(this->gas);
1477 buffer.write(this->polymer);
1478 buffer.write(this->solvent);
1479 buffer.write(this->energy);
1480 buffer.write(this->dissolved_gas);
1481 buffer.write(this->vaporized_oil);
1482 buffer.write(this->reservoir_water);
1483 buffer.write(this->reservoir_oil);
1484 buffer.write(this->reservoir_gas);
1485 buffer.write(this->productivity_index_water);
1486 buffer.write(this->productivity_index_oil);
1487 buffer.write(this->productivity_index_gas);
1488 buffer.write(this->well_potential_water);
1489 buffer.write(this->well_potential_oil);
1490 buffer.write(this->well_potential_gas);
1491 buffer.write(this->brine);
1492 buffer.write(this->alq);
1495 unsigned int size = this->tracer.size();
1497 for (
const auto& [name, rate] : this->tracer) {
1502 buffer.write(this->microbial);
1503 buffer.write(this->oxygen);
1504 buffer.write(this->urea);
1505 buffer.write(this->vaporized_water);
1506 buffer.write(this->mass_gas);
1507 buffer.write(this->mass_wat);
1508 buffer.write(this->wat_frac);
1511 template <
class MessageBufferType>
1512 void ConnectionFiltrate::write(MessageBufferType& buffer)
const {
1513 buffer.write(this->rate);
1514 buffer.write(this->total);
1515 buffer.write(this->skin_factor);
1516 buffer.write(this->thickness);
1517 buffer.write(this->perm);
1518 buffer.write(this->poro);
1519 buffer.write(this->radius);
1520 buffer.write(this->area_of_flow);
1521 buffer.write(this->flow_factor);
1522 buffer.write(this->fracture_rate);
1525 template <
class MessageBufferType>
1526 void Connection::write(MessageBufferType& buffer)
const {
1527 buffer.write(this->index);
1528 this->rates.write(buffer);
1529 buffer.write(this->pressure);
1530 buffer.write(this->reservoir_rate);
1531 buffer.write(this->cell_pressure);
1532 buffer.write(this->cell_saturation_water);
1533 buffer.write(this->cell_saturation_gas);
1534 buffer.write(this->effective_Kh);
1535 buffer.write(this->trans_factor);
1536 buffer.write(this->d_factor);
1537 buffer.write(this->compact_mult);
1538 buffer.write(this->lgr_grid);
1539 this->filtrate.write(buffer);
1540 this->fracture.write(buffer);
1544 template <
class MessageBufferType>
1545 void Segment::write(MessageBufferType& buffer)
const 1547 buffer.write(this->segNumber);
1548 this->rates.write(buffer);
1549 this->pressures.write(buffer);
1550 this->velocity.write(buffer);
1551 this->holdup.write(buffer);
1552 this->viscosity.write(buffer);
1553 this->density.write(buffer);
1556 template <
class MessageBufferType>
1557 void CurrentControl::write(MessageBufferType& buffer)
const 1559 buffer.write(this->isProducer);
1560 if (this->isProducer) {
1561 buffer.write(this->
prod);
1564 buffer.write(this->
inj);
1568 template <
class MessageBufferType>
1569 void WellBlockAvgPress::write(MessageBufferType& buffer)
const 1571 for (
const auto& quantity : this->wbp_) {
1572 buffer.write(quantity);
1576 template <
class MessageBufferType>
1577 void WellFiltrate::write(MessageBufferType& buffer)
const 1579 buffer.write(this->rate);
1580 buffer.write(this->total);
1581 buffer.write(this->concentration);
1584 template <
class MessageBufferType>
1585 void Well::write(MessageBufferType& buffer)
const 1587 this->rates.write(buffer);
1589 buffer.write(this->bhp);
1590 buffer.write(this->thp);
1591 buffer.write(this->temperature);
1592 buffer.write(this->control);
1593 buffer.write(this->efficiency_scaling_factor);
1595 this->filtrate.write(buffer);
1598 const auto status = ::Opm::WellStatus2String(this->dynamicStatus);
1599 buffer.write(status);
1603 const unsigned int size = this->connections.size();
1606 for (
const Connection& comp : this->connections) {
1613 static_cast<unsigned int>(this->segments.size());
1616 for (
const auto& seg : this->segments) {
1617 seg.second.write(buffer);
1621 this->current_control.write(buffer);
1622 this->guide_rates.write(buffer);
1623 this->limits.write(buffer);
1626 template <
class MessageBufferType>
1627 void WellBlockAveragePressures::write(MessageBufferType& buffer)
const 1629 buffer.write(this->values.size());
1631 for (
const auto& [well,
value] : this->values) {
1633 value.write(buffer);
1637 template <
class MessageBufferType>
1638 void Rates::read(MessageBufferType& buffer) {
1639 buffer.read(this->mask);
1640 buffer.read(this->wat);
1641 buffer.read(this->oil);
1642 buffer.read(this->gas);
1643 buffer.read(this->polymer);
1644 buffer.read(this->solvent);
1645 buffer.read(this->energy);
1646 buffer.read(this->dissolved_gas);
1647 buffer.read(this->vaporized_oil);
1648 buffer.read(this->reservoir_water);
1649 buffer.read(this->reservoir_oil);
1650 buffer.read(this->reservoir_gas);
1651 buffer.read(this->productivity_index_water);
1652 buffer.read(this->productivity_index_oil);
1653 buffer.read(this->productivity_index_gas);
1654 buffer.read(this->well_potential_water);
1655 buffer.read(this->well_potential_oil);
1656 buffer.read(this->well_potential_gas);
1657 buffer.read(this->brine);
1658 buffer.read(this->alq);
1663 for (std::size_t i = 0; i < size; ++i) {
1664 std::string tracer_name;
1665 buffer.read(tracer_name);
1667 buffer.read(tracer_rate);
1668 this->tracer.emplace(tracer_name, tracer_rate);
1671 buffer.read(this->microbial);
1672 buffer.read(this->oxygen);
1673 buffer.read(this->urea);
1674 buffer.read(this->vaporized_water);
1675 buffer.read(this->mass_gas);
1676 buffer.read(this->mass_wat);
1677 buffer.read(this->wat_frac);
1680 template <
class MessageBufferType>
1681 void ConnectionFiltrate::read(MessageBufferType& buffer) {
1682 buffer.read(this->rate);
1683 buffer.read(this->total);
1684 buffer.read(this->skin_factor);
1685 buffer.read(this->thickness);
1686 buffer.read(this->perm);
1687 buffer.read(this->poro);
1688 buffer.read(this->radius);
1689 buffer.read(this->area_of_flow);
1690 buffer.read(this->flow_factor);
1691 buffer.read(this->fracture_rate);
1694 template <
class MessageBufferType>
1695 void Connection::read(MessageBufferType& buffer) {
1696 buffer.read(this->index);
1697 this->rates.read(buffer);
1698 buffer.read(this->pressure);
1699 buffer.read(this->reservoir_rate);
1700 buffer.read(this->cell_pressure);
1701 buffer.read(this->cell_saturation_water);
1702 buffer.read(this->cell_saturation_gas);
1703 buffer.read(this->effective_Kh);
1704 buffer.read(this->trans_factor);
1705 buffer.read(this->d_factor);
1706 buffer.read(this->compact_mult);
1707 buffer.read(this->lgr_grid);
1708 this->filtrate.read(buffer);
1709 this->fracture.read(buffer);
1713 template <
class MessageBufferType>
1714 void Segment::read(MessageBufferType& buffer)
1716 buffer.read(this->segNumber);
1717 this->rates.read(buffer);
1718 this->pressures.read(buffer);
1719 this->velocity.read(buffer);
1720 this->holdup.read(buffer);
1721 this->viscosity.read(buffer);
1722 this->density.read(buffer);
1725 template <
class MessageBufferType>
1726 void CurrentControl::read(MessageBufferType& buffer)
1728 buffer.read(this->isProducer);
1729 if (this->isProducer) {
1730 buffer.read(this->
prod);
1733 buffer.read(this->
inj);
1737 template <
class MessageBufferType>
1738 void WellBlockAvgPress::read(MessageBufferType& buffer)
1740 for (
auto& quantity : this->wbp_) {
1741 buffer.read(quantity);
1745 template <
class MessageBufferType>
1746 void WellFiltrate::read(MessageBufferType& buffer)
1748 buffer.read(this->rate);
1749 buffer.read(this->total);
1750 buffer.read(this->concentration);
1753 template <
class MessageBufferType>
1754 void Well::read(MessageBufferType& buffer)
1756 this->rates.read(buffer);
1758 buffer.read(this->bhp);
1759 buffer.read(this->thp);
1760 buffer.read(this->temperature);
1761 buffer.read(this->control);
1762 buffer.read(this->efficiency_scaling_factor);
1764 this->filtrate.read(buffer);
1767 auto status = std::string{};
1768 buffer.read(status);
1769 this->dynamicStatus = ::Opm::WellStatusFromString(status);
1774 unsigned int size = 0;
1777 this->connections.resize(size);
1778 for (
auto& connection : this->connections) {
1779 connection.read(buffer);
1784 const auto nSeg = [&buffer]() ->
unsigned int 1792 for (
auto segID = 0*nSeg; segID < nSeg; ++segID) {
1793 auto seg = Segment{};
1796 const auto segNumber = seg.segNumber;
1797 this->segments.emplace(segNumber, std::move(seg));
1800 this->current_control.read(buffer);
1801 this->guide_rates.read(buffer);
1802 this->limits.read(buffer);
1805 template <
class MessageBufferType>
1806 void WellBlockAveragePressures::read(MessageBufferType& buffer)
1808 const auto numWells = [&buffer,
this]()
1810 auto size = 0*this->values.size();
1816 auto wellName = std::string{};
1817 for (
auto well = 0*numWells; well < numWells; ++well) {
1818 buffer.read(wellName);
1820 this->values[wellName].read(buffer);
1826 #endif // OPM_OUTPUT_WELLS_HPP Definition: Wells.hpp:671
double avg
Arithmetic average.
Definition: Wells.hpp:368
Statistics collection for a single quantity.
Definition: Wells.hpp:365
Definition: UDQActive.cpp:79
bool has(opt) const
Query if a value is set.
Definition: Wells.hpp:1310
void write(MessageBufferType &buffer) const
MPI communication protocol–serialisation operation.
Definition: Wells.hpp:499
bool operator==(const ConnectionFracturing &that) const
Equality predicate.
Definition: Wells.hpp:488
Rates & set(opt m, double value)
Set the value specified by m.
Definition: Wells.hpp:1338
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: Wells.hpp:473
Definition: Wells.hpp:603
static ConnectionFracturing serializationTestObject()
Create a serialisation test object.
Definition: Wells.hpp:455
Definition: Wells.hpp:1005
Definition: Wells.hpp:1279
bool operator==(const Statistics &that) const
Equality predicate.
Definition: Wells.hpp:410
std::size_t numCells
Sample size.
Definition: Wells.hpp:443
double max
Maximum value.
Definition: Wells.hpp:371
Definition: Wells.hpp:1080
Statistics width
Statistical measures for connection's fracture fracture width.
Definition: Wells.hpp:452
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: Wells.hpp:272
Definition: Wells.hpp:216
Definition: GuideRateValue.hpp:31
double get(opt m) const
Read the value indicated by m.
Definition: Wells.hpp:1317
Definition: Wells.hpp:859
ConnectionFracturing fract
Connection level fracturing statistics.
Definition: Wells.hpp:542
Definition: Wells.hpp:819
Definition: UDQActive.cpp:103
Definition: Wells.hpp:954
Definition: Wells.hpp:786
void read(MessageBufferType &buffer)
MPI communication protocol–deserialisation operation.
Definition: Wells.hpp:509
Connection Level Fracturing Statistics.
Definition: Wells.hpp:362
double stdev
Unbiased sample standard deviation.
Definition: Wells.hpp:379
Definition: Wells.hpp:912
Definition: Wells.hpp:518
Statistics rate
Statistical measures for connection's fracture fracture flow rate.
Definition: Wells.hpp:449
Statistics press
Statistical measures for connection's fracture pressures.
Definition: Wells.hpp:446
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: Wells.hpp:395
Definition: Wells.hpp:1039
static Statistics serializationTestObject()
Create a serialization test object.
Definition: Wells.hpp:382
void read(MessageBufferType &buffer)
MPI communication protocol–deserialisation operation.
Definition: Wells.hpp:431
double min
Minimum value.
Definition: Wells.hpp:374
Definition: Wells.hpp:1198
bool flowing() const
Returns true if any of the rates oil, gas, water is nonzero.
Definition: Wells.hpp:1461
Class for (de-)serializing.
Definition: Serializer.hpp:95
void write(MessageBufferType &buffer) const
MPI communication protocol–serialisation operation.
Definition: Wells.hpp:421