mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
BlackoilWellModel: move runWellPIScaling to generic class
This commit is contained in:
@@ -125,7 +125,7 @@ namespace Opm {
|
|||||||
BlackoilWellModel(Simulator& ebosSimulator);
|
BlackoilWellModel(Simulator& ebosSimulator);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void initWellContainer();
|
void initWellContainer() override;
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
// <eWoms auxiliary module stuff>
|
// <eWoms auxiliary module stuff>
|
||||||
@@ -279,7 +279,7 @@ namespace Opm {
|
|||||||
const SummaryState& summaryState);
|
const SummaryState& summaryState);
|
||||||
|
|
||||||
// create the well container
|
// create the well container
|
||||||
void createWellContainer(const int time_step);
|
void createWellContainer(const int time_step) override;
|
||||||
|
|
||||||
WellInterfacePtr
|
WellInterfacePtr
|
||||||
createWellPointer(const int wellID,
|
createWellPointer(const int wellID,
|
||||||
@@ -301,8 +301,6 @@ namespace Opm {
|
|||||||
std::vector<double> depth_{};
|
std::vector<double> depth_{};
|
||||||
bool alternative_well_rate_init_{};
|
bool alternative_well_rate_init_{};
|
||||||
|
|
||||||
std::optional<int> last_run_wellpi_{};
|
|
||||||
|
|
||||||
std::unique_ptr<RateConverterType> rateConverter_{};
|
std::unique_ptr<RateConverterType> rateConverter_{};
|
||||||
|
|
||||||
SimulatorReportSingle last_report_{};
|
SimulatorReportSingle last_report_{};
|
||||||
@@ -348,8 +346,8 @@ namespace Opm {
|
|||||||
|
|
||||||
const std::vector<double>& wellPerfEfficiencyFactors() const;
|
const std::vector<double>& wellPerfEfficiencyFactors() const;
|
||||||
|
|
||||||
void calculateProductivityIndexValuesShutWells(const int reportStepIdx, DeferredLogger& deferred_logger);
|
void calculateProductivityIndexValuesShutWells(const int reportStepIdx, DeferredLogger& deferred_logger) override;
|
||||||
void calculateProductivityIndexValues(DeferredLogger& deferred_logger);
|
void calculateProductivityIndexValues(DeferredLogger& deferred_logger) override;
|
||||||
void calculateProductivityIndexValues(const WellInterface<TypeTag>* wellPtr,
|
void calculateProductivityIndexValues(const WellInterface<TypeTag>* wellPtr,
|
||||||
DeferredLogger& deferred_logger);
|
DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
@@ -375,8 +373,6 @@ namespace Opm {
|
|||||||
const int pvtreg,
|
const int pvtreg,
|
||||||
std::vector<double>& resv_coeff) override;
|
std::vector<double>& resv_coeff) override;
|
||||||
|
|
||||||
void runWellPIScaling(const int timeStepIdx, DeferredLogger& local_deferredLogger);
|
|
||||||
|
|
||||||
void computeWellTemperature();
|
void computeWellTemperature();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
BlackoilWellModelGeneric::
|
BlackoilWellModelGeneric::
|
||||||
BlackoilWellModelGeneric(const Schedule& schedule,
|
BlackoilWellModelGeneric(Schedule& schedule,
|
||||||
const SummaryState& summaryState,
|
const SummaryState& summaryState,
|
||||||
const EclipseState& eclState,
|
const EclipseState& eclState,
|
||||||
const PhaseUsage& phase_usage,
|
const PhaseUsage& phase_usage,
|
||||||
@@ -1764,4 +1764,78 @@ updateWellPotentials(const int reportStepIdx,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BlackoilWellModelGeneric::
|
||||||
|
runWellPIScaling(const int timeStepIdx,
|
||||||
|
DeferredLogger& local_deferredLogger)
|
||||||
|
{
|
||||||
|
if (this->last_run_wellpi_.has_value() && (*this->last_run_wellpi_ == timeStepIdx)) {
|
||||||
|
// We've already run WELPI scaling for this report step. Most
|
||||||
|
// common for the very first report step. Don't redo WELPI scaling.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto hasWellPIEvent = [this, timeStepIdx](const int well_index) -> bool
|
||||||
|
{
|
||||||
|
return this->schedule()[timeStepIdx].wellgroup_events()
|
||||||
|
.hasEvent(this->wells_ecl_[well_index].name(),
|
||||||
|
ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto updateEclWell = [this, timeStepIdx](const int well_index) -> void
|
||||||
|
{
|
||||||
|
const auto& schedule = this->schedule();
|
||||||
|
const auto& wname = this->wells_ecl_[well_index].name();
|
||||||
|
this->wells_ecl_[well_index] = schedule.getWell(wname, timeStepIdx);
|
||||||
|
|
||||||
|
const auto& well = this->wells_ecl_[well_index];
|
||||||
|
auto& pd = this->well_perf_data_[well_index];
|
||||||
|
auto pdIter = pd.begin();
|
||||||
|
for (const auto& conn : well.getConnections()) {
|
||||||
|
if (conn.state() != Connection::State::SHUT) {
|
||||||
|
pdIter->connection_transmissibility_factor = conn.CF();
|
||||||
|
++pdIter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->wellState().resetConnectionTransFactors(well_index, pd);
|
||||||
|
this->prod_index_calc_[well_index].reInit(well);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
auto rescaleWellPI =
|
||||||
|
[this, timeStepIdx](const int well_index,
|
||||||
|
const double newWellPI) -> void
|
||||||
|
{
|
||||||
|
const auto& wname = this->wells_ecl_[well_index].name();
|
||||||
|
|
||||||
|
schedule_.applyWellProdIndexScaling(wname, timeStepIdx, newWellPI);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Minimal well setup to compute PI/II values
|
||||||
|
{
|
||||||
|
auto saved_previous_wgstate = this->prevWGState();
|
||||||
|
this->commitWGState();
|
||||||
|
|
||||||
|
this->createWellContainer(timeStepIdx);
|
||||||
|
this->inferLocalShutWells();
|
||||||
|
|
||||||
|
this->initWellContainer();
|
||||||
|
|
||||||
|
this->calculateProductivityIndexValues(local_deferredLogger);
|
||||||
|
this->calculateProductivityIndexValuesShutWells(timeStepIdx, local_deferredLogger);
|
||||||
|
|
||||||
|
this->commitWGState(std::move(saved_previous_wgstate));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto nw = this->numLocalWells();
|
||||||
|
for (auto wellID = 0*nw; wellID < nw; ++wellID) {
|
||||||
|
if (hasWellPIEvent(wellID)) {
|
||||||
|
rescaleWellPI(wellID, this->wellPI(wellID));
|
||||||
|
updateEclWell(wellID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->last_run_wellpi_ = timeStepIdx;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
using GLiftProdWells = std::map<std::string,const WellInterfaceGeneric*>;
|
using GLiftProdWells = std::map<std::string,const WellInterfaceGeneric*>;
|
||||||
using GLiftWellStateMap = std::map<std::string,std::unique_ptr<GasLiftWellState>>;
|
using GLiftWellStateMap = std::map<std::string,std::unique_ptr<GasLiftWellState>>;
|
||||||
|
|
||||||
BlackoilWellModelGeneric(const Schedule& schedule,
|
BlackoilWellModelGeneric(Schedule& schedule,
|
||||||
const SummaryState& summaryState,
|
const SummaryState& summaryState,
|
||||||
const EclipseState& eclState,
|
const EclipseState& eclState,
|
||||||
const PhaseUsage& phase_usage,
|
const PhaseUsage& phase_usage,
|
||||||
@@ -353,8 +353,18 @@ protected:
|
|||||||
const SummaryConfig& summaryConfig,
|
const SummaryConfig& summaryConfig,
|
||||||
DeferredLogger& deferred_logger);
|
DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
|
// create the well container
|
||||||
|
virtual void createWellContainer(const int time_step) = 0;
|
||||||
|
virtual void initWellContainer() = 0;
|
||||||
|
|
||||||
const Schedule& schedule_;
|
virtual void calculateProductivityIndexValuesShutWells(const int reportStepIdx,
|
||||||
|
DeferredLogger& deferred_logger) = 0;
|
||||||
|
virtual void calculateProductivityIndexValues(DeferredLogger& deferred_logger) = 0;
|
||||||
|
|
||||||
|
void runWellPIScaling(const int timeStepIdx,
|
||||||
|
DeferredLogger& local_deferredLogger);
|
||||||
|
|
||||||
|
Schedule& schedule_;
|
||||||
const SummaryState& summaryState_;
|
const SummaryState& summaryState_;
|
||||||
const EclipseState& eclState_;
|
const EclipseState& eclState_;
|
||||||
const Comm& comm_;
|
const Comm& comm_;
|
||||||
@@ -365,6 +375,8 @@ protected:
|
|||||||
bool initial_step_{};
|
bool initial_step_{};
|
||||||
bool report_step_starts_{};
|
bool report_step_starts_{};
|
||||||
|
|
||||||
|
std::optional<int> last_run_wellpi_{};
|
||||||
|
|
||||||
std::vector<Well> wells_ecl_;
|
std::vector<Well> wells_ecl_;
|
||||||
std::vector<std::vector<PerforationData>> well_perf_data_;
|
std::vector<std::vector<PerforationData>> well_perf_data_;
|
||||||
std::function<bool(const Well&)> not_on_process_{};
|
std::function<bool(const Well&)> not_on_process_{};
|
||||||
|
|||||||
@@ -1496,85 +1496,6 @@ namespace Opm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename TypeTag>
|
|
||||||
void
|
|
||||||
BlackoilWellModel<TypeTag>::
|
|
||||||
runWellPIScaling(const int timeStepIdx, DeferredLogger& local_deferredLogger)
|
|
||||||
{
|
|
||||||
if (this->last_run_wellpi_.has_value() && (*this->last_run_wellpi_ == timeStepIdx)) {
|
|
||||||
// We've already run WELPI scaling for this report step. Most
|
|
||||||
// common for the very first report step. Don't redo WELPI scaling.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto hasWellPIEvent = [this, timeStepIdx](const int well_index) -> bool
|
|
||||||
{
|
|
||||||
return this->schedule()[timeStepIdx].wellgroup_events()
|
|
||||||
.hasEvent(this->wells_ecl_[well_index].name(),
|
|
||||||
ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto updateEclWell = [this, timeStepIdx](const int well_index) -> void
|
|
||||||
{
|
|
||||||
const auto& schedule = this->schedule();
|
|
||||||
const auto& wname = this->wells_ecl_[well_index].name();
|
|
||||||
this->wells_ecl_[well_index] = schedule.getWell(wname, timeStepIdx);
|
|
||||||
|
|
||||||
const auto& well = this->wells_ecl_[well_index];
|
|
||||||
auto& pd = this->well_perf_data_[well_index];
|
|
||||||
auto pdIter = pd.begin();
|
|
||||||
for (const auto& conn : well.getConnections()) {
|
|
||||||
if (conn.state() != Connection::State::SHUT) {
|
|
||||||
pdIter->connection_transmissibility_factor = conn.CF();
|
|
||||||
++pdIter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->wellState().resetConnectionTransFactors(well_index, pd);
|
|
||||||
this->prod_index_calc_[well_index].reInit(well);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
auto rescaleWellPI =
|
|
||||||
[this, timeStepIdx](const int well_index,
|
|
||||||
const double newWellPI) -> void
|
|
||||||
{
|
|
||||||
const auto& wname = this->wells_ecl_[well_index].name();
|
|
||||||
|
|
||||||
auto& schedule = this->ebosSimulator_.vanguard().schedule(); // Mutable
|
|
||||||
schedule.applyWellProdIndexScaling(wname, timeStepIdx, newWellPI);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Minimal well setup to compute PI/II values
|
|
||||||
{
|
|
||||||
auto saved_previous_wgstate = this->prevWGState();
|
|
||||||
this->commitWGState();
|
|
||||||
|
|
||||||
this->createWellContainer(timeStepIdx);
|
|
||||||
this->inferLocalShutWells();
|
|
||||||
|
|
||||||
this->initWellContainer();
|
|
||||||
|
|
||||||
this->calculateProductivityIndexValues(local_deferredLogger);
|
|
||||||
this->calculateProductivityIndexValuesShutWells(timeStepIdx, local_deferredLogger);
|
|
||||||
|
|
||||||
this->commitWGState(std::move(saved_previous_wgstate));
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto nw = this->numLocalWells();
|
|
||||||
for (auto wellID = 0*nw; wellID < nw; ++wellID) {
|
|
||||||
if (hasWellPIEvent(wellID)) {
|
|
||||||
rescaleWellPI(wellID, this->wellPI(wellID));
|
|
||||||
updateEclWell(wellID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this->last_run_wellpi_ = timeStepIdx;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename TypeTag>
|
template <typename TypeTag>
|
||||||
void
|
void
|
||||||
BlackoilWellModel<TypeTag>::
|
BlackoilWellModel<TypeTag>::
|
||||||
|
|||||||
Reference in New Issue
Block a user