mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
SegmentState: template Scalar type
This commit is contained in:
@@ -864,7 +864,7 @@ accelerationPressureLossContribution(const int seg,
|
||||
template <class FluidSystem, class Indices>
|
||||
void
|
||||
MultisegmentWellSegments<FluidSystem,Indices>::
|
||||
copyPhaseDensities(const PhaseUsage& pu, SegmentState& segSol) const
|
||||
copyPhaseDensities(const PhaseUsage& pu, SegmentState<Scalar>& segSol) const
|
||||
{
|
||||
auto* rho = segSol.phase_density.data();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Opm {
|
||||
|
||||
class AutoICD;
|
||||
struct PhaseUsage;
|
||||
class SegmentState;
|
||||
template<class Scalar> class SegmentState;
|
||||
class UnitSystem;
|
||||
class WellInterfaceGeneric;
|
||||
class SummaryState;
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
}
|
||||
|
||||
void copyPhaseDensities(const PhaseUsage& pu,
|
||||
SegmentState& segSol) const;
|
||||
SegmentState<Scalar>& segSol) const;
|
||||
|
||||
private:
|
||||
// TODO: trying to use the information from the Well opm-parser as much
|
||||
@@ -141,8 +141,8 @@ private:
|
||||
// the completions's ids are their index in the vector well_index_, well_cell_
|
||||
// This is also assuming the order of the completions in Well is the same with
|
||||
// the order of the completions in wells.
|
||||
// it is for convinience reason. we can just calcuate the inforation for segment once then using it for all the perofrations
|
||||
// belonging to this segment
|
||||
// it is for convenience reason. we can just calculate the information for segment once
|
||||
// then using it for all the perforations belonging to this segment
|
||||
std::vector<std::vector<int>> perforations_;
|
||||
|
||||
// depth difference between the segment and the perforation
|
||||
|
||||
@@ -50,10 +50,10 @@ std::vector<int> make_segment_number(const Opm::WellSegments& segments)
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
namespace Opm {
|
||||
|
||||
SegmentState::SegmentState(int num_phases, const WellSegments& segments)
|
||||
template<class Scalar>
|
||||
SegmentState<Scalar>::SegmentState(int num_phases, const WellSegments& segments)
|
||||
: rates (segments.size() * num_phases)
|
||||
, dissolved_gas_rate (segments.size())
|
||||
, vaporized_oil_rate (segments.size())
|
||||
@@ -69,7 +69,8 @@ SegmentState::SegmentState(int num_phases, const WellSegments& segments)
|
||||
, m_segment_number (make_segment_number(segments))
|
||||
{}
|
||||
|
||||
SegmentState SegmentState::serializationTestObject()
|
||||
template<class Scalar>
|
||||
SegmentState<Scalar> SegmentState<Scalar>::serializationTestObject()
|
||||
{
|
||||
SegmentState result;
|
||||
result.rates = {1.0, 2.0};
|
||||
@@ -89,19 +90,27 @@ SegmentState SegmentState::serializationTestObject()
|
||||
return result;
|
||||
}
|
||||
|
||||
double SegmentState::pressure_drop(std::size_t index) const {
|
||||
template<class Scalar>
|
||||
Scalar SegmentState<Scalar>::pressure_drop(std::size_t index) const
|
||||
{
|
||||
return this->pressure_drop_friction[index] + this->pressure_drop_hydrostatic[index] + this->pressure_drop_accel[index];
|
||||
}
|
||||
|
||||
bool SegmentState::empty() const {
|
||||
template<class Scalar>
|
||||
bool SegmentState<Scalar>::empty() const
|
||||
{
|
||||
return this->rates.empty();
|
||||
}
|
||||
|
||||
std::size_t SegmentState::size() const {
|
||||
template<class Scalar>
|
||||
std::size_t SegmentState<Scalar>::size() const
|
||||
{
|
||||
return this->pressure.size();
|
||||
}
|
||||
|
||||
void SegmentState::scale_pressure(const double bhp) {
|
||||
template<class Scalar>
|
||||
void SegmentState<Scalar>::scale_pressure(const Scalar bhp)
|
||||
{
|
||||
if (this->empty())
|
||||
throw std::logic_error("Tried to pressure scale empty SegmentState");
|
||||
|
||||
@@ -110,14 +119,18 @@ void SegmentState::scale_pressure(const double bhp) {
|
||||
std::transform(this->pressure.begin(),
|
||||
this->pressure.end(),
|
||||
this->pressure.begin(),
|
||||
[pressure_change] (const double& p) { return p + pressure_change;});
|
||||
[pressure_change] (const Scalar& p) { return p + pressure_change;});
|
||||
}
|
||||
|
||||
const std::vector<int>& SegmentState::segment_number() const {
|
||||
template<class Scalar>
|
||||
const std::vector<int>&
|
||||
SegmentState<Scalar>::segment_number() const
|
||||
{
|
||||
return this->m_segment_number;
|
||||
}
|
||||
|
||||
bool SegmentState::operator==(const SegmentState& rhs) const
|
||||
template<class Scalar>
|
||||
bool SegmentState<Scalar>::operator==(const SegmentState& rhs) const
|
||||
{
|
||||
return this->rates == rhs.rates &&
|
||||
this->dissolved_gas_rate == rhs.dissolved_gas_rate &&
|
||||
@@ -134,4 +147,6 @@ bool SegmentState::operator==(const SegmentState& rhs) const
|
||||
this->m_segment_number == rhs.m_segment_number;
|
||||
}
|
||||
|
||||
template class SegmentState<double>;
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
@@ -23,14 +23,13 @@
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
namespace Opm {
|
||||
class WellSegments;
|
||||
} // namespace Opm
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
namespace Opm {
|
||||
|
||||
template<class Scalar>
|
||||
class SegmentState
|
||||
{
|
||||
public:
|
||||
@@ -39,9 +38,9 @@ public:
|
||||
|
||||
static SegmentState serializationTestObject();
|
||||
|
||||
double pressure_drop(std::size_t index) const;
|
||||
Scalar pressure_drop(std::size_t index) const;
|
||||
bool empty() const;
|
||||
void scale_pressure(double bhp);
|
||||
void scale_pressure(Scalar bhp);
|
||||
|
||||
const std::vector<int>& segment_number() const;
|
||||
std::size_t size() const;
|
||||
@@ -66,21 +65,21 @@ public:
|
||||
|
||||
bool operator==(const SegmentState&) const;
|
||||
|
||||
std::vector<double> rates;
|
||||
std::vector<double> dissolved_gas_rate;
|
||||
std::vector<double> vaporized_oil_rate;
|
||||
std::vector<Scalar> rates;
|
||||
std::vector<Scalar> dissolved_gas_rate;
|
||||
std::vector<Scalar> vaporized_oil_rate;
|
||||
|
||||
/// Segment condition volume flow rates through segment (per phase)
|
||||
std::vector<double> phase_resv_rates;
|
||||
std::vector<Scalar> phase_resv_rates;
|
||||
|
||||
/// Segment condition flow velocity through segment (per phase)
|
||||
std::vector<double> phase_velocity;
|
||||
std::vector<Scalar> phase_velocity;
|
||||
|
||||
/// Segment condition holdup fractions through segment (per phase)
|
||||
std::vector<double> phase_holdup;
|
||||
std::vector<Scalar> phase_holdup;
|
||||
|
||||
/// Segment condition phase viscosities.
|
||||
std::vector<double> phase_viscosity;
|
||||
std::vector<Scalar> phase_viscosity;
|
||||
|
||||
/// Segment condition phase densities.
|
||||
///
|
||||
@@ -98,12 +97,12 @@ public:
|
||||
/// { p0, p1, ..., (np - 1), mixture, mixture_with_exponents },
|
||||
/// ...
|
||||
/// { p0, p1, ..., (np - 1), mixture, mixture_with_exponents }]
|
||||
std::vector<double> phase_density;
|
||||
std::vector<Scalar> phase_density;
|
||||
|
||||
std::vector<double> pressure;
|
||||
std::vector<double> pressure_drop_friction;
|
||||
std::vector<double> pressure_drop_hydrostatic;
|
||||
std::vector<double> pressure_drop_accel;
|
||||
std::vector<Scalar> pressure;
|
||||
std::vector<Scalar> pressure_drop_friction;
|
||||
std::vector<Scalar> pressure_drop_hydrostatic;
|
||||
std::vector<Scalar> pressure_drop_accel;
|
||||
|
||||
private:
|
||||
std::vector<int> m_segment_number;
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
std::vector<double> prev_surface_rates;
|
||||
PerfData<double> perf_data;
|
||||
bool trivial_target;
|
||||
SegmentState segments;
|
||||
SegmentState<double> segments;
|
||||
Events events;
|
||||
WellInjectorCMode injection_cmode{WellInjectorCMode::CMODE_UNDEFINED};
|
||||
WellProducerCMode production_cmode{WellProducerCMode::CMODE_UNDEFINED};
|
||||
|
||||
@@ -677,7 +677,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
|
||||
// assuming the order of the perforations in well_ecl is the same with Wells
|
||||
const WellConnections& completion_set = well_ecl.getConnections();
|
||||
// number of segment for this single well
|
||||
ws.segments = SegmentState{np, segment_set};
|
||||
ws.segments = SegmentState<double>{np, segment_set};
|
||||
const int well_nseg = segment_set.size();
|
||||
int n_activeperf = 0;
|
||||
|
||||
|
||||
@@ -109,7 +109,8 @@ namespace Opm { using PerfD = PerfData<double>; }
|
||||
TEST_FOR_TYPE_NAMED(PerfD, PerfData)
|
||||
TEST_FOR_TYPE(PIDAndIterationCountTimeStepControl)
|
||||
TEST_FOR_TYPE(PIDTimeStepControl)
|
||||
TEST_FOR_TYPE(SegmentState)
|
||||
namespace Opm { using SegmState = SegmentState<double>; }
|
||||
TEST_FOR_TYPE_NAMED(SegmState, SegmentState)
|
||||
TEST_FOR_TYPE(SimpleIterationCountTimeStepControl)
|
||||
TEST_FOR_TYPE(SimulatorReport)
|
||||
TEST_FOR_TYPE(SimulatorReportSingle)
|
||||
|
||||
@@ -511,8 +511,8 @@ BOOST_AUTO_TEST_CASE(TESTSegmentState) {
|
||||
const Setup setup{ "msw.data" };
|
||||
const auto& well = setup.sched.getWell("PROD01", 0);
|
||||
const auto& segments = well.getSegments();
|
||||
Opm::SegmentState ss1(3, segments);
|
||||
Opm::SegmentState ss2;
|
||||
Opm::SegmentState<double> ss1(3, segments);
|
||||
Opm::SegmentState<double> ss2;
|
||||
|
||||
|
||||
ss1.pressure_drop_hydrostatic[0] = 1;
|
||||
|
||||
Reference in New Issue
Block a user