BlackoilWellModel: move some glift stuff to generic class

This commit is contained in:
Arne Morten Kvarving 2021-06-07 13:04:29 +02:00
parent 2b9141035e
commit b0b0ae20d3
4 changed files with 76 additions and 73 deletions

View File

@ -47,8 +47,8 @@
#include <opm/simulators/timestepping/SimulatorReport.hpp>
#include <opm/simulators/flow/countGlobalCells.hpp>
#include <opm/simulators/wells/BlackoilWellModelGeneric.hpp>
#include <opm/simulators/wells/GasLiftSingleWell.hpp>
#include <opm/simulators/wells/GasLiftStage2.hpp>
#include <opm/simulators/wells/GasLiftWellState.hpp>
#include <opm/simulators/wells/PerforationData.hpp>
#include <opm/simulators/wells/VFPInjProperties.hpp>
@ -71,8 +71,6 @@
#include <opm/simulators/utils/DeferredLogger.hpp>
#include <opm/simulators/wells/BlackoilWellModelGeneric.hpp>
namespace Opm::Properties {
template<class TypeTag, class MyTypeTag>
@ -104,13 +102,6 @@ namespace Opm {
using SparseMatrixAdapter = GetPropType<TypeTag, Properties::SparseMatrixAdapter>;
typedef typename BaseAuxiliaryModule<TypeTag>::NeighborSet NeighborSet;
using GasLiftSingleWell = GasLiftSingleWellGeneric;
using GLiftWellStateMap =
std::map<std::string,std::unique_ptr<GasLiftWellState>>;
using GLiftOptWells =
std::map<std::string,std::unique_ptr<GasLiftSingleWell>>;
using GLiftProdWells =
std::map<std::string,const WellInterfaceGeneric*>;
static const int numEq = Indices::numEq;
static const int solventSaturationIdx = Indices::solventSaturationIdx;
@ -308,7 +299,6 @@ namespace Opm {
double gravity_{};
std::vector<double> depth_{};
bool report_step_starts_{};
bool glift_debug = false;
bool alternative_well_rate_init_{};
std::optional<int> last_run_wellpi_{};
@ -328,10 +318,6 @@ namespace Opm {
const EclipseState& eclState() const
{ return ebosSimulator_.vanguard().eclState(); }
void gliftDebug(
const std::string &msg,
DeferredLogger& deferred_logger) const;
// compute the well fluxes and assemble them in to the reservoir equations as source terms
// and in the well equations.
void assemble(const int iterationIdx,
@ -373,12 +359,6 @@ namespace Opm {
void maybeDoGasLiftOptimize(DeferredLogger& deferred_logger);
void gliftDebugShowALQ(DeferredLogger& deferred_logger);
void gasLiftOptimizationStage2(DeferredLogger& deferred_logger,
GLiftProdWells &prod_wells, GLiftOptWells &glift_wells,
GLiftWellStateMap &map);
void extractLegacyCellPvtRegionIndex_();
void extractLegacyDepth_();

View File

@ -32,6 +32,7 @@
#include <opm/simulators/utils/DeferredLogger.hpp>
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/wells/GasLiftStage2.hpp>
#include <opm/simulators/wells/VFPProperties.hpp>
#include <opm/simulators/wells/WellGroupHelpers.hpp>
#include <opm/simulators/wells/WellState.hpp>
@ -39,6 +40,8 @@
#include <cassert>
#include <stdexcept>
#include <fmt/format.h>
namespace Opm {
BlackoilWellModelGeneric::
@ -1646,4 +1649,57 @@ setRepRadiusPerfLength()
}
}
void
BlackoilWellModelGeneric::
gliftDebug(const std::string& msg,
DeferredLogger& deferred_logger) const
{
if (this->glift_debug) {
const std::string message = fmt::format(
" GLIFT (DEBUG) : BlackoilWellModel : {}", msg);
deferred_logger.info(message);
}
}
void
BlackoilWellModelGeneric::
gliftDebugShowALQ(DeferredLogger& deferred_logger)
{
for (auto& well : this->well_container_generic_) {
if (well->isProducer()) {
auto alq = this->wellState().getALQ(well->name());
const std::string msg = fmt::format("ALQ_REPORT : {} : {}",
well->name(), alq);
gliftDebug(msg, deferred_logger);
}
}
}
// If a group has any production rate constraints, and/or a limit
// on its total rate of lift gas supply, allocate lift gas
// preferentially to the wells that gain the most benefit from
// it. Lift gas increments are allocated in turn to the well that
// currently has the largest weighted incremental gradient. The
// procedure takes account of any limits on the group production
// rate or lift gas supply applied to any level of group.
void
BlackoilWellModelGeneric::
gasLiftOptimizationStage2(DeferredLogger& deferred_logger,
GLiftProdWells& prod_wells,
GLiftOptWells& glift_wells,
GLiftWellStateMap& glift_well_state_map,
const int episodeIndex)
{
GasLiftStage2 glift {episodeIndex,
comm_,
schedule_,
summaryState_,
deferred_logger,
this->wellState(),
prod_wells,
glift_wells,
glift_well_state_map};
glift.runOptimize();
}
}

View File

@ -53,6 +53,8 @@ struct NodeData;
class DeferredLogger;
class EclipseState;
class GasLiftSingleWellGeneric;
class GasLiftWellState;
class Group;
class RestartValue;
class Schedule;
@ -65,6 +67,9 @@ class BlackoilWellModelGeneric
public:
// --------- Types ---------
using Comm = Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator>;
using GLiftOptWells = std::map<std::string,std::unique_ptr<GasLiftSingleWellGeneric>>;
using GLiftProdWells = std::map<std::string,const WellInterfaceGeneric*>;
using GLiftWellStateMap = std::map<std::string,std::unique_ptr<GasLiftWellState>>;
BlackoilWellModelGeneric(const Schedule& schedule,
const SummaryState& summaryState,
@ -323,6 +328,17 @@ protected:
void setRepRadiusPerfLength();
void gliftDebug(const std::string& msg,
DeferredLogger& deferred_logger) const;
void gliftDebugShowALQ(DeferredLogger& deferred_logger);
void gasLiftOptimizationStage2(DeferredLogger& deferred_logger,
GLiftProdWells& prod_wells,
GLiftOptWells& glift_wells,
GLiftWellStateMap& map,
const int episodeIndex);
const Schedule& schedule_;
const SummaryState& summaryState_;
const EclipseState& eclState_;
@ -371,6 +387,8 @@ protected:
WGState last_valid_wgstate_;
WGState nupcol_wgstate_;
bool glift_debug = false;
private:
WellInterfaceGeneric* getGenWell(const std::string& well_name);
};

View File

@ -356,18 +356,6 @@ namespace Opm {
}
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::gliftDebug(
const std::string &msg, DeferredLogger &deferred_logger) const
{
if (this->glift_debug) {
const std::string message = fmt::format(
" GLIFT (DEBUG) : BlackoilWellModel : {}", msg);
deferred_logger.info(message);
}
}
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::wellTesting(const int timeStepIdx,
@ -858,50 +846,11 @@ namespace Opm {
this->wellState(), ebosSimulator_, deferred_logger,
prod_wells, glift_wells, state_map);
}
gasLiftOptimizationStage2(deferred_logger, prod_wells, glift_wells, state_map);
gasLiftOptimizationStage2(deferred_logger, prod_wells, glift_wells, state_map, ebosSimulator_.episodeIndex());
if (this->glift_debug) gliftDebugShowALQ(deferred_logger);
this->wellState().disableGliftOptimization();
}
// If a group has any production rate constraints, and/or a limit
// on its total rate of lift gas supply, allocate lift gas
// preferentially to the wells that gain the most benefit from
// it. Lift gas increments are allocated in turn to the well that
// currently has the largest weighted incremental gradient. The
// procedure takes account of any limits on the group production
// rate or lift gas supply applied to any level of group.
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::
gasLiftOptimizationStage2(DeferredLogger& deferred_logger,
GLiftProdWells &prod_wells, GLiftOptWells &glift_wells,
GLiftWellStateMap &glift_well_state_map)
{
GasLiftStage2 glift {this->ebosSimulator_.episodeIndex(),
this->ebosSimulator_.vanguard().grid().comm(),
ebosSimulator_.vanguard().schedule(),
ebosSimulator_.vanguard().summaryState(),
deferred_logger, this->wellState(),
prod_wells, glift_wells, glift_well_state_map};
glift.runOptimize();
}
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::
gliftDebugShowALQ(DeferredLogger& deferred_logger)
{
for (auto& well : this->well_container_) {
if (well->isProducer()) {
auto alq = this->wellState().getALQ(well->name());
const std::string msg = fmt::format("ALQ_REPORT : {} : {}",
well->name(), alq);
gliftDebug(msg, deferred_logger);
}
}
}
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::