mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
SingleWellState: template Scalar type
This commit is contained in:
parent
e46e52f3dc
commit
ab0e696709
@ -1206,7 +1206,7 @@ updateNetworkPressures(const int reportStepIdx)
|
||||
// set the dynamic THP constraint of the well accordingly.
|
||||
const double new_limit = it->second;
|
||||
well->setDynamicThpLimit(new_limit);
|
||||
SingleWellState& ws = this->wellState()[well->indexOfWell()];
|
||||
SingleWellState<double>& ws = this->wellState()[well->indexOfWell()];
|
||||
const bool thp_is_limit = ws.production_cmode == Well::ProducerCMode::THP;
|
||||
// TODO: not sure why the thp is NOT updated properly elsewhere
|
||||
if (thp_is_limit) {
|
||||
|
@ -71,7 +71,7 @@ void BlackoilWellModelRestart::
|
||||
loadRestartConnectionData(const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& ws) const
|
||||
SingleWellState<double>& ws) const
|
||||
{
|
||||
auto& perf_data = ws.perf_data;
|
||||
auto perf_pressure = perf_data.pressure.begin();
|
||||
@ -95,7 +95,7 @@ void BlackoilWellModelRestart::
|
||||
loadRestartSegmentData(const std::string& well_name,
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
SingleWellState& ws) const
|
||||
SingleWellState<double>& ws) const
|
||||
{
|
||||
const auto& segment_set = wellModel_.getWellEcl(well_name).getSegments();
|
||||
const auto& rst_segments = rst_well.segments;
|
||||
@ -128,7 +128,7 @@ loadRestartWellData(const std::string& well_name,
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& ws) const
|
||||
SingleWellState<double>& ws) const
|
||||
{
|
||||
const auto np = phs.size();
|
||||
|
||||
|
@ -40,7 +40,7 @@ class GuideRate;
|
||||
class GuideRateConfig;
|
||||
struct PerforationData;
|
||||
struct PhaseUsage;
|
||||
class SingleWellState;
|
||||
template<class Scalar> class SingleWellState;
|
||||
class WellState;
|
||||
|
||||
/// Class for restarting the blackoil well model.
|
||||
@ -76,13 +76,13 @@ private:
|
||||
void loadRestartConnectionData(const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& ws) const;
|
||||
SingleWellState<double>& ws) const;
|
||||
|
||||
//! \brief Loads per-segment data from restart structures.
|
||||
void loadRestartSegmentData(const std::string& well_name,
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
SingleWellState& ws) const;
|
||||
SingleWellState<double>& ws) const;
|
||||
|
||||
//! \brief Loads per-well data from restart structures.
|
||||
void loadRestartWellData(const std::string& well_name,
|
||||
@ -90,7 +90,7 @@ private:
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& ws) const;
|
||||
SingleWellState<double>& ws) const;
|
||||
|
||||
//! \brief Loads per-group data from restart structures.
|
||||
void loadRestartGroupData(const std::string& group,
|
||||
|
@ -28,13 +28,15 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
SingleWellState::SingleWellState(const std::string& name_,
|
||||
const ParallelWellInfo& pinfo,
|
||||
bool is_producer,
|
||||
double pressure_first_connection,
|
||||
const std::vector<PerforationData>& perf_input,
|
||||
const PhaseUsage& pu_,
|
||||
double temp)
|
||||
template<class Scalar>
|
||||
SingleWellState<Scalar>::
|
||||
SingleWellState(const std::string& name_,
|
||||
const ParallelWellInfo& pinfo,
|
||||
bool is_producer,
|
||||
Scalar pressure_first_connection,
|
||||
const std::vector<PerforationData>& perf_input,
|
||||
const PhaseUsage& pu_,
|
||||
Scalar temp)
|
||||
: name(name_)
|
||||
, parallel_info(pinfo)
|
||||
, producer(is_producer)
|
||||
@ -59,15 +61,19 @@ SingleWellState::SingleWellState(const std::string& name_,
|
||||
}
|
||||
}
|
||||
|
||||
SingleWellState SingleWellState::serializationTestObject(const ParallelWellInfo& pinfo)
|
||||
template<class Scalar>
|
||||
SingleWellState<Scalar> SingleWellState<Scalar>::
|
||||
serializationTestObject(const ParallelWellInfo& pinfo)
|
||||
{
|
||||
SingleWellState result("testing", pinfo, true, 1.0, {}, PhaseUsage{}, 2.0);
|
||||
result.perf_data = PerfData<double>::serializationTestObject();
|
||||
result.perf_data = PerfData<Scalar>::serializationTestObject();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SingleWellState::init_timestep(const SingleWellState& other) {
|
||||
template<class Scalar>
|
||||
void SingleWellState<Scalar>::init_timestep(const SingleWellState& other)
|
||||
{
|
||||
if (this->producer != other.producer)
|
||||
return;
|
||||
|
||||
@ -82,8 +88,9 @@ void SingleWellState::init_timestep(const SingleWellState& other) {
|
||||
this->temperature = other.temperature;
|
||||
}
|
||||
|
||||
|
||||
void SingleWellState::shut() {
|
||||
template<class Scalar>
|
||||
void SingleWellState<Scalar>::shut()
|
||||
{
|
||||
this->bhp = 0;
|
||||
this->thp = 0;
|
||||
this->status = Well::Status::SHUT;
|
||||
@ -98,16 +105,22 @@ void SingleWellState::shut() {
|
||||
connpi.assign(connpi.size(), 0);
|
||||
}
|
||||
|
||||
void SingleWellState::stop() {
|
||||
template<class Scalar>
|
||||
void SingleWellState<Scalar>::stop()
|
||||
{
|
||||
this->thp = 0;
|
||||
this->status = Well::Status::STOP;
|
||||
}
|
||||
|
||||
void SingleWellState::open() {
|
||||
template<class Scalar>
|
||||
void SingleWellState<Scalar>::open()
|
||||
{
|
||||
this->status = Well::Status::OPEN;
|
||||
}
|
||||
|
||||
void SingleWellState::updateStatus(Well::Status new_status) {
|
||||
template<class Scalar>
|
||||
void SingleWellState<Scalar>::updateStatus(Well::Status new_status)
|
||||
{
|
||||
switch (new_status) {
|
||||
case Well::Status::OPEN:
|
||||
this->open();
|
||||
@ -123,8 +136,11 @@ void SingleWellState::updateStatus(Well::Status new_status) {
|
||||
}
|
||||
}
|
||||
|
||||
void SingleWellState::reset_connection_factors(const std::vector<PerforationData>& new_perf_data) {
|
||||
if (this->perf_data.size() != new_perf_data.size()) {
|
||||
template<class Scalar>
|
||||
void SingleWellState<Scalar>::
|
||||
reset_connection_factors(const std::vector<PerforationData>& new_perf_data)
|
||||
{
|
||||
if (this->perf_data.size() != new_perf_data.size()) {
|
||||
throw std::invalid_argument {
|
||||
"Size mismatch for perforation data in well " + this->name
|
||||
};
|
||||
@ -152,39 +168,52 @@ void SingleWellState::reset_connection_factors(const std::vector<PerforationData
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double SingleWellState::sum_connection_rates(const std::vector<double>& connection_rates) const {
|
||||
template<class Scalar>
|
||||
Scalar SingleWellState<Scalar>::
|
||||
sum_connection_rates(const std::vector<Scalar>& connection_rates) const
|
||||
{
|
||||
return this->parallel_info.get().sumPerfValues(connection_rates.begin(), connection_rates.end());
|
||||
}
|
||||
|
||||
double SingleWellState::sum_brine_rates() const {
|
||||
template<class Scalar>
|
||||
Scalar SingleWellState<Scalar>::sum_brine_rates() const
|
||||
{
|
||||
return this->sum_connection_rates(this->perf_data.brine_rates);
|
||||
}
|
||||
|
||||
|
||||
double SingleWellState::sum_polymer_rates() const {
|
||||
template<class Scalar>
|
||||
Scalar SingleWellState<Scalar>::sum_polymer_rates() const
|
||||
{
|
||||
return this->sum_connection_rates(this->perf_data.polymer_rates);
|
||||
}
|
||||
|
||||
|
||||
double SingleWellState::sum_solvent_rates() const {
|
||||
template<class Scalar>
|
||||
Scalar SingleWellState<Scalar>::sum_solvent_rates() const
|
||||
{
|
||||
return this->sum_connection_rates(this->perf_data.solvent_rates);
|
||||
}
|
||||
|
||||
double SingleWellState::sum_filtrate_rate() const {
|
||||
template<class Scalar>
|
||||
Scalar SingleWellState<Scalar>::sum_filtrate_rate() const
|
||||
{
|
||||
if (this->producer) return 0.;
|
||||
|
||||
return this->sum_connection_rates(this->perf_data.filtrate_data.rates);
|
||||
}
|
||||
|
||||
double SingleWellState::sum_filtrate_total() const {
|
||||
template<class Scalar>
|
||||
Scalar SingleWellState<Scalar>::sum_filtrate_total() const
|
||||
{
|
||||
if (this->producer) return 0.;
|
||||
|
||||
return this->sum_connection_rates(this->perf_data.filtrate_data.total);
|
||||
}
|
||||
|
||||
void SingleWellState::update_producer_targets(const Well& ecl_well, const SummaryState& st) {
|
||||
const double bhp_safety_factor = 0.99;
|
||||
template<class Scalar>
|
||||
void SingleWellState<Scalar>::
|
||||
update_producer_targets(const Well& ecl_well, const SummaryState& st)
|
||||
{
|
||||
constexpr Scalar bhp_safety_factor = 0.99;
|
||||
const auto& prod_controls = ecl_well.productionControls(st);
|
||||
|
||||
auto cmode_is_bhp = (prod_controls.cmode == Well::ProducerCMode::BHP);
|
||||
@ -239,11 +268,13 @@ void SingleWellState::update_producer_targets(const Well& ecl_well, const Summar
|
||||
this->bhp = bhp_limit;
|
||||
else
|
||||
this->bhp = this->perf_data.pressure_first_connection * bhp_safety_factor;
|
||||
|
||||
}
|
||||
|
||||
void SingleWellState::update_injector_targets(const Well& ecl_well, const SummaryState& st) {
|
||||
const double bhp_safety_factor = 1.01;
|
||||
template<class Scalar>
|
||||
void SingleWellState<Scalar>::
|
||||
update_injector_targets(const Well& ecl_well, const SummaryState& st)
|
||||
{
|
||||
const Scalar bhp_safety_factor = 1.01;
|
||||
const auto& inj_controls = ecl_well.injectionControls(st);
|
||||
|
||||
if (inj_controls.hasControl(Well::InjectorCMode::THP))
|
||||
@ -262,7 +293,7 @@ void SingleWellState::update_injector_targets(const Well& ecl_well, const Summar
|
||||
}
|
||||
|
||||
// we initialize all open wells with a rate to avoid singularities
|
||||
double inj_surf_rate = 10.0 * Opm::unit::cubic(Opm::unit::meter) / Opm::unit::day;
|
||||
Scalar inj_surf_rate = 10.0 * Opm::unit::cubic(Opm::unit::meter) / Opm::unit::day;
|
||||
if (inj_controls.cmode == Well::InjectorCMode::RATE) {
|
||||
inj_surf_rate = inj_controls.surface_rate;
|
||||
}
|
||||
@ -291,14 +322,18 @@ void SingleWellState::update_injector_targets(const Well& ecl_well, const Summar
|
||||
this->bhp = this->perf_data.pressure_first_connection * bhp_safety_factor;
|
||||
}
|
||||
|
||||
void SingleWellState::update_targets(const Well& ecl_well, const SummaryState& st) {
|
||||
template<class Scalar>
|
||||
void SingleWellState<Scalar>::
|
||||
update_targets(const Well& ecl_well, const SummaryState& st)
|
||||
{
|
||||
if (this->producer)
|
||||
this->update_producer_targets(ecl_well, st);
|
||||
else
|
||||
this->update_injector_targets(ecl_well, st);
|
||||
}
|
||||
|
||||
bool SingleWellState::operator==(const SingleWellState& rhs) const
|
||||
template<class Scalar>
|
||||
bool SingleWellState<Scalar>::operator==(const SingleWellState& rhs) const
|
||||
{
|
||||
return this->name == rhs.name &&
|
||||
this->status == rhs.status &&
|
||||
@ -323,4 +358,6 @@ bool SingleWellState::operator==(const SingleWellState& rhs) const
|
||||
this->production_cmode == rhs.production_cmode;
|
||||
}
|
||||
|
||||
template class SingleWellState<double>;
|
||||
|
||||
}
|
||||
|
@ -37,15 +37,16 @@ struct PerforationData;
|
||||
class SummaryState;
|
||||
class Well;
|
||||
|
||||
template<class Scalar>
|
||||
class SingleWellState {
|
||||
public:
|
||||
SingleWellState(const std::string& name,
|
||||
const ParallelWellInfo& pinfo,
|
||||
bool is_producer,
|
||||
double presssure_first_connection,
|
||||
Scalar presssure_first_connection,
|
||||
const std::vector<PerforationData>& perf_input,
|
||||
const PhaseUsage& pu,
|
||||
double temp);
|
||||
Scalar temp);
|
||||
|
||||
static SingleWellState serializationTestObject(const ParallelWellInfo& pinfo);
|
||||
|
||||
@ -83,14 +84,14 @@ public:
|
||||
WellStatus status{WellStatus::OPEN};
|
||||
bool producer;
|
||||
PhaseUsage pu;
|
||||
double bhp{0};
|
||||
double thp{0};
|
||||
double temperature{0};
|
||||
Scalar bhp{0};
|
||||
Scalar thp{0};
|
||||
Scalar temperature{0};
|
||||
|
||||
// filtration injection concentration
|
||||
double filtrate_conc{0};
|
||||
Scalar filtrate_conc{0};
|
||||
|
||||
std::array<double,4> phase_mixing_rates{};
|
||||
std::array<Scalar,4> phase_mixing_rates{};
|
||||
enum RateIndices {
|
||||
dissolved_gas = 0,
|
||||
dissolved_gas_in_water = 1,
|
||||
@ -98,16 +99,16 @@ public:
|
||||
vaporized_water = 3
|
||||
};
|
||||
|
||||
std::vector<double> well_potentials;
|
||||
std::vector<double> productivity_index;
|
||||
std::vector<double> implicit_ipr_a;
|
||||
std::vector<double> implicit_ipr_b;
|
||||
std::vector<double> surface_rates;
|
||||
std::vector<double> reservoir_rates;
|
||||
std::vector<double> prev_surface_rates;
|
||||
PerfData<double> perf_data;
|
||||
std::vector<Scalar> well_potentials;
|
||||
std::vector<Scalar> productivity_index;
|
||||
std::vector<Scalar> implicit_ipr_a;
|
||||
std::vector<Scalar> implicit_ipr_b;
|
||||
std::vector<Scalar> surface_rates;
|
||||
std::vector<Scalar> reservoir_rates;
|
||||
std::vector<Scalar> prev_surface_rates;
|
||||
PerfData<Scalar> perf_data;
|
||||
bool trivial_target;
|
||||
SegmentState<double> segments;
|
||||
SegmentState<Scalar> segments;
|
||||
Events events;
|
||||
WellInjectorCMode injection_cmode{WellInjectorCMode::CMODE_UNDEFINED};
|
||||
WellProducerCMode production_cmode{WellProducerCMode::CMODE_UNDEFINED};
|
||||
@ -132,20 +133,17 @@ public:
|
||||
// The sum_xxx_rates() functions sum over all connection rates of pertinent
|
||||
// types. In the case of distributed wells this involves an MPI
|
||||
// communication.
|
||||
double sum_solvent_rates() const;
|
||||
double sum_polymer_rates() const;
|
||||
double sum_brine_rates() const;
|
||||
Scalar sum_solvent_rates() const;
|
||||
Scalar sum_polymer_rates() const;
|
||||
Scalar sum_brine_rates() const;
|
||||
|
||||
double sum_filtrate_rate() const;
|
||||
double sum_filtrate_total() const;
|
||||
Scalar sum_filtrate_rate() const;
|
||||
Scalar sum_filtrate_total() const;
|
||||
|
||||
private:
|
||||
double sum_connection_rates(const std::vector<double>& connection_rates) const;
|
||||
Scalar sum_connection_rates(const std::vector<Scalar>& connection_rates) const;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -35,7 +35,7 @@ namespace Opm
|
||||
{
|
||||
|
||||
bool WellConstraints::
|
||||
checkIndividualConstraints(SingleWellState& ws,
|
||||
checkIndividualConstraints(SingleWellState<double>& ws,
|
||||
const SummaryState& summaryState,
|
||||
const RateConvFunc& calcReservoirVoidageRates,
|
||||
bool& thp_limit_violated_but_not_switched,
|
||||
@ -70,7 +70,7 @@ checkIndividualConstraints(SingleWellState& ws,
|
||||
}
|
||||
|
||||
Well::InjectorCMode WellConstraints::
|
||||
activeInjectionConstraint(const SingleWellState& ws,
|
||||
activeInjectionConstraint(const SingleWellState<double>& ws,
|
||||
const SummaryState& summaryState,
|
||||
bool& thp_limit_violated_but_not_switched,
|
||||
DeferredLogger& deferred_logger,
|
||||
@ -167,7 +167,7 @@ activeInjectionConstraint(const SingleWellState& ws,
|
||||
}
|
||||
|
||||
Well::ProducerCMode WellConstraints::
|
||||
activeProductionConstraint(const SingleWellState& ws,
|
||||
activeProductionConstraint(const SingleWellState<double>& ws,
|
||||
const SummaryState& summaryState,
|
||||
const RateConvFunc& calcReservoirVoidageRates,
|
||||
bool& thp_limit_violated_but_not_switched,
|
||||
|
@ -37,7 +37,7 @@ namespace Opm
|
||||
class DeferredLogger;
|
||||
using RegionId = int;
|
||||
class Rates;
|
||||
class SingleWellState;
|
||||
template<class Scalar> class SingleWellState;
|
||||
class SummaryState;
|
||||
class WellInterfaceGeneric;
|
||||
enum class WellInjectorCMode;
|
||||
@ -54,7 +54,7 @@ public:
|
||||
std::vector<double>&)>;
|
||||
|
||||
bool
|
||||
checkIndividualConstraints(SingleWellState& ws,
|
||||
checkIndividualConstraints(SingleWellState<double>& ws,
|
||||
const SummaryState& summaryState,
|
||||
const RateConvFunc& calcReservoirVoidageRates,
|
||||
bool& thp_limit_violated_but_not_switched,
|
||||
@ -64,14 +64,14 @@ public:
|
||||
|
||||
private:
|
||||
WellInjectorCMode
|
||||
activeInjectionConstraint(const SingleWellState& ws,
|
||||
activeInjectionConstraint(const SingleWellState<double>& ws,
|
||||
const SummaryState& summaryState,
|
||||
bool& thp_limit_violated_but_not_switched,
|
||||
DeferredLogger& deferred_logger,
|
||||
const std::optional<Well::InjectionControls>& inj_controls = std::nullopt) const;
|
||||
|
||||
WellProducerCMode
|
||||
activeProductionConstraint(const SingleWellState& ws,
|
||||
activeProductionConstraint(const SingleWellState<double>& ws,
|
||||
const SummaryState& summaryState,
|
||||
const RateConvFunc& calcReservoirVoidageRates,
|
||||
bool& thp_limit_violated_but_not_switched,
|
||||
|
@ -353,11 +353,16 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<double> wellIndex(const int perf, const IntensiveQuantities& intQuants, const double trans_mult, const SingleWellState& ws) const;
|
||||
std::vector<double> wellIndex(const int perf,
|
||||
const IntensiveQuantities& intQuants,
|
||||
const double trans_mult,
|
||||
const SingleWellState<double>& ws) const;
|
||||
|
||||
void updateConnectionDFactor(const Simulator& simulator, SingleWellState& ws) const;
|
||||
void updateConnectionDFactor(const Simulator& simulator,
|
||||
SingleWellState<double>& ws) const;
|
||||
|
||||
void updateConnectionTransmissibilityFactor(const Simulator& simulator, SingleWellState& ws) const;
|
||||
void updateConnectionTransmissibilityFactor(const Simulator& simulator,
|
||||
SingleWellState<double>& ws) const;
|
||||
|
||||
|
||||
protected:
|
||||
@ -492,7 +497,7 @@ protected:
|
||||
|
||||
double computeConnectionDFactor(const int perf,
|
||||
const IntensiveQuantities& intQuants,
|
||||
const SingleWellState& ws) const;
|
||||
const SingleWellState<double>& ws) const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -67,7 +67,7 @@ WellInterfaceFluidSystem(const Well& well,
|
||||
template <typename FluidSystem>
|
||||
void
|
||||
WellInterfaceFluidSystem<FluidSystem>::
|
||||
calculateReservoirRates(SingleWellState& ws) const
|
||||
calculateReservoirRates(SingleWellState<double>& ws) const
|
||||
{
|
||||
const int np = number_of_phases_;
|
||||
const auto& pu = this->phaseUsage();
|
||||
@ -156,7 +156,7 @@ calculateReservoirRates(SingleWellState& ws) const
|
||||
template <typename FluidSystem>
|
||||
bool
|
||||
WellInterfaceFluidSystem<FluidSystem>::
|
||||
checkIndividualConstraints(SingleWellState& ws,
|
||||
checkIndividualConstraints(SingleWellState<double>& ws,
|
||||
const SummaryState& summaryState,
|
||||
DeferredLogger& deferred_logger,
|
||||
const std::optional<Well::InjectionControls>& inj_controls,
|
||||
|
@ -40,7 +40,7 @@ class Group;
|
||||
class GroupState;
|
||||
class Schedule;
|
||||
struct RatioLimitCheckReport;
|
||||
class SingleWellState;
|
||||
template<class Scalar> class SingleWellState;
|
||||
class WellState;
|
||||
|
||||
template<class FluidSystem>
|
||||
@ -75,9 +75,9 @@ protected:
|
||||
const std::vector<PerforationData>& perf_data);
|
||||
|
||||
// updating the voidage rates in well_state when requested
|
||||
void calculateReservoirRates(SingleWellState& ws) const;
|
||||
void calculateReservoirRates(SingleWellState<double>& ws) const;
|
||||
|
||||
bool checkIndividualConstraints(SingleWellState& ws,
|
||||
bool checkIndividualConstraints(SingleWellState<double>& ws,
|
||||
const SummaryState& summaryState,
|
||||
DeferredLogger& deferred_logger,
|
||||
const std::optional<Well::InjectionControls>& inj_controls = std::nullopt,
|
||||
|
@ -272,7 +272,7 @@ bool WellInterfaceGeneric::wellHasTHPConstraints(const SummaryState& summaryStat
|
||||
return WellBhpThpCalculator(*this).wellHasTHPConstraints(summaryState);
|
||||
}
|
||||
|
||||
void WellInterfaceGeneric::updateWellTestState(const SingleWellState& ws,
|
||||
void WellInterfaceGeneric::updateWellTestState(const SingleWellState<double>& ws,
|
||||
const double& simulationTime,
|
||||
const bool& writeMessageToOPMLog,
|
||||
WellTestState& wellTestState,
|
||||
@ -514,7 +514,8 @@ double WellInterfaceGeneric::getALQ(const WellState& well_state) const
|
||||
return well_state.getALQ(name());
|
||||
}
|
||||
|
||||
void WellInterfaceGeneric::reportWellSwitching(const SingleWellState& ws, DeferredLogger& deferred_logger) const
|
||||
void WellInterfaceGeneric::reportWellSwitching(const SingleWellState<double> &ws,
|
||||
DeferredLogger& deferred_logger) const
|
||||
{
|
||||
if (well_control_log_.empty())
|
||||
return;
|
||||
|
@ -43,7 +43,7 @@ class SummaryState;
|
||||
class VFPProperties;
|
||||
class WellTestState;
|
||||
class WellState;
|
||||
class SingleWellState;
|
||||
template<class Scalar> class SingleWellState;
|
||||
class GroupState;
|
||||
class Group;
|
||||
class Schedule;
|
||||
@ -193,13 +193,13 @@ public:
|
||||
// whether a well is specified with a non-zero and valid VFP table number
|
||||
bool isVFPActive(DeferredLogger& deferred_logger) const;
|
||||
|
||||
void reportWellSwitching(const SingleWellState& ws, DeferredLogger& deferred_logger) const;
|
||||
void reportWellSwitching(const SingleWellState<double>& ws, DeferredLogger& deferred_logger) const;
|
||||
|
||||
bool changedToOpenThisStep() const {
|
||||
return this->changed_to_open_this_step_;
|
||||
}
|
||||
|
||||
void updateWellTestState(const SingleWellState& ws,
|
||||
void updateWellTestState(const SingleWellState<double>& ws,
|
||||
const double& simulationTime,
|
||||
const bool& writeMessageToOPMLog,
|
||||
WellTestState& wellTestState,
|
||||
|
@ -1494,10 +1494,10 @@ namespace Opm
|
||||
template <typename TypeTag>
|
||||
std::vector<double>
|
||||
WellInterface<TypeTag>::
|
||||
wellIndex(const int perf,
|
||||
const IntensiveQuantities& intQuants,
|
||||
const double trans_mult,
|
||||
const SingleWellState& ws) const
|
||||
wellIndex(const int perf,
|
||||
const IntensiveQuantities& intQuants,
|
||||
const double trans_mult,
|
||||
const SingleWellState<double>& ws) const
|
||||
{
|
||||
// Add a Forchheimer term to the gas phase CTF if the run uses
|
||||
// either of the WDFAC or the WDFACCOR keywords.
|
||||
@ -1572,7 +1572,8 @@ namespace Opm
|
||||
template <typename TypeTag>
|
||||
void
|
||||
WellInterface<TypeTag>::
|
||||
updateConnectionDFactor(const Simulator& simulator, SingleWellState& ws) const
|
||||
updateConnectionDFactor(const Simulator& simulator,
|
||||
SingleWellState<double>& ws) const
|
||||
{
|
||||
if (! this->well_ecl_.getWDFAC().useDFactor()) {
|
||||
return;
|
||||
@ -1591,9 +1592,9 @@ namespace Opm
|
||||
template <typename TypeTag>
|
||||
double
|
||||
WellInterface<TypeTag>::
|
||||
computeConnectionDFactor(const int perf,
|
||||
const IntensiveQuantities& intQuants,
|
||||
const SingleWellState& ws) const
|
||||
computeConnectionDFactor(const int perf,
|
||||
const IntensiveQuantities& intQuants,
|
||||
const SingleWellState<double>& ws) const
|
||||
{
|
||||
auto rhoGS = [regIdx = this->pvtRegionIdx()]() {
|
||||
return FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, regIdx);
|
||||
@ -1633,7 +1634,8 @@ namespace Opm
|
||||
template <typename TypeTag>
|
||||
void
|
||||
WellInterface<TypeTag>::
|
||||
updateConnectionTransmissibilityFactor(const Simulator& simulator, SingleWellState& ws) const
|
||||
updateConnectionTransmissibilityFactor(const Simulator& simulator,
|
||||
SingleWellState<double>& ws) const
|
||||
{
|
||||
auto connCF = [&connIx = std::as_const(ws.perf_data.ecl_index),
|
||||
&conns = this->well_ecl_.getConnections()]
|
||||
|
@ -130,7 +130,7 @@ WellState::WellState(const ParallelWellInfo& pinfo)
|
||||
: phase_usage_{}
|
||||
{
|
||||
wells_.add("test4",
|
||||
SingleWellState{"dummy", pinfo, false, 0.0, {}, phase_usage_, 0.0});
|
||||
SingleWellState<double>{"dummy", pinfo, false, 0.0, {}, phase_usage_, 0.0});
|
||||
}
|
||||
|
||||
WellState WellState::serializationTestObject(const ParallelWellInfo& pinfo)
|
||||
@ -138,7 +138,7 @@ WellState WellState::serializationTestObject(const ParallelWellInfo& pinfo)
|
||||
WellState result(PhaseUsage{});
|
||||
result.alq_state = ALQState::serializationTestObject();
|
||||
result.well_rates = {{"test2", {true, {1.0}}}, {"test3", {false, {2.0}}}};
|
||||
result.wells_.add("test4", SingleWellState::serializationTestObject(pinfo));
|
||||
result.wells_.add("test4", SingleWellState<double>::serializationTestObject(pinfo));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -173,13 +173,13 @@ void WellState::initSingleProducer(const Well& well,
|
||||
const double temp = 273.15 + 15.56;
|
||||
|
||||
auto& ws = this->wells_.add(well.name(),
|
||||
SingleWellState{well.name(),
|
||||
well_info,
|
||||
true,
|
||||
pressure_first_connection,
|
||||
well_perf_data,
|
||||
pu,
|
||||
temp});
|
||||
SingleWellState<double>{well.name(),
|
||||
well_info,
|
||||
true,
|
||||
pressure_first_connection,
|
||||
well_perf_data,
|
||||
pu,
|
||||
temp});
|
||||
|
||||
// the rest of the code needs to executed even if ws.perf_data is empty
|
||||
// as this does not say anything for the whole well if it is distributed.
|
||||
@ -200,13 +200,13 @@ void WellState::initSingleInjector(const Well& well,
|
||||
const auto& pu = this->phase_usage_;
|
||||
const double temp = well.temperature();
|
||||
|
||||
auto& ws = this->wells_.add(well.name(), SingleWellState{well.name(),
|
||||
well_info,
|
||||
false,
|
||||
pressure_first_connection,
|
||||
well_perf_data,
|
||||
pu,
|
||||
temp});
|
||||
auto& ws = this->wells_.add(well.name(), SingleWellState<double>{well.name(),
|
||||
well_info,
|
||||
false,
|
||||
pressure_first_connection,
|
||||
well_perf_data,
|
||||
pu,
|
||||
temp});
|
||||
|
||||
// the rest of the code needs to executed even if ws.perf_data is empty
|
||||
// as this does not say anything for the whole well if it is distributed.
|
||||
|
@ -251,35 +251,43 @@ public:
|
||||
return this->wells_.well_index(well_name);
|
||||
}
|
||||
|
||||
const SingleWellState& operator[](std::size_t well_index) const {
|
||||
const SingleWellState<double>& operator[](std::size_t well_index) const
|
||||
{
|
||||
return this->wells_[well_index];
|
||||
}
|
||||
|
||||
const SingleWellState& operator[](const std::string& well_name) const {
|
||||
const SingleWellState<double>& operator[](const std::string& well_name) const
|
||||
{
|
||||
return this->wells_[well_name];
|
||||
}
|
||||
|
||||
SingleWellState& operator[](std::size_t well_index) {
|
||||
SingleWellState<double>& operator[](std::size_t well_index)
|
||||
{
|
||||
return this->wells_[well_index];
|
||||
}
|
||||
|
||||
SingleWellState& operator[](const std::string& well_name) {
|
||||
SingleWellState<double>& operator[](const std::string& well_name)
|
||||
{
|
||||
return this->wells_[well_name];
|
||||
}
|
||||
|
||||
const SingleWellState& well(std::size_t well_index) const {
|
||||
const SingleWellState<double>& well(std::size_t well_index) const
|
||||
{
|
||||
return this->operator[](well_index);
|
||||
}
|
||||
|
||||
const SingleWellState& well(const std::string& well_name) const {
|
||||
const SingleWellState<double>& well(const std::string& well_name) const
|
||||
{
|
||||
return this->operator[](well_name);
|
||||
}
|
||||
|
||||
SingleWellState& well(std::size_t well_index) {
|
||||
SingleWellState<double>& well(std::size_t well_index)
|
||||
{
|
||||
return this->operator[](well_index);
|
||||
}
|
||||
|
||||
SingleWellState& well(const std::string& well_name) {
|
||||
SingleWellState<double>& well(const std::string& well_name)
|
||||
{
|
||||
return this->operator[](well_name);
|
||||
}
|
||||
|
||||
@ -314,7 +322,7 @@ private:
|
||||
// The wells_ variable is essentially a map of all the wells on the current
|
||||
// process. Observe that since a well can be split over several processes a
|
||||
// well might appear in the WellContainer on different processes.
|
||||
WellContainer<SingleWellState> wells_;
|
||||
WellContainer<SingleWellState<double>> wells_;
|
||||
|
||||
// The members alq_state, global_well_info and well_rates are map like
|
||||
// structures which will have entries for *all* the wells in the system.
|
||||
|
@ -36,7 +36,7 @@ namespace Opm
|
||||
{
|
||||
|
||||
template<class RatioFunc>
|
||||
bool WellTest::checkMaxRatioLimitWell(const SingleWellState& ws,
|
||||
bool WellTest::checkMaxRatioLimitWell(const SingleWellState<double>& ws,
|
||||
const double max_ratio_limit,
|
||||
const RatioFunc& ratioFunc) const
|
||||
{
|
||||
@ -52,7 +52,7 @@ bool WellTest::checkMaxRatioLimitWell(const SingleWellState& ws,
|
||||
}
|
||||
|
||||
template<class RatioFunc>
|
||||
void WellTest::checkMaxRatioLimitCompletions(const SingleWellState& ws,
|
||||
void WellTest::checkMaxRatioLimitCompletions(const SingleWellState<double>& ws,
|
||||
const double max_ratio_limit,
|
||||
const RatioFunc& ratioFunc,
|
||||
RatioLimitCheckReport& report) const
|
||||
@ -97,7 +97,7 @@ void WellTest::checkMaxRatioLimitCompletions(const SingleWellState& ws,
|
||||
}
|
||||
|
||||
void WellTest::checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits,
|
||||
const SingleWellState& ws,
|
||||
const SingleWellState<double>& ws,
|
||||
RatioLimitCheckReport& report) const
|
||||
{
|
||||
static constexpr int Oil = BlackoilPhases::Liquid;
|
||||
@ -128,7 +128,7 @@ void WellTest::checkMaxGORLimit(const WellEconProductionLimits& econ_production_
|
||||
}
|
||||
|
||||
void WellTest::checkMaxWGRLimit(const WellEconProductionLimits& econ_production_limits,
|
||||
const SingleWellState& ws,
|
||||
const SingleWellState<double>& ws,
|
||||
RatioLimitCheckReport& report) const
|
||||
{
|
||||
static constexpr int Gas = BlackoilPhases::Vapour;
|
||||
@ -160,7 +160,7 @@ void WellTest::checkMaxWGRLimit(const WellEconProductionLimits& econ_production_
|
||||
}
|
||||
|
||||
void WellTest::checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits,
|
||||
const SingleWellState& ws,
|
||||
const SingleWellState<double>& ws,
|
||||
RatioLimitCheckReport& report) const
|
||||
{
|
||||
static constexpr int Oil = BlackoilPhases::Liquid;
|
||||
@ -241,7 +241,7 @@ bool WellTest::checkRateEconLimits(const WellEconProductionLimits& econ_producti
|
||||
|
||||
WellTest::RatioLimitCheckReport WellTest::
|
||||
checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
|
||||
const SingleWellState& ws,
|
||||
const SingleWellState<double>& ws,
|
||||
DeferredLogger& deferred_logger) const
|
||||
{
|
||||
// TODO: not sure how to define the worst-offending completion when more than one
|
||||
@ -289,7 +289,7 @@ checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
|
||||
return report;
|
||||
}
|
||||
|
||||
void WellTest::updateWellTestStateEconomic(const SingleWellState& ws,
|
||||
void WellTest::updateWellTestStateEconomic(const SingleWellState<double>& ws,
|
||||
const double simulation_time,
|
||||
const bool write_message_to_opmlog,
|
||||
WellTestState& well_test_state,
|
||||
|
@ -32,7 +32,7 @@ namespace Opm
|
||||
|
||||
class DeferredLogger;
|
||||
struct PhaseUsage;
|
||||
class SingleWellState;
|
||||
template<class Scalar> class SingleWellState;
|
||||
class WellEconProductionLimits;
|
||||
class WellInterfaceGeneric;
|
||||
class WellTestState;
|
||||
@ -43,7 +43,7 @@ public:
|
||||
//! \brief Constructor sets reference to well.
|
||||
WellTest(const WellInterfaceGeneric& well) : well_(well) {}
|
||||
|
||||
void updateWellTestStateEconomic(const SingleWellState& ws,
|
||||
void updateWellTestStateEconomic(const SingleWellState<double>& ws,
|
||||
const double simulation_time,
|
||||
const bool write_message_to_opmlog,
|
||||
WellTestState& well_test_state,
|
||||
@ -63,24 +63,24 @@ private:
|
||||
};
|
||||
|
||||
void checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits,
|
||||
const SingleWellState& ws,
|
||||
const SingleWellState<double>& ws,
|
||||
RatioLimitCheckReport& report) const;
|
||||
|
||||
void checkMaxWGRLimit(const WellEconProductionLimits& econ_production_limits,
|
||||
const SingleWellState& ws,
|
||||
const SingleWellState<double>& ws,
|
||||
RatioLimitCheckReport& report) const;
|
||||
|
||||
void checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits,
|
||||
const SingleWellState& ws,
|
||||
const SingleWellState<double>& ws,
|
||||
RatioLimitCheckReport& report) const;
|
||||
|
||||
template<class RatioFunc>
|
||||
bool checkMaxRatioLimitWell(const SingleWellState& ws,
|
||||
bool checkMaxRatioLimitWell(const SingleWellState<double>& ws,
|
||||
const double max_ratio_limit,
|
||||
const RatioFunc& ratioFunc) const;
|
||||
|
||||
template<class RatioFunc>
|
||||
void checkMaxRatioLimitCompletions(const SingleWellState& ws,
|
||||
void checkMaxRatioLimitCompletions(const SingleWellState<double>& ws,
|
||||
const double max_ratio_limit,
|
||||
const RatioFunc& ratioFunc,
|
||||
RatioLimitCheckReport& report) const;
|
||||
@ -91,7 +91,7 @@ private:
|
||||
|
||||
RatioLimitCheckReport
|
||||
checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
|
||||
const SingleWellState& ws,
|
||||
const SingleWellState<double>& ws,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
|
||||
|
@ -148,7 +148,7 @@ TEST_FOR_TYPE_NAMED(BVec, BlockVectorWrapper)
|
||||
BOOST_AUTO_TEST_CASE(SingleWellState)
|
||||
{
|
||||
Opm::ParallelWellInfo dummy;
|
||||
auto data_out = Opm::SingleWellState::serializationTestObject(dummy);
|
||||
auto data_out = Opm::SingleWellState<double>::serializationTestObject(dummy);
|
||||
Opm::Serialization::MemPacker packer;
|
||||
Opm::Serializer ser(packer);
|
||||
ser.pack(data_out);
|
||||
|
@ -587,9 +587,9 @@ BOOST_AUTO_TEST_CASE(TestSingleWellState) {
|
||||
// This is totally bonkers, but the pu needs a complete deck to initialize properly
|
||||
pu.num_phases = 3;
|
||||
|
||||
Opm::SingleWellState ws1("W1", pinfo, true, 100, connections, pu, 1);
|
||||
Opm::SingleWellState ws2("W2", pinfo, true, 100, connections, pu, 2);
|
||||
Opm::SingleWellState ws3("W3", pinfo, false, 100, connections, pu, 3);
|
||||
Opm::SingleWellState ws1("W1", pinfo, true, 100.0, connections, pu, 1.0);
|
||||
Opm::SingleWellState ws2("W2", pinfo, true, 100.0, connections, pu, 2.0);
|
||||
Opm::SingleWellState ws3("W3", pinfo, false, 100.0, connections, pu, 3.0);
|
||||
|
||||
ws1.bhp = 100;
|
||||
ws1.thp = 200;
|
||||
|
Loading…
Reference in New Issue
Block a user