addressing reviewing comments from OPM/opm-common#1695
This commit is contained in:
@@ -150,23 +150,63 @@ namespace Opm {
|
||||
void read(MessageBufferType& buffer);
|
||||
};
|
||||
|
||||
class SegmentPressures {
|
||||
public:
|
||||
enum class Value : std::size_t {
|
||||
Pressure, PDrop, PDropHydrostatic, PDropAccel, PDropFriction,
|
||||
};
|
||||
|
||||
double& operator[](const Value i)
|
||||
{
|
||||
return this->values_[this->index(i)];
|
||||
}
|
||||
|
||||
double operator[](const Value i) const
|
||||
{
|
||||
return this->values_[this->index(i)];
|
||||
}
|
||||
|
||||
bool operator==(const SegmentPressures& segpres2) const
|
||||
{
|
||||
return this->values_ == segpres2.values_;
|
||||
}
|
||||
|
||||
template <class MessageBufferType>
|
||||
void write(MessageBufferType& buffer) const
|
||||
{
|
||||
for (const auto& value : this->values_) {
|
||||
buffer.write(value);
|
||||
}
|
||||
}
|
||||
|
||||
template <class MessageBufferType>
|
||||
void read(MessageBufferType& buffer)
|
||||
{
|
||||
for (auto& value : this->values_) {
|
||||
buffer.read(value);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
constexpr static std::size_t numvals = 5;
|
||||
|
||||
std::array<double, numvals> values_;
|
||||
|
||||
std::size_t index(const Value ix) const
|
||||
{
|
||||
return static_cast<std::size_t>(ix);
|
||||
}
|
||||
};
|
||||
|
||||
struct Segment {
|
||||
Rates rates;
|
||||
double pressure;
|
||||
double pressure_drop;
|
||||
double pressure_drop_hydrostatic;
|
||||
double pressure_drop_acceleration;
|
||||
double pressure_drop_friction;
|
||||
SegmentPressures pressures;
|
||||
std::size_t segNumber;
|
||||
|
||||
bool operator==(const Segment& seg2) const
|
||||
{
|
||||
return rates == seg2.rates &&
|
||||
pressure == seg2.pressure &&
|
||||
pressure_drop == seg2.pressure_drop &&
|
||||
pressure_drop_hydrostatic == seg2.pressure_drop_hydrostatic &&
|
||||
pressure_drop_friction == seg2.pressure_drop_friction &&
|
||||
pressure_drop_acceleration == seg2.pressure_drop_acceleration &&
|
||||
pressures == seg2.pressures &&
|
||||
segNumber == seg2.segNumber;
|
||||
}
|
||||
|
||||
@@ -460,11 +500,7 @@ namespace Opm {
|
||||
void Segment::write(MessageBufferType& buffer) const {
|
||||
buffer.write(this->segNumber);
|
||||
this->rates.write(buffer);
|
||||
buffer.write(this->pressure);
|
||||
buffer.write(this->pressure_drop);
|
||||
buffer.write(this->pressure_drop_hydrostatic);
|
||||
buffer.write(this->pressure_drop_friction);
|
||||
buffer.write(this->pressure_drop_acceleration);
|
||||
this->pressures.write(buffer);
|
||||
}
|
||||
|
||||
template <class MessageBufferType>
|
||||
@@ -542,11 +578,7 @@ namespace Opm {
|
||||
void Segment::read(MessageBufferType& buffer) {
|
||||
buffer.read(this->segNumber);
|
||||
this->rates.read(buffer);
|
||||
buffer.read(this->pressure);
|
||||
buffer.read(this->pressure_drop);
|
||||
buffer.read(this->pressure_drop_hydrostatic);
|
||||
buffer.read(this->pressure_drop_friction);
|
||||
buffer.read(this->pressure_drop_acceleration);
|
||||
this->pressures.read(buffer);
|
||||
}
|
||||
|
||||
template <class MessageBufferType>
|
||||
|
||||
@@ -1098,7 +1098,7 @@ namespace {
|
||||
auto& segment = xw.segments[segNumber];
|
||||
|
||||
segment.segNumber = segNumber;
|
||||
segment.pressure =
|
||||
segment.pressures[Opm::data::SegmentPressures::Value::Pressure] =
|
||||
usys.to_si(M::pressure, rseg[VI::RSeg::index::Pressure]);
|
||||
|
||||
const auto totFlow = rseg[VI::RSeg::index::TotFlowRate];
|
||||
|
||||
@@ -568,7 +568,8 @@ inline quantity trans_factors ( const fn_args& args ) {
|
||||
return { v, measure::transmissibility };
|
||||
}
|
||||
|
||||
inline quantity spr ( const fn_args& args ) {
|
||||
template <Opm::data::SegmentPressures::Value ix>
|
||||
inline quantity segpress ( const fn_args& args ) {
|
||||
const quantity zero = { 0, measure::pressure };
|
||||
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
@@ -588,104 +589,7 @@ inline quantity spr ( const fn_args& args ) {
|
||||
if( segment == well_data.segments.end() ) return zero;
|
||||
|
||||
|
||||
const auto& v = segment->second.pressure;
|
||||
return { v, measure::pressure };
|
||||
}
|
||||
|
||||
inline quantity sprd ( const fn_args& args ) {
|
||||
const quantity zero = { 0, measure::pressure };
|
||||
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
// Like completion rate we need to look
|
||||
// up a connection with offset 0.
|
||||
const size_t segNumber = args.num;
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
|
||||
const auto& well = args.schedule_wells.front();
|
||||
const auto& name = well.name();
|
||||
if( args.wells.count( name ) == 0 ) return zero;
|
||||
|
||||
const auto& well_data = args.wells.at( name );
|
||||
|
||||
const auto& segment = well_data.segments.find(segNumber);
|
||||
|
||||
if( segment == well_data.segments.end() ) return zero;
|
||||
|
||||
|
||||
const auto& v = segment->second.pressure_drop;
|
||||
return { v, measure::pressure };
|
||||
}
|
||||
|
||||
inline quantity sprdh ( const fn_args& args ) {
|
||||
const quantity zero = { 0, measure::pressure };
|
||||
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
// Like completion rate we need to look
|
||||
// up a connection with offset 0.
|
||||
const size_t segNumber = args.num;
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
|
||||
const auto& well = args.schedule_wells.front();
|
||||
const auto& name = well.name();
|
||||
if( args.wells.count( name ) == 0 ) return zero;
|
||||
|
||||
const auto& well_data = args.wells.at( name );
|
||||
|
||||
const auto& segment = well_data.segments.find(segNumber);
|
||||
|
||||
if( segment == well_data.segments.end() ) return zero;
|
||||
|
||||
|
||||
const auto& v = segment->second.pressure_drop_hydrostatic;
|
||||
return { v, measure::pressure };
|
||||
}
|
||||
|
||||
inline quantity sprdf ( const fn_args& args ) {
|
||||
const quantity zero = { 0, measure::pressure };
|
||||
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
// Like completion rate we need to look
|
||||
// up a connection with offset 0.
|
||||
const size_t segNumber = args.num;
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
|
||||
const auto& well = args.schedule_wells.front();
|
||||
const auto& name = well.name();
|
||||
if( args.wells.count( name ) == 0 ) return zero;
|
||||
|
||||
const auto& well_data = args.wells.at( name );
|
||||
|
||||
const auto& segment = well_data.segments.find(segNumber);
|
||||
|
||||
if( segment == well_data.segments.end() ) return zero;
|
||||
|
||||
|
||||
const auto& v = segment->second.pressure_drop_friction;
|
||||
return { v, measure::pressure };
|
||||
}
|
||||
|
||||
inline quantity sprda ( const fn_args& args ) {
|
||||
const quantity zero = { 0, measure::pressure };
|
||||
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
// Like completion rate we need to look
|
||||
// up a connection with offset 0.
|
||||
const size_t segNumber = args.num;
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
|
||||
const auto& well = args.schedule_wells.front();
|
||||
const auto& name = well.name();
|
||||
if( args.wells.count( name ) == 0 ) return zero;
|
||||
|
||||
const auto& well_data = args.wells.at( name );
|
||||
|
||||
const auto& segment = well_data.segments.find(segNumber);
|
||||
|
||||
if( segment == well_data.segments.end() ) return zero;
|
||||
|
||||
|
||||
const auto& v = segment->second.pressure_drop_acceleration;
|
||||
return { v, measure::pressure };
|
||||
return { segment->second.pressures[ix], measure::pressure };
|
||||
}
|
||||
|
||||
inline quantity bhp( const fn_args& args ) {
|
||||
@@ -1304,11 +1208,11 @@ static const std::unordered_map< std::string, ofun > funs = {
|
||||
{ "SOFR", srate< rt::oil > },
|
||||
{ "SWFR", srate< rt::wat > },
|
||||
{ "SGFR", srate< rt::gas > },
|
||||
{ "SPR", spr },
|
||||
{ "SPRD", sprd },
|
||||
{ "SPRDH", sprdh },
|
||||
{ "SPRDF", sprdf },
|
||||
{ "SPRDA", sprda },
|
||||
{ "SPR", segpress<Opm::data::SegmentPressures::Value::Pressure> },
|
||||
{ "SPRD", segpress<Opm::data::SegmentPressures::Value::PDrop> },
|
||||
{ "SPRDH", segpress<Opm::data::SegmentPressures::Value::PDropHydrostatic> },
|
||||
{ "SPRDF", segpress<Opm::data::SegmentPressures::Value::PDropFriction> },
|
||||
{ "SPRDA", segpress<Opm::data::SegmentPressures::Value::PDropAccel> },
|
||||
// Well productivity index
|
||||
{ "WPIW", potential_rate< rt::productivity_index_water >},
|
||||
{ "WPIO", potential_rate< rt::productivity_index_oil >},
|
||||
|
||||
@@ -224,7 +224,10 @@ static data::Wells result_wells() {
|
||||
segment.rates.set(rt::wat, 123.45*sm3_pr_day());
|
||||
segment.rates.set(rt::oil, 543.21*sm3_pr_day());
|
||||
segment.rates.set(rt::gas, 1729.496*sm3_pr_day());
|
||||
segment.pressure = 314.159*unit::barsa;
|
||||
{
|
||||
const auto pres_idx = Opm::data::SegmentPressures::Value::Pressure;
|
||||
segment.pressures[pres_idx] = 314.159*unit::barsa;
|
||||
}
|
||||
segment.segNumber = 1;
|
||||
|
||||
/*
|
||||
@@ -1561,7 +1564,8 @@ BOOST_AUTO_TEST_CASE(READ_WRITE_WELLDATA) {
|
||||
BOOST_CHECK_CLOSE(seg.rates.get(rt::wat), 123.45*sm3_pr_day(), 1.0e-10);
|
||||
BOOST_CHECK_CLOSE(seg.rates.get(rt::oil), 543.21*sm3_pr_day(), 1.0e-10);
|
||||
BOOST_CHECK_CLOSE(seg.rates.get(rt::gas), 1729.496*sm3_pr_day(), 1.0e-10);
|
||||
BOOST_CHECK_CLOSE(seg.pressure, 314.159*unit::barsa, 1.0e-10);
|
||||
const auto pres_idx = Opm::data::SegmentPressures::Value::Pressure;
|
||||
BOOST_CHECK_CLOSE(seg.pressures[pres_idx], 314.159*unit::barsa, 1.0e-10);
|
||||
BOOST_CHECK_EQUAL(seg.segNumber, 1);
|
||||
|
||||
// No data for segment 10 of well W_2 (or no such segment).
|
||||
@@ -2462,7 +2466,8 @@ namespace {
|
||||
|
||||
fill_surface_rates(segID, sign, res.rates);
|
||||
|
||||
res.pressure = (100.0 + segID)*unit::barsa;
|
||||
const auto pres_idx = Opm::data::SegmentPressures::Value::Pressure;
|
||||
res.pressures[pres_idx] = (100.0 + segID)*unit::barsa;
|
||||
|
||||
res.segNumber = segID;
|
||||
|
||||
|
||||
@@ -154,7 +154,10 @@ static data::Wells result_wells() {
|
||||
segment.rates.set(rt::wat, 123.45*sm3_pr_day());
|
||||
segment.rates.set(rt::oil, 543.21*sm3_pr_day());
|
||||
segment.rates.set(rt::gas, 1729.496*sm3_pr_day());
|
||||
segment.pressure = 314.159*unit::barsa;
|
||||
{
|
||||
const auto pres_idx = Opm::data::SegmentPressures::Value::Pressure;
|
||||
segment.pressures[pres_idx] = 314.159*unit::barsa;
|
||||
}
|
||||
segment.segNumber = 1;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user