mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
split out typetag independent code from BlackoilWellModel
This commit is contained in:
parent
ce3d2b17dd
commit
059140f2ee
@ -55,6 +55,7 @@ list (APPEND MAIN_SOURCE_FILES
|
|||||||
opm/simulators/utils/ParallelFileMerger.cpp
|
opm/simulators/utils/ParallelFileMerger.cpp
|
||||||
opm/simulators/utils/ParallelRestart.cpp
|
opm/simulators/utils/ParallelRestart.cpp
|
||||||
opm/simulators/wells/ALQState.cpp
|
opm/simulators/wells/ALQState.cpp
|
||||||
|
opm/simulators/wells/BlackoilWellModelGeneric.cpp
|
||||||
opm/simulators/wells/GasLiftSingleWellGeneric.cpp
|
opm/simulators/wells/GasLiftSingleWellGeneric.cpp
|
||||||
opm/simulators/wells/GasLiftStage2.cpp
|
opm/simulators/wells/GasLiftStage2.cpp
|
||||||
opm/simulators/wells/GlobalWellInfo.cpp
|
opm/simulators/wells/GlobalWellInfo.cpp
|
||||||
|
@ -568,8 +568,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
data::GroupAndNetworkValues
|
data::GroupAndNetworkValues
|
||||||
groupAndNetworkData(const int /* reportStepIdx */,
|
groupAndNetworkData(const int /* reportStepIdx */)
|
||||||
const Schedule& /* sched */) const
|
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ public:
|
|||||||
|
|
||||||
const auto localWellData = simulator_.problem().wellModel().wellData();
|
const auto localWellData = simulator_.problem().wellModel().wellData();
|
||||||
const auto localGroupAndNetworkData = simulator_.problem().wellModel()
|
const auto localGroupAndNetworkData = simulator_.problem().wellModel()
|
||||||
.groupAndNetworkData(reportStepNum, simulator_.vanguard().schedule());
|
.groupAndNetworkData(reportStepNum);
|
||||||
|
|
||||||
|
|
||||||
const auto localAquiferData = simulator_.problem().aquiferModel().aquiferData();
|
const auto localAquiferData = simulator_.problem().aquiferModel().aquiferData();
|
||||||
@ -229,7 +229,7 @@ public:
|
|||||||
// output using eclWriter if enabled
|
// output using eclWriter if enabled
|
||||||
auto localWellData = simulator_.problem().wellModel().wellData();
|
auto localWellData = simulator_.problem().wellModel().wellData();
|
||||||
auto localGroupAndNetworkData = simulator_.problem().wellModel()
|
auto localGroupAndNetworkData = simulator_.problem().wellModel()
|
||||||
.groupAndNetworkData(reportStepNum, simulator_.vanguard().schedule());
|
.groupAndNetworkData(reportStepNum);
|
||||||
|
|
||||||
auto localAquiferData = simulator_.problem().aquiferModel().aquiferData();
|
auto localAquiferData = simulator_.problem().aquiferModel().aquiferData();
|
||||||
|
|
||||||
|
@ -27,11 +27,7 @@
|
|||||||
#include <ebos/eclproblem.hh>
|
#include <ebos/eclproblem.hh>
|
||||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||||
|
|
||||||
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
|
||||||
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <functional>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -48,7 +44,6 @@
|
|||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp>
|
|
||||||
|
|
||||||
#include <opm/simulators/timestepping/SimulatorReport.hpp>
|
#include <opm/simulators/timestepping/SimulatorReport.hpp>
|
||||||
#include <opm/simulators/flow/countGlobalCells.hpp>
|
#include <opm/simulators/flow/countGlobalCells.hpp>
|
||||||
@ -76,6 +71,8 @@
|
|||||||
|
|
||||||
#include <opm/simulators/utils/DeferredLogger.hpp>
|
#include <opm/simulators/utils/DeferredLogger.hpp>
|
||||||
|
|
||||||
|
#include <opm/simulators/wells/BlackoilWellModelGeneric.hpp>
|
||||||
|
|
||||||
namespace Opm::Properties {
|
namespace Opm::Properties {
|
||||||
|
|
||||||
template<class TypeTag, class MyTypeTag>
|
template<class TypeTag, class MyTypeTag>
|
||||||
@ -90,6 +87,7 @@ namespace Opm {
|
|||||||
/// Class for handling the blackoil well model.
|
/// Class for handling the blackoil well model.
|
||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
class BlackoilWellModel : public BaseAuxiliaryModule<TypeTag>
|
class BlackoilWellModel : public BaseAuxiliaryModule<TypeTag>
|
||||||
|
, public BlackoilWellModelGeneric
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// --------- Types ---------
|
// --------- Types ---------
|
||||||
@ -212,126 +210,12 @@ namespace Opm {
|
|||||||
using WellInterfacePtr = std::shared_ptr<WellInterface<TypeTag> >;
|
using WellInterfacePtr = std::shared_ptr<WellInterface<TypeTag> >;
|
||||||
WellInterfacePtr well(const std::string& wellName) const;
|
WellInterfacePtr well(const std::string& wellName) const;
|
||||||
|
|
||||||
void initFromRestartFile(const RestartValue& restartValues);
|
using BlackoilWellModelGeneric::initFromRestartFile;
|
||||||
|
void initFromRestartFile(const RestartValue& restartValues)
|
||||||
data::GroupAndNetworkValues
|
|
||||||
groupAndNetworkData(const int reportStepIdx, const Schedule& sched) const
|
|
||||||
{
|
{
|
||||||
auto grp_nwrk_values = ::Opm::data::GroupAndNetworkValues{};
|
initFromRestartFile(restartValues,
|
||||||
|
UgGridHelpers::numCells(grid()),
|
||||||
this->assignGroupValues(reportStepIdx, sched, grp_nwrk_values.groupData);
|
param_.use_multisegment_well_);
|
||||||
this->assignNodeValues(grp_nwrk_values.nodeData);
|
|
||||||
|
|
||||||
return grp_nwrk_values;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
The dynamic state of the well model is maintained with an instance
|
|
||||||
of the WellState class. Currently we have
|
|
||||||
three different wellstate instances:
|
|
||||||
|
|
||||||
1. The currently active wellstate is in the active_well_state_
|
|
||||||
member. That is the state which is mutated by the simulator.
|
|
||||||
|
|
||||||
2. In the case timestep fails to converge and we must go back and
|
|
||||||
try again with a smaller timestep we need to recover the last
|
|
||||||
valid wellstate. This is maintained with the
|
|
||||||
last_valid_well_state_ member and the functions
|
|
||||||
commitWellState() and resetWellState().
|
|
||||||
|
|
||||||
3. For the NUPCOL functionality we should either use the
|
|
||||||
currently active wellstate or a wellstate frozen at max
|
|
||||||
nupcol iterations. This is handled with the member
|
|
||||||
nupcol_well_state_ and the initNupcolWellState() function.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Immutable version of the currently active wellstate.
|
|
||||||
*/
|
|
||||||
const WellState& wellState() const
|
|
||||||
{
|
|
||||||
return this->active_wgstate_.well_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Mutable version of the currently active wellstate.
|
|
||||||
*/
|
|
||||||
WellState& wellState()
|
|
||||||
{
|
|
||||||
return this->active_wgstate_.well_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Will return the last good wellstate. This is typcially used when
|
|
||||||
initializing a new report step where the Schedule object might
|
|
||||||
have introduced new wells. The wellstate returned by
|
|
||||||
prevWellState() must have been stored with the commitWellState()
|
|
||||||
function first.
|
|
||||||
*/
|
|
||||||
const WellState& prevWellState() const
|
|
||||||
{
|
|
||||||
return this->last_valid_wgstate_.well_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
const WGState& prevWGState() const
|
|
||||||
{
|
|
||||||
return this->last_valid_wgstate_;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
Will return the currently active nupcolWellState; must initialize
|
|
||||||
the internal nupcol wellstate with initNupcolWellState() first.
|
|
||||||
*/
|
|
||||||
const WellState& nupcolWellState() const
|
|
||||||
{
|
|
||||||
return this->nupcol_wgstate_.well_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Will assign the internal member last_valid_well_state_ to the
|
|
||||||
current value of the this->active_well_state_. The state stored
|
|
||||||
with storeWellState() can then subsequently be recovered with the
|
|
||||||
resetWellState() method.
|
|
||||||
*/
|
|
||||||
void commitWGState()
|
|
||||||
{
|
|
||||||
this->last_valid_wgstate_ = this->active_wgstate_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Will store a copy of the input argument well_state in the
|
|
||||||
last_valid_well_state_ member, that state can then be recovered
|
|
||||||
with a subsequent call to resetWellState().
|
|
||||||
*/
|
|
||||||
void commitWGState(WGState wgstate)
|
|
||||||
{
|
|
||||||
this->last_valid_wgstate_ = std::move(wgstate);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Will update the internal variable active_well_state_ to whatever
|
|
||||||
was stored in the last_valid_well_state_ member. This function
|
|
||||||
works in pair with commitWellState() which should be called first.
|
|
||||||
*/
|
|
||||||
void resetWGState()
|
|
||||||
{
|
|
||||||
this->active_wgstate_ = this->last_valid_wgstate_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Will store the current active wellstate in the nupcol_well_state_
|
|
||||||
member. This can then be subsequently retrieved with accessor
|
|
||||||
nupcolWellState().
|
|
||||||
*/
|
|
||||||
void updateNupcolWGState()
|
|
||||||
{
|
|
||||||
this->nupcol_wgstate_ = this->active_wgstate_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const GroupState& groupState() const
|
|
||||||
{
|
|
||||||
return this->active_wgstate_.group_state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data::Wells wellData() const
|
data::Wells wellData() const
|
||||||
@ -343,7 +227,7 @@ namespace Opm {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this->assignWellGuideRates(wsrpt);
|
this->assignWellGuideRates(wsrpt);
|
||||||
this->assignShutConnections(wsrpt);
|
this->assignShutConnections(wsrpt, this->reportStepIndex());
|
||||||
|
|
||||||
return wsrpt;
|
return wsrpt;
|
||||||
}
|
}
|
||||||
@ -365,8 +249,6 @@ namespace Opm {
|
|||||||
// Check if well equations is converged.
|
// Check if well equations is converged.
|
||||||
ConvergenceReport getWellConvergence(const std::vector<Scalar>& B_avg, const bool checkGroupConvergence = false) const;
|
ConvergenceReport getWellConvergence(const std::vector<Scalar>& B_avg, const bool checkGroupConvergence = false) const;
|
||||||
|
|
||||||
const PhaseUsage& phaseUsage() const { return phase_usage_; }
|
|
||||||
|
|
||||||
const SimulatorReportSingle& lastReport() const;
|
const SimulatorReportSingle& lastReport() const;
|
||||||
|
|
||||||
void addWellContributions(SparseMatrixAdapter& jacobian) const
|
void addWellContributions(SparseMatrixAdapter& jacobian) const
|
||||||
@ -386,11 +268,6 @@ namespace Opm {
|
|||||||
/// Returns true if the well was actually found and shut.
|
/// Returns true if the well was actually found and shut.
|
||||||
bool forceShutWellByNameIfPredictionMode(const std::string& wellname, const double simulation_time);
|
bool forceShutWellByNameIfPredictionMode(const std::string& wellname, const double simulation_time);
|
||||||
|
|
||||||
void updateEclWells(const int timeStepIdx, const std::unordered_set<std::string>& wells);
|
|
||||||
bool hasWell(const std::string& wname);
|
|
||||||
double wellPI(const int well_index) const;
|
|
||||||
double wellPI(const std::string& well_name) const;
|
|
||||||
|
|
||||||
void updatePerforationIntensiveQuantities();
|
void updatePerforationIntensiveQuantities();
|
||||||
// it should be able to go to prepareTimeStep(), however, the updateWellControls() and initPrimaryVariablesEvaluation()
|
// it should be able to go to prepareTimeStep(), however, the updateWellControls() and initPrimaryVariablesEvaluation()
|
||||||
// makes it a little more difficult. unless we introduce if (iterationIdx != 0) to avoid doing the above functions
|
// makes it a little more difficult. unless we introduce if (iterationIdx != 0) to avoid doing the above functions
|
||||||
@ -404,33 +281,17 @@ namespace Opm {
|
|||||||
void initPrimaryVariablesEvaluation() const;
|
void initPrimaryVariablesEvaluation() const;
|
||||||
void updateWellControls(DeferredLogger& deferred_logger, const bool checkGroupControls);
|
void updateWellControls(DeferredLogger& deferred_logger, const bool checkGroupControls);
|
||||||
WellInterfacePtr getWell(const std::string& well_name) const;
|
WellInterfacePtr getWell(const std::string& well_name) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Simulator& ebosSimulator_;
|
Simulator& ebosSimulator_;
|
||||||
|
|
||||||
std::vector< Well > wells_ecl_{};
|
|
||||||
std::vector< std::vector<PerforationData> > well_perf_data_{};
|
|
||||||
std::vector< WellProdIndexCalculator > prod_index_calc_{};
|
|
||||||
std::vector<int> local_shut_wells_{};
|
std::vector<int> local_shut_wells_{};
|
||||||
|
|
||||||
std::vector< ParallelWellInfo > parallel_well_info_;
|
|
||||||
std::vector< ParallelWellInfo* > local_parallel_well_info_;
|
|
||||||
|
|
||||||
bool wells_active_{false};
|
|
||||||
|
|
||||||
// a vector of all the wells.
|
// a vector of all the wells.
|
||||||
std::vector<WellInterfacePtr > well_container_{};
|
std::vector<WellInterfacePtr > well_container_{};
|
||||||
|
|
||||||
// Map from logically cartesian cell indices to compressed ones.
|
|
||||||
// Cells not in the interior are not mapped. This deactivates
|
|
||||||
// these for distributed wells and makes the distribution non-overlapping.
|
|
||||||
std::vector<int> cartesian_to_compressed_{};
|
|
||||||
|
|
||||||
std::vector<bool> is_cell_perforated_{};
|
std::vector<bool> is_cell_perforated_{};
|
||||||
|
|
||||||
std::function<bool(const Well&)> not_on_process_{};
|
|
||||||
|
|
||||||
void initializeWellProdIndCalculators();
|
|
||||||
void initializeWellPerfData();
|
|
||||||
void initializeWellState(const int timeStepIdx,
|
void initializeWellState(const int timeStepIdx,
|
||||||
const SummaryState& summaryState);
|
const SummaryState& summaryState);
|
||||||
|
|
||||||
@ -452,15 +313,11 @@ namespace Opm {
|
|||||||
|
|
||||||
|
|
||||||
const ModelParameters param_;
|
const ModelParameters param_;
|
||||||
bool terminal_output_{false};
|
|
||||||
std::vector<int> pvt_region_idx_{};
|
|
||||||
PhaseUsage phase_usage_;
|
|
||||||
size_t global_num_cells_{};
|
size_t global_num_cells_{};
|
||||||
// the number of the cells in the local grid
|
// the number of the cells in the local grid
|
||||||
size_t local_num_cells_{};
|
size_t local_num_cells_{};
|
||||||
double gravity_{};
|
double gravity_{};
|
||||||
std::vector<double> depth_{};
|
std::vector<double> depth_{};
|
||||||
bool initial_step_{};
|
|
||||||
bool report_step_starts_{};
|
bool report_step_starts_{};
|
||||||
bool glift_debug = false;
|
bool glift_debug = false;
|
||||||
bool alternative_well_rate_init_{};
|
bool alternative_well_rate_init_{};
|
||||||
@ -472,12 +329,6 @@ namespace Opm {
|
|||||||
|
|
||||||
SimulatorReportSingle last_report_{};
|
SimulatorReportSingle last_report_{};
|
||||||
|
|
||||||
WellTestState wellTestState_{};
|
|
||||||
std::unique_ptr<GuideRate> guideRate_{};
|
|
||||||
|
|
||||||
std::map<std::string, double> node_pressures_{}; // Storing network pressures for output.
|
|
||||||
mutable std::unordered_set<std::string> closed_this_step_{};
|
|
||||||
|
|
||||||
// used to better efficiency of calcuation
|
// used to better efficiency of calcuation
|
||||||
mutable BVector scaleAddRes_{};
|
mutable BVector scaleAddRes_{};
|
||||||
|
|
||||||
@ -489,23 +340,10 @@ namespace Opm {
|
|||||||
const EclipseState& eclState() const
|
const EclipseState& eclState() const
|
||||||
{ return ebosSimulator_.vanguard().eclState(); }
|
{ return ebosSimulator_.vanguard().eclState(); }
|
||||||
|
|
||||||
const Schedule& schedule() const
|
|
||||||
{ return ebosSimulator_.vanguard().schedule(); }
|
|
||||||
|
|
||||||
void gliftDebug(
|
void gliftDebug(
|
||||||
const std::string &msg,
|
const std::string &msg,
|
||||||
DeferredLogger& deferred_logger) const;
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
/// \brief Get the wells of our partition that are not shut.
|
|
||||||
/// \param timeStepIdx The index of the time step.
|
|
||||||
/// \param[out] globalNumWells the number of wells globally.
|
|
||||||
std::vector< Well > getLocalWells(const int timeStepId) const;
|
|
||||||
|
|
||||||
/// \brief Create the parallel well information
|
|
||||||
/// \param localWells The local wells from ECL schedule
|
|
||||||
std::vector< ParallelWellInfo* >
|
|
||||||
createLocalParallelWellInfo(const std::vector<Well>& localWells);
|
|
||||||
|
|
||||||
// compute the well fluxes and assemble them in to the reservoir equations as source terms
|
// compute the well fluxes and assemble them in to the reservoir equations as source terms
|
||||||
// and in the well equations.
|
// and in the well equations.
|
||||||
void assemble(const int iterationIdx,
|
void assemble(const int iterationIdx,
|
||||||
@ -521,7 +359,6 @@ namespace Opm {
|
|||||||
// xw to update Well State
|
// xw to update Well State
|
||||||
void recoverWellSolutionAndUpdateWellState(const BVector& x);
|
void recoverWellSolutionAndUpdateWellState(const BVector& x);
|
||||||
|
|
||||||
void updateAndCommunicateGroupData();
|
|
||||||
void updateNetworkPressures();
|
void updateNetworkPressures();
|
||||||
|
|
||||||
// setting the well_solutions_ based on well_state.
|
// setting the well_solutions_ based on well_state.
|
||||||
@ -549,10 +386,6 @@ namespace Opm {
|
|||||||
// The number of components in the model.
|
// The number of components in the model.
|
||||||
int numComponents() const;
|
int numComponents() const;
|
||||||
|
|
||||||
int numLocalWells() const;
|
|
||||||
|
|
||||||
int numPhases() const;
|
|
||||||
|
|
||||||
int reportStepIndex() const;
|
int reportStepIndex() const;
|
||||||
|
|
||||||
void assembleWellEq(const double dt, DeferredLogger& deferred_logger);
|
void assembleWellEq(const double dt, DeferredLogger& deferred_logger);
|
||||||
@ -569,91 +402,22 @@ namespace Opm {
|
|||||||
|
|
||||||
void extractLegacyDepth_();
|
void extractLegacyDepth_();
|
||||||
|
|
||||||
/// return true if wells are available in the reservoir
|
|
||||||
bool wellsActive() const;
|
|
||||||
|
|
||||||
void setWellsActive(const bool wells_active);
|
|
||||||
|
|
||||||
/// return true if wells are available on this process
|
|
||||||
bool localWellsActive() const;
|
|
||||||
|
|
||||||
/// upate the wellTestState related to economic limits
|
/// upate the wellTestState related to economic limits
|
||||||
void updateWellTestState(const double& simulationTime, WellTestState& wellTestState) const;
|
void updateWellTestState(const double& simulationTime, WellTestState& wellTestState) const;
|
||||||
|
|
||||||
void wellTesting(const int timeStepIdx, const double simulationTime, DeferredLogger& deferred_logger);
|
void wellTesting(const int timeStepIdx, const double simulationTime, DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
// convert well data from opm-common to well state from opm-core
|
void setWellWsolvent(const std::string& name, double wsolvent) override;
|
||||||
void loadRestartData( const data::Wells& wells,
|
void calcRates(const int fipnum,
|
||||||
const data::GroupAndNetworkValues& grpNwrkValues,
|
const int pvtreg,
|
||||||
const PhaseUsage& phases,
|
std::vector<double>& resv_coeff) override;
|
||||||
const bool handle_ms_well,
|
|
||||||
WellState& state );
|
|
||||||
|
|
||||||
// whether there exists any multisegment well open on this process
|
|
||||||
bool anyMSWellOpenLocal() const;
|
|
||||||
|
|
||||||
const Well& getWellEcl(const std::string& well_name) const;
|
|
||||||
|
|
||||||
void updateGroupIndividualControls(DeferredLogger& deferred_logger, std::set<std::string>& switched_groups);
|
|
||||||
void updateGroupIndividualControl(const Group& group, DeferredLogger& deferred_logger, std::set<std::string>& switched_groups);
|
|
||||||
bool checkGroupConstraints(const Group& group, DeferredLogger& deferred_logger) const;
|
|
||||||
Group::ProductionCMode checkGroupProductionConstraints(const Group& group, DeferredLogger& deferred_logger) const;
|
|
||||||
Group::InjectionCMode checkGroupInjectionConstraints(const Group& group, const Phase& phase) const;
|
|
||||||
void checkGconsaleLimits(const Group& group, WellState& well_state, DeferredLogger& deferred_logger );
|
|
||||||
|
|
||||||
void updateGroupHigherControls(DeferredLogger& deferred_logger, std::set<std::string>& switched_groups);
|
|
||||||
void checkGroupHigherConstraints(const Group& group, DeferredLogger& deferred_logger, std::set<std::string>& switched_groups);
|
|
||||||
|
|
||||||
void actionOnBrokenConstraints(const Group& group, const Group::ExceedAction& exceed_action, const Group::ProductionCMode& newControl, DeferredLogger& deferred_logger);
|
|
||||||
|
|
||||||
void actionOnBrokenConstraints(const Group& group, const Group::InjectionCMode& newControl, const Phase& topUpPhase, DeferredLogger& deferred_logger);
|
|
||||||
|
|
||||||
void updateWsolvent(const Group& group, const Schedule& schedule, const int reportStepIdx, const WellState& wellState);
|
|
||||||
|
|
||||||
void setWsolvent(const Group& group, const Schedule& schedule, const int reportStepIdx, double wsolvent);
|
|
||||||
|
|
||||||
void runWellPIScaling(const int timeStepIdx, DeferredLogger& local_deferredLogger);
|
void runWellPIScaling(const int timeStepIdx, DeferredLogger& local_deferredLogger);
|
||||||
|
|
||||||
bool wasDynamicallyShutThisTimeStep(const int well_index) const;
|
void computeWellTemperature();
|
||||||
|
|
||||||
void assignWellGuideRates(data::Wells& wsrpt) const;
|
|
||||||
void assignShutConnections(data::Wells& wsrpt) const;
|
|
||||||
void assignGroupValues(const int reportStepIdx,
|
|
||||||
const Schedule& sched,
|
|
||||||
std::map<std::string, data::GroupData>& gvalues) const;
|
|
||||||
|
|
||||||
void assignNodeValues(std::map<std::string, data::NodeData>& gvalues) const;
|
|
||||||
|
|
||||||
std::unordered_map<std::string, data::GroupGuideRates>
|
|
||||||
calculateAllGroupGuiderates(const int reportStepIdx, const Schedule& sched) const;
|
|
||||||
|
|
||||||
void assignGroupControl(const Group& group, data::GroupData& gdata) const;
|
|
||||||
data::GuideRateValue getGuideRateValues(const Well& well) const;
|
|
||||||
data::GuideRateValue getGuideRateValues(const Group& group) const;
|
|
||||||
data::GuideRateValue getGuideRateInjectionGroupValues(const Group& group) const;
|
|
||||||
void getGuideRateValues(const GuideRate::RateVector& qs,
|
|
||||||
const bool is_inj,
|
|
||||||
const std::string& wgname,
|
|
||||||
data::GuideRateValue& grval) const;
|
|
||||||
|
|
||||||
void assignGroupGuideRates(const Group& group,
|
|
||||||
const std::unordered_map<std::string, data::GroupGuideRates>& groupGuideRates,
|
|
||||||
data::GroupData& gdata) const;
|
|
||||||
|
|
||||||
void computeWellTemperature();
|
|
||||||
private:
|
private:
|
||||||
GroupState& groupState() { return this->active_wgstate_.group_state; }
|
|
||||||
BlackoilWellModel(Simulator& ebosSimulator, const PhaseUsage& pu);
|
BlackoilWellModel(Simulator& ebosSimulator, const PhaseUsage& pu);
|
||||||
/*
|
|
||||||
The various wellState members should be accessed and modified
|
|
||||||
through the accessor functions wellState(), prevWellState(),
|
|
||||||
commitWellState(), resetWellState(), nupcolWellState() and
|
|
||||||
updateNupcolWellState().
|
|
||||||
*/
|
|
||||||
WGState active_wgstate_;
|
|
||||||
WGState last_valid_wgstate_;
|
|
||||||
WGState nupcol_wgstate_;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1511
opm/simulators/wells/BlackoilWellModelGeneric.cpp
Normal file
1511
opm/simulators/wells/BlackoilWellModelGeneric.cpp
Normal file
File diff suppressed because it is too large
Load Diff
355
opm/simulators/wells/BlackoilWellModelGeneric.hpp
Normal file
355
opm/simulators/wells/BlackoilWellModelGeneric.hpp
Normal file
@ -0,0 +1,355 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 SINTEF ICT, Applied Mathematics.
|
||||||
|
Copyright 2016 - 2017 Statoil ASA.
|
||||||
|
Copyright 2017 Dr. Blatt - HPC-Simulation-Software & Services
|
||||||
|
Copyright 2016 - 2018 IRIS AS
|
||||||
|
|
||||||
|
This file is part of the Open Porous Media project (OPM).
|
||||||
|
|
||||||
|
OPM is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OPM is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef OPM_BLACKOILWELLMODEL_GENERIC_HEADER_INCLUDED
|
||||||
|
#define OPM_BLACKOILWELLMODEL_GENERIC_HEADER_INCLUDED
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <opm/output/data/GuideRateValue.hpp>
|
||||||
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp>
|
||||||
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp>
|
||||||
|
|
||||||
|
#include <opm/simulators/wells/PerforationData.hpp>
|
||||||
|
#include <opm/simulators/wells/WGState.hpp>
|
||||||
|
#include <opm/simulators/wells/WellProdIndexCalculator.hpp>
|
||||||
|
#include <opm/simulators/wells/ParallelWellInfo.hpp>
|
||||||
|
|
||||||
|
namespace Opm {
|
||||||
|
|
||||||
|
namespace data {
|
||||||
|
struct GroupData;
|
||||||
|
struct GroupGuideRates;
|
||||||
|
struct GroupAndNetworkValues;
|
||||||
|
struct NodeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeferredLogger;
|
||||||
|
class EclipseState;
|
||||||
|
class Group;
|
||||||
|
class RestartValue;
|
||||||
|
class Schedule;
|
||||||
|
class WellState;
|
||||||
|
|
||||||
|
/// Class for handling the blackoil well model.
|
||||||
|
class BlackoilWellModelGeneric
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// --------- Types ---------
|
||||||
|
using Comm = Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator>;
|
||||||
|
|
||||||
|
BlackoilWellModelGeneric(const Schedule& schedule,
|
||||||
|
const SummaryState& summaryState,
|
||||||
|
const EclipseState& eclState,
|
||||||
|
const PhaseUsage& phase_usage,
|
||||||
|
const Comm& comm);
|
||||||
|
|
||||||
|
virtual ~BlackoilWellModelGeneric() = default;
|
||||||
|
|
||||||
|
int numLocalWells() const;
|
||||||
|
int numPhases() const;
|
||||||
|
|
||||||
|
/// return true if wells are available in the reservoir
|
||||||
|
bool wellsActive() const;
|
||||||
|
bool hasWell(const std::string& wname);
|
||||||
|
/// return true if wells are available on this process
|
||||||
|
bool localWellsActive() const;
|
||||||
|
// whether there exists any multisegment well open on this process
|
||||||
|
bool anyMSWellOpenLocal() const;
|
||||||
|
|
||||||
|
const Well& getWellEcl(const std::string& well_name) const;
|
||||||
|
std::vector<Well> getLocalWells(const int timeStepIdx) const;
|
||||||
|
const Schedule& schedule() const { return schedule_; }
|
||||||
|
const PhaseUsage& phaseUsage() const { return phase_usage_; }
|
||||||
|
const GroupState& groupState() const { return this->active_wgstate_.group_state; }
|
||||||
|
|
||||||
|
/*
|
||||||
|
Immutable version of the currently active wellstate.
|
||||||
|
*/
|
||||||
|
const WellState& wellState() const
|
||||||
|
{
|
||||||
|
return this->active_wgstate_.well_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Mutable version of the currently active wellstate.
|
||||||
|
*/
|
||||||
|
WellState& wellState()
|
||||||
|
{
|
||||||
|
return this->active_wgstate_.well_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
double wellPI(const int well_index) const;
|
||||||
|
double wellPI(const std::string& well_name) const;
|
||||||
|
|
||||||
|
void updateEclWells(const int timeStepIdx,
|
||||||
|
const std::unordered_set<std::string>& wells);
|
||||||
|
|
||||||
|
|
||||||
|
void loadRestartData(const data::Wells& rst_wells,
|
||||||
|
const data::GroupAndNetworkValues& grpNwrkValues,
|
||||||
|
const PhaseUsage& phases,
|
||||||
|
const bool handle_ms_well,
|
||||||
|
WellState& well_state);
|
||||||
|
|
||||||
|
void initFromRestartFile(const RestartValue& restartValues,
|
||||||
|
const size_t numCells,
|
||||||
|
bool handle_ms_well);
|
||||||
|
|
||||||
|
void setWellsActive(const bool wells_active);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Will assign the internal member last_valid_well_state_ to the
|
||||||
|
current value of the this->active_well_state_. The state stored
|
||||||
|
with storeWellState() can then subsequently be recovered with the
|
||||||
|
resetWellState() method.
|
||||||
|
*/
|
||||||
|
void commitWGState()
|
||||||
|
{
|
||||||
|
this->last_valid_wgstate_ = this->active_wgstate_;
|
||||||
|
}
|
||||||
|
|
||||||
|
data::GroupAndNetworkValues groupAndNetworkData(const int reportStepIdx) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
GroupState& groupState() { return this->active_wgstate_.group_state; }
|
||||||
|
|
||||||
|
/*
|
||||||
|
The dynamic state of the well model is maintained with an instance
|
||||||
|
of the WellState class. Currently we have
|
||||||
|
three different wellstate instances:
|
||||||
|
|
||||||
|
1. The currently active wellstate is in the active_well_state_
|
||||||
|
member. That is the state which is mutated by the simulator.
|
||||||
|
|
||||||
|
2. In the case timestep fails to converge and we must go back and
|
||||||
|
try again with a smaller timestep we need to recover the last
|
||||||
|
valid wellstate. This is maintained with the
|
||||||
|
last_valid_well_state_ member and the functions
|
||||||
|
commitWellState() and resetWellState().
|
||||||
|
|
||||||
|
3. For the NUPCOL functionality we should either use the
|
||||||
|
currently active wellstate or a wellstate frozen at max
|
||||||
|
nupcol iterations. This is handled with the member
|
||||||
|
nupcol_well_state_ and the initNupcolWellState() function.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Will return the last good wellstate. This is typcially used when
|
||||||
|
initializing a new report step where the Schedule object might
|
||||||
|
have introduced new wells. The wellstate returned by
|
||||||
|
prevWellState() must have been stored with the commitWellState()
|
||||||
|
function first.
|
||||||
|
*/
|
||||||
|
const WellState& prevWellState() const
|
||||||
|
{
|
||||||
|
return this->last_valid_wgstate_.well_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
const WGState& prevWGState() const
|
||||||
|
{
|
||||||
|
return this->last_valid_wgstate_;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Will return the currently active nupcolWellState; must initialize
|
||||||
|
the internal nupcol wellstate with initNupcolWellState() first.
|
||||||
|
*/
|
||||||
|
const WellState& nupcolWellState() const
|
||||||
|
{
|
||||||
|
return this->nupcol_wgstate_.well_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Will store a copy of the input argument well_state in the
|
||||||
|
last_valid_well_state_ member, that state can then be recovered
|
||||||
|
with a subsequent call to resetWellState().
|
||||||
|
*/
|
||||||
|
void commitWGState(WGState wgstate)
|
||||||
|
{
|
||||||
|
this->last_valid_wgstate_ = std::move(wgstate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Will update the internal variable active_well_state_ to whatever
|
||||||
|
was stored in the last_valid_well_state_ member. This function
|
||||||
|
works in pair with commitWellState() which should be called first.
|
||||||
|
*/
|
||||||
|
void resetWGState()
|
||||||
|
{
|
||||||
|
this->active_wgstate_ = this->last_valid_wgstate_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Will store the current active wellstate in the nupcol_well_state_
|
||||||
|
member. This can then be subsequently retrieved with accessor
|
||||||
|
nupcolWellState().
|
||||||
|
*/
|
||||||
|
void updateNupcolWGState()
|
||||||
|
{
|
||||||
|
this->nupcol_wgstate_ = this->active_wgstate_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief Create the parallel well information
|
||||||
|
/// \param localWells The local wells from ECL schedule
|
||||||
|
std::vector<ParallelWellInfo*> createLocalParallelWellInfo(const std::vector<Well>& wells);
|
||||||
|
|
||||||
|
void initializeWellProdIndCalculators();
|
||||||
|
void initializeWellPerfData();
|
||||||
|
|
||||||
|
bool wasDynamicallyShutThisTimeStep(const int well_index) const;
|
||||||
|
|
||||||
|
void updateWsolvent(const Group& group,
|
||||||
|
const int reportStepIdx,
|
||||||
|
const WellState& wellState);
|
||||||
|
void setWsolvent(const Group& group,
|
||||||
|
const int reportStepIdx,
|
||||||
|
double wsolvent);
|
||||||
|
virtual void setWellWsolvent(const std::string& name, double wsolvent) = 0;
|
||||||
|
virtual void calcRates(const int fipnum,
|
||||||
|
const int pvtreg,
|
||||||
|
std::vector<double>& resv_coeff) = 0;
|
||||||
|
|
||||||
|
data::GuideRateValue getGuideRateValues(const Group& group) const;
|
||||||
|
data::GuideRateValue getGuideRateValues(const Well& well) const;
|
||||||
|
data::GuideRateValue getGuideRateInjectionGroupValues(const Group& group) const;
|
||||||
|
void getGuideRateValues(const GuideRate::RateVector& qs,
|
||||||
|
const bool is_inj,
|
||||||
|
const std::string& wgname,
|
||||||
|
data::GuideRateValue& grval) const;
|
||||||
|
|
||||||
|
void assignWellGuideRates(data::Wells& wsrpt) const;
|
||||||
|
void assignShutConnections(data::Wells& wsrpt,
|
||||||
|
const int reportStepIndex) const;
|
||||||
|
void assignGroupControl(const Group& group,
|
||||||
|
data::GroupData& gdata) const;
|
||||||
|
void assignGroupGuideRates(const Group& group,
|
||||||
|
const std::unordered_map<std::string, data::GroupGuideRates>& groupGuideRates,
|
||||||
|
data::GroupData& gdata) const;
|
||||||
|
void assignGroupValues(const int reportStepIdx,
|
||||||
|
std::map<std::string, data::GroupData>& gvalues) const;
|
||||||
|
void assignNodeValues(std::map<std::string, data::NodeData>& nodevalues) const;
|
||||||
|
|
||||||
|
std::unordered_map<std::string, data::GroupGuideRates>
|
||||||
|
calculateAllGroupGuiderates(const int reportStepIdx) const;
|
||||||
|
|
||||||
|
bool checkGroupConstraints(const Group& group,
|
||||||
|
const int reportStepIdx,
|
||||||
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
|
Group::InjectionCMode checkGroupInjectionConstraints(const Group& group,
|
||||||
|
const int reportStepIdx,
|
||||||
|
const Phase& phase) const;
|
||||||
|
Group::ProductionCMode checkGroupProductionConstraints(const Group& group,
|
||||||
|
const int reportStepIdx,
|
||||||
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
|
void checkGconsaleLimits(const Group& group,
|
||||||
|
WellState& well_state,
|
||||||
|
const int reportStepIdx,
|
||||||
|
DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
|
void checkGroupHigherConstraints(const Group& group,
|
||||||
|
DeferredLogger& deferred_logger,
|
||||||
|
const int reportStepIdx,
|
||||||
|
std::set<std::string>& switched_groups);
|
||||||
|
|
||||||
|
void updateGroupIndividualControl(const Group& group,
|
||||||
|
DeferredLogger& deferred_logger,
|
||||||
|
const int reportStepIdx,
|
||||||
|
std::set<std::string>& switched_groups);
|
||||||
|
|
||||||
|
void updateGroupIndividualControls(DeferredLogger& deferred_logger,
|
||||||
|
std::set<std::string>& switched_groups,
|
||||||
|
const int reportStepIdx,
|
||||||
|
const int iterationIdx);
|
||||||
|
|
||||||
|
void updateGroupHigherControls(DeferredLogger& deferred_logger,
|
||||||
|
const int reportStepIdx,
|
||||||
|
std::set<std::string>& switched_groups);
|
||||||
|
|
||||||
|
void actionOnBrokenConstraints(const Group& group,
|
||||||
|
const Group::ExceedAction& exceed_action,
|
||||||
|
const Group::ProductionCMode& newControl,
|
||||||
|
DeferredLogger& deferred_logger);
|
||||||
|
void actionOnBrokenConstraints(const Group& group,
|
||||||
|
const Group::InjectionCMode& newControl,
|
||||||
|
const Phase& controlPhase,
|
||||||
|
DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
|
void updateAndCommunicateGroupData(const int reportStepIdx,
|
||||||
|
const int iterationIdx);
|
||||||
|
|
||||||
|
const Schedule& schedule_;
|
||||||
|
const SummaryState& summaryState_;
|
||||||
|
const EclipseState& eclState_;
|
||||||
|
const Comm& comm_;
|
||||||
|
|
||||||
|
PhaseUsage phase_usage_;
|
||||||
|
bool terminal_output_{false};
|
||||||
|
bool wells_active_{false};
|
||||||
|
bool initial_step_{};
|
||||||
|
|
||||||
|
std::vector<Well> wells_ecl_;
|
||||||
|
std::vector<std::vector<PerforationData>> well_perf_data_;
|
||||||
|
std::function<bool(const Well&)> not_on_process_{};
|
||||||
|
|
||||||
|
std::vector<ParallelWellInfo> parallel_well_info_;
|
||||||
|
std::vector<ParallelWellInfo*> local_parallel_well_info_;
|
||||||
|
|
||||||
|
std::vector<WellProdIndexCalculator> prod_index_calc_;
|
||||||
|
|
||||||
|
// Map from logically cartesian cell indices to compressed ones.
|
||||||
|
// Cells not in the interior are not mapped. This deactivates
|
||||||
|
// these for distributed wells and makes the distribution non-overlapping.
|
||||||
|
std::vector<int> cartesian_to_compressed_;
|
||||||
|
|
||||||
|
std::vector<int> pvt_region_idx_;
|
||||||
|
|
||||||
|
mutable std::unordered_set<std::string> closed_this_step_;
|
||||||
|
|
||||||
|
WellTestState wellTestState_{};
|
||||||
|
std::unique_ptr<GuideRate> guideRate_;
|
||||||
|
std::map<std::string, double> node_pressures_; // Storing network pressures for output.
|
||||||
|
|
||||||
|
/*
|
||||||
|
The various wellState members should be accessed and modified
|
||||||
|
through the accessor functions wellState(), prevWellState(),
|
||||||
|
commitWellState(), resetWellState(), nupcolWellState() and
|
||||||
|
updateNupcolWellState().
|
||||||
|
*/
|
||||||
|
WGState active_wgstate_;
|
||||||
|
WGState last_valid_wgstate_;
|
||||||
|
WGState nupcol_wgstate_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Opm
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because it is too large
Load Diff
@ -160,7 +160,7 @@ BOOST_AUTO_TEST_CASE(G1)
|
|||||||
const auto &well = wells_ecl[*idx];
|
const auto &well = wells_ecl[*idx];
|
||||||
BOOST_CHECK_EQUAL( well.name(), "B-1H");
|
BOOST_CHECK_EQUAL( well.name(), "B-1H");
|
||||||
const auto& summary_state = simulator->vanguard().summaryState();
|
const auto& summary_state = simulator->vanguard().summaryState();
|
||||||
WellState &well_state = const_cast<WellState &>(well_model.wellState());
|
WellState &well_state = well_model.wellState();
|
||||||
GasLiftSingleWell glift {*std_well, *(simulator.get()), summary_state,
|
GasLiftSingleWell glift {*std_well, *(simulator.get()), summary_state,
|
||||||
deferred_logger, well_state};
|
deferred_logger, well_state};
|
||||||
auto state = glift.runOptimize(simulator->model().newtonMethod().numIterations());
|
auto state = glift.runOptimize(simulator->model().newtonMethod().numIterations());
|
||||||
|
Loading…
Reference in New Issue
Block a user