mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4211 from akva2/blackoilwellmodel_restart
Add class for handling restart initialization in BlackoilWellModel
This commit is contained in:
commit
f373c2f908
@ -81,6 +81,7 @@ list (APPEND MAIN_SOURCE_FILES
|
||||
opm/simulators/utils/ParallelRestart.cpp
|
||||
opm/simulators/wells/ALQState.cpp
|
||||
opm/simulators/wells/BlackoilWellModelGeneric.cpp
|
||||
opm/simulators/wells/BlackoilWellModelRestart.cpp
|
||||
opm/simulators/wells/GasLiftCommon.cpp
|
||||
opm/simulators/wells/GasLiftGroupInfo.cpp
|
||||
opm/simulators/wells/GasLiftSingleWellGeneric.cpp
|
||||
@ -347,6 +348,8 @@ list (APPEND PUBLIC_HEADER_FILES
|
||||
opm/simulators/wells/ALQState.hpp
|
||||
opm/simulators/wells/BlackoilWellModel.hpp
|
||||
opm/simulators/wells/BlackoilWellModel_impl.hpp
|
||||
opm/simulators/wells/BlackoilWellModelGeneric.hpp
|
||||
opm/simulators/wells/BlackoilWellModelRestart.hpp
|
||||
opm/simulators/wells/GasLiftCommon.hpp
|
||||
opm/simulators/wells/GasLiftGroupInfo.hpp
|
||||
opm/simulators/wells/GasLiftSingleWellGeneric.hpp
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||
|
||||
#include <opm/simulators/utils/DeferredLogger.hpp>
|
||||
#include <opm/simulators/wells/BlackoilWellModelRestart.hpp>
|
||||
#include <opm/simulators/wells/GasLiftStage2.hpp>
|
||||
#include <opm/simulators/wells/VFPProperties.hpp>
|
||||
#include <opm/simulators/wells/WellGroupHelpers.hpp>
|
||||
@ -56,36 +57,6 @@
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace {
|
||||
Opm::data::GuideRateValue::Item
|
||||
guideRateRestartItem(const Opm::GuideRateModel::Target target)
|
||||
{
|
||||
using Item = Opm::data::GuideRateValue::Item;
|
||||
using Target = Opm::GuideRateModel::Target;
|
||||
|
||||
static const auto items = std::unordered_map<Target, Item> {
|
||||
{ Target::OIL, Item::Oil },
|
||||
{ Target::GAS, Item::Gas },
|
||||
{ Target::WAT, Item::Water },
|
||||
{ Target::RES, Item::ResV },
|
||||
};
|
||||
|
||||
auto i = items.find(target);
|
||||
return (i == items.end()) ? Item::NumItems : i->second;
|
||||
}
|
||||
|
||||
Opm::GuideRate::GuideRateValue
|
||||
makeGuideRateValue(const Opm::data::GuideRateValue& restart,
|
||||
const Opm::GuideRateModel::Target target)
|
||||
{
|
||||
const auto item = guideRateRestartItem(target);
|
||||
|
||||
if (! restart.has(item)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return { 0.0, restart.get(item), target };
|
||||
}
|
||||
|
||||
struct RetrieveWellGuideRate
|
||||
{
|
||||
RetrieveWellGuideRate() = default;
|
||||
@ -370,7 +341,7 @@ numPhases() const
|
||||
|
||||
bool
|
||||
BlackoilWellModelGeneric::
|
||||
hasWell(const std::string& wname)
|
||||
hasWell(const std::string& wname) const
|
||||
{
|
||||
return std::any_of(this->wells_ecl_.begin(), this->wells_ecl_.end(),
|
||||
[&wname](const Well& well)
|
||||
@ -414,204 +385,6 @@ getWellEcl(const std::string& well_name) const
|
||||
return *well_ecl;
|
||||
}
|
||||
|
||||
void
|
||||
BlackoilWellModelGeneric::
|
||||
loadRestartConnectionData(const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& ws)
|
||||
{
|
||||
auto& perf_data = ws.perf_data;
|
||||
auto perf_pressure = perf_data.pressure.begin();
|
||||
auto perf_rates = perf_data.rates.begin();
|
||||
auto perf_phase_rates = perf_data.phase_rates.begin();
|
||||
|
||||
for (const auto& pd : old_perf_data) {
|
||||
const auto& rst_connection = rst_well.connections[pd.ecl_index];
|
||||
|
||||
*perf_pressure = rst_connection.pressure; ++perf_pressure;
|
||||
*perf_rates = rst_connection.reservoir_rate; ++perf_rates;
|
||||
|
||||
for (const auto& phase : phs) {
|
||||
*perf_phase_rates = rst_connection.rates.get(phase);
|
||||
++perf_phase_rates;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BlackoilWellModelGeneric::
|
||||
loadRestartSegmentData(const std::string& well_name,
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
SingleWellState& ws)
|
||||
{
|
||||
const auto& segment_set = this->getWellEcl(well_name).getSegments();
|
||||
const auto& rst_segments = rst_well.segments;
|
||||
|
||||
// \Note: Eventually we need to handle the situations that some segments are shut
|
||||
assert(0u + segment_set.size() == rst_segments.size());
|
||||
|
||||
const auto np = phs.size();
|
||||
const auto pres_idx = data::SegmentPressures::Value::Pressure;
|
||||
|
||||
auto& segments = ws.segments;
|
||||
auto& segment_pressure = segments.pressure;
|
||||
auto& segment_rates = segments.rates;
|
||||
for (const auto& [segNum, rst_segment] : rst_segments) {
|
||||
const int segment_index = segment_set.segmentNumberToIndex(segNum);
|
||||
|
||||
// Recovering segment rates and pressure from the restart values
|
||||
segment_pressure[segment_index] = rst_segment.pressures[pres_idx];
|
||||
|
||||
const auto& rst_segment_rates = rst_segment.rates;
|
||||
for (auto p = 0*np; p < np; ++p) {
|
||||
segment_rates[segment_index*np + p] = rst_segment_rates.get(phs[p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BlackoilWellModelGeneric::
|
||||
loadRestartWellData(const std::string& well_name,
|
||||
const bool handle_ms_well,
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& ws)
|
||||
{
|
||||
const auto np = phs.size();
|
||||
|
||||
ws.bhp = rst_well.bhp;
|
||||
ws.thp = rst_well.thp;
|
||||
ws.temperature = rst_well.temperature;
|
||||
|
||||
if (rst_well.current_control.isProducer) {
|
||||
ws.production_cmode = rst_well.current_control.prod;
|
||||
}
|
||||
else {
|
||||
ws.injection_cmode = rst_well.current_control.inj;
|
||||
}
|
||||
|
||||
for (auto i = 0*np; i < np; ++i) {
|
||||
assert( rst_well.rates.has( phs[ i ] ) );
|
||||
ws.surface_rates[i] = rst_well.rates.get(phs[i]);
|
||||
}
|
||||
|
||||
this->loadRestartConnectionData(phs, rst_well, old_perf_data, ws);
|
||||
|
||||
if (handle_ms_well && !rst_well.segments.empty()) {
|
||||
this->loadRestartSegmentData(well_name, phs, rst_well, ws);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BlackoilWellModelGeneric::
|
||||
loadRestartGroupData(const std::string& group,
|
||||
const data::GroupData& value)
|
||||
{
|
||||
using GPMode = Group::ProductionCMode;
|
||||
using GIMode = Group::InjectionCMode;
|
||||
|
||||
const auto cpc = value.currentControl.currentProdConstraint;
|
||||
const auto cgi = value.currentControl.currentGasInjectionConstraint;
|
||||
const auto cwi = value.currentControl.currentWaterInjectionConstraint;
|
||||
|
||||
auto& grpState = this->groupState();
|
||||
|
||||
if (cpc != GPMode::NONE) {
|
||||
grpState.production_control(group, cpc);
|
||||
}
|
||||
|
||||
if (cgi != GIMode::NONE) {
|
||||
grpState.injection_control(group, Phase::GAS, cgi);
|
||||
}
|
||||
|
||||
if (cwi != GIMode::NONE) {
|
||||
grpState.injection_control(group, Phase::WATER, cwi);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BlackoilWellModelGeneric::
|
||||
loadRestartGuideRates(const int report_step,
|
||||
const GuideRateModel::Target target,
|
||||
const data::Wells& rst_wells)
|
||||
{
|
||||
for (const auto& [well_name, rst_well] : rst_wells) {
|
||||
if (! this->hasWell(well_name) || this->getWellEcl(well_name).isInjector()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this->guideRate_.init_grvalue_SI(report_step, well_name,
|
||||
makeGuideRateValue(rst_well.guide_rates, target));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BlackoilWellModelGeneric::
|
||||
loadRestartGuideRates(const int report_step,
|
||||
const GuideRateConfig& config,
|
||||
const std::map<std::string, data::GroupData>& rst_groups)
|
||||
{
|
||||
const auto target = config.model().target();
|
||||
|
||||
for (const auto& [group_name, rst_group] : rst_groups) {
|
||||
if (! config.has_production_group(group_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& group = config.production_group(group_name);
|
||||
if ((group.guide_rate > 0.0) || (group.target != Group::GuideRateProdTarget::FORM)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this->guideRate_.init_grvalue_SI(report_step, group_name,
|
||||
makeGuideRateValue(rst_group.guideRates.production, target));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BlackoilWellModelGeneric::
|
||||
loadRestartData(const data::Wells& rst_wells,
|
||||
const data::GroupAndNetworkValues& grpNwrkValues,
|
||||
const PhaseUsage& phases,
|
||||
const bool handle_ms_well,
|
||||
WellState& well_state)
|
||||
{
|
||||
using rt = data::Rates::opt;
|
||||
const auto np = phases.num_phases;
|
||||
|
||||
std::vector<rt> phs(np);
|
||||
if (phases.phase_used[BlackoilPhases::Aqua]) {
|
||||
phs.at(phases.phase_pos[BlackoilPhases::Aqua]) = rt::wat;
|
||||
}
|
||||
|
||||
if (phases.phase_used[BlackoilPhases::Liquid]) {
|
||||
phs.at( phases.phase_pos[BlackoilPhases::Liquid] ) = rt::oil;
|
||||
}
|
||||
|
||||
if (phases.phase_used[BlackoilPhases::Vapour]) {
|
||||
phs.at( phases.phase_pos[BlackoilPhases::Vapour] ) = rt::gas;
|
||||
}
|
||||
|
||||
for (auto well_index = 0*well_state.size();
|
||||
well_index < well_state.size();
|
||||
++well_index)
|
||||
{
|
||||
const auto& well_name = well_state.name(well_index);
|
||||
|
||||
this->loadRestartWellData(well_name, handle_ms_well, phs,
|
||||
rst_wells.at(well_name),
|
||||
this->well_perf_data_[well_index],
|
||||
well_state.well(well_index));
|
||||
}
|
||||
|
||||
for (const auto& [group, value] : grpNwrkValues.groupData) {
|
||||
this->loadRestartGroupData(group, value);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BlackoilWellModelGeneric::
|
||||
initFromRestartFile(const RestartValue& restartValues,
|
||||
@ -641,23 +414,29 @@ initFromRestartFile(const RestartValue& restartValues,
|
||||
this->schedule(), handle_ms_well, numCells,
|
||||
this->well_perf_data_, this->summaryState_);
|
||||
|
||||
loadRestartData(restartValues.wells, restartValues.grp_nwrk,
|
||||
this->phase_usage_, handle_ms_well, this->wellState());
|
||||
BlackoilWellModelRestart(*this).loadRestartData(restartValues.wells,
|
||||
restartValues.grp_nwrk,
|
||||
handle_ms_well,
|
||||
this->wellState(),
|
||||
this->groupState());
|
||||
|
||||
if (config.has_model()) {
|
||||
this->loadRestartGuideRates(report_step,
|
||||
config.model().target(),
|
||||
restartValues.wells);
|
||||
BlackoilWellModelRestart(*this).loadRestartGuideRates(report_step,
|
||||
config.model().target(),
|
||||
restartValues.wells,
|
||||
this->guideRate_);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.has_model()) {
|
||||
this->loadRestartGuideRates(report_step, config, restartValues.grp_nwrk.groupData);
|
||||
BlackoilWellModelRestart(*this).loadRestartGuideRates(report_step,
|
||||
config,
|
||||
restartValues.grp_nwrk.groupData,
|
||||
this->guideRate_);
|
||||
|
||||
this->guideRate_.updateGuideRateExpiration(this->schedule().seconds(report_step), report_step);
|
||||
}
|
||||
|
||||
|
||||
this->active_wgstate_.wtest_state(std::move(wtestState));
|
||||
this->commitWGState();
|
||||
initial_step_ = false;
|
||||
@ -1277,7 +1056,6 @@ checkGroupHigherConstraints(const Group& group,
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return changed;
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
|
||||
/// return true if wells are available in the reservoir
|
||||
bool wellsActive() const;
|
||||
bool hasWell(const std::string& wname);
|
||||
bool hasWell(const std::string& wname) const;
|
||||
|
||||
// whether there exists any multisegment well open on this process
|
||||
bool anyMSWellOpenLocal() const;
|
||||
@ -130,13 +130,6 @@ public:
|
||||
const std::unordered_set<std::string>& wells,
|
||||
const SummaryState& st);
|
||||
|
||||
|
||||
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,
|
||||
WellTestState wtestState,
|
||||
const size_t numCells,
|
||||
@ -163,6 +156,10 @@ public:
|
||||
bool forceShutWellByName(const std::string& wellname,
|
||||
const double simulation_time);
|
||||
|
||||
|
||||
const std::vector<PerforationData>& perfData(const int well_idx) const
|
||||
{ return well_perf_data_[well_idx]; }
|
||||
|
||||
protected:
|
||||
|
||||
/*
|
||||
@ -286,34 +283,6 @@ protected:
|
||||
std::map<std::string, data::GroupData>& gvalues) const;
|
||||
void assignNodeValues(std::map<std::string, data::NodeData>& nodevalues) const;
|
||||
|
||||
void loadRestartConnectionData(const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& ws);
|
||||
|
||||
void loadRestartSegmentData(const std::string& well_name,
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
SingleWellState& ws);
|
||||
|
||||
void loadRestartWellData(const std::string& well_name,
|
||||
const bool handle_ms_well,
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& ws);
|
||||
|
||||
void loadRestartGroupData(const std::string& group,
|
||||
const data::GroupData& value);
|
||||
|
||||
void loadRestartGuideRates(const int report_step,
|
||||
const GuideRateModel::Target target,
|
||||
const data::Wells& rst_wells);
|
||||
|
||||
void loadRestartGuideRates(const int report_step,
|
||||
const GuideRateConfig& config,
|
||||
const std::map<std::string, data::GroupData>& rst_groups);
|
||||
|
||||
std::unordered_map<std::string, data::GroupGuideRates>
|
||||
calculateAllGroupGuiderates(const int reportStepIdx) const;
|
||||
|
||||
|
261
opm/simulators/wells/BlackoilWellModelRestart.cpp
Normal file
261
opm/simulators/wells/BlackoilWellModelRestart.cpp
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <opm/simulators/wells/BlackoilWellModelRestart.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/Group/GuideRateConfig.hpp>
|
||||
|
||||
#include <opm/output/data/Groups.hpp>
|
||||
|
||||
#include <opm/simulators/wells/BlackoilWellModelGeneric.hpp>
|
||||
#include <opm/simulators/wells/PerforationData.hpp>
|
||||
#include <opm/simulators/wells/SingleWellState.hpp>
|
||||
|
||||
namespace {
|
||||
Opm::data::GuideRateValue::Item
|
||||
guideRateRestartItem(const Opm::GuideRateModel::Target target)
|
||||
{
|
||||
using Item = Opm::data::GuideRateValue::Item;
|
||||
using Target = Opm::GuideRateModel::Target;
|
||||
|
||||
static const auto items = std::unordered_map<Target, Item> {
|
||||
{ Target::OIL, Item::Oil },
|
||||
{ Target::GAS, Item::Gas },
|
||||
{ Target::WAT, Item::Water },
|
||||
{ Target::RES, Item::ResV },
|
||||
};
|
||||
|
||||
auto i = items.find(target);
|
||||
return (i == items.end()) ? Item::NumItems : i->second;
|
||||
}
|
||||
|
||||
Opm::GuideRate::GuideRateValue
|
||||
makeGuideRateValue(const Opm::data::GuideRateValue& restart,
|
||||
const Opm::GuideRateModel::Target target)
|
||||
{
|
||||
const auto item = guideRateRestartItem(target);
|
||||
|
||||
if (! restart.has(item)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return { 0.0, restart.get(item), target };
|
||||
}
|
||||
} // Anonymous
|
||||
|
||||
namespace Opm {
|
||||
|
||||
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
|
||||
{
|
||||
auto& perf_data = ws.perf_data;
|
||||
auto perf_pressure = perf_data.pressure.begin();
|
||||
auto perf_rates = perf_data.rates.begin();
|
||||
auto perf_phase_rates = perf_data.phase_rates.begin();
|
||||
|
||||
for (const auto& pd : old_perf_data) {
|
||||
const auto& rst_connection = rst_well.connections[pd.ecl_index];
|
||||
|
||||
*perf_pressure = rst_connection.pressure; ++perf_pressure;
|
||||
*perf_rates = rst_connection.reservoir_rate; ++perf_rates;
|
||||
|
||||
for (const auto& phase : phs) {
|
||||
*perf_phase_rates = rst_connection.rates.get(phase);
|
||||
++perf_phase_rates;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlackoilWellModelRestart::
|
||||
loadRestartSegmentData(const std::string& well_name,
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
SingleWellState& ws) const
|
||||
{
|
||||
const auto& segment_set = wellModel_.getWellEcl(well_name).getSegments();
|
||||
const auto& rst_segments = rst_well.segments;
|
||||
|
||||
// \Note: Eventually we need to handle the situations that some segments are shut
|
||||
assert(0u + segment_set.size() == rst_segments.size());
|
||||
|
||||
const auto np = phs.size();
|
||||
const auto pres_idx = data::SegmentPressures::Value::Pressure;
|
||||
|
||||
auto& segments = ws.segments;
|
||||
auto& segment_pressure = segments.pressure;
|
||||
auto& segment_rates = segments.rates;
|
||||
for (const auto& [segNum, rst_segment] : rst_segments) {
|
||||
const int segment_index = segment_set.segmentNumberToIndex(segNum);
|
||||
|
||||
// Recovering segment rates and pressure from the restart values
|
||||
segment_pressure[segment_index] = rst_segment.pressures[pres_idx];
|
||||
|
||||
const auto& rst_segment_rates = rst_segment.rates;
|
||||
for (auto p = 0*np; p < np; ++p) {
|
||||
segment_rates[segment_index*np + p] = rst_segment_rates.get(phs[p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlackoilWellModelRestart::
|
||||
loadRestartWellData(const std::string& well_name,
|
||||
const bool handle_ms_well,
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& ws) const
|
||||
{
|
||||
const auto np = phs.size();
|
||||
|
||||
ws.bhp = rst_well.bhp;
|
||||
ws.thp = rst_well.thp;
|
||||
ws.temperature = rst_well.temperature;
|
||||
|
||||
if (rst_well.current_control.isProducer) {
|
||||
ws.production_cmode = rst_well.current_control.prod;
|
||||
}
|
||||
else {
|
||||
ws.injection_cmode = rst_well.current_control.inj;
|
||||
}
|
||||
|
||||
for (auto i = 0*np; i < np; ++i) {
|
||||
assert( rst_well.rates.has( phs[ i ] ) );
|
||||
ws.surface_rates[i] = rst_well.rates.get(phs[i]);
|
||||
}
|
||||
|
||||
this->loadRestartConnectionData(phs, rst_well, old_perf_data, ws);
|
||||
|
||||
if (handle_ms_well && !rst_well.segments.empty()) {
|
||||
this->loadRestartSegmentData(well_name, phs, rst_well, ws);
|
||||
}
|
||||
}
|
||||
|
||||
void BlackoilWellModelRestart::
|
||||
loadRestartGroupData(const std::string& group,
|
||||
const data::GroupData& value,
|
||||
GroupState& grpState) const
|
||||
{
|
||||
using GPMode = Group::ProductionCMode;
|
||||
using GIMode = Group::InjectionCMode;
|
||||
|
||||
const auto cpc = value.currentControl.currentProdConstraint;
|
||||
const auto cgi = value.currentControl.currentGasInjectionConstraint;
|
||||
const auto cwi = value.currentControl.currentWaterInjectionConstraint;
|
||||
|
||||
if (cpc != GPMode::NONE) {
|
||||
grpState.production_control(group, cpc);
|
||||
}
|
||||
|
||||
if (cgi != GIMode::NONE) {
|
||||
grpState.injection_control(group, Phase::GAS, cgi);
|
||||
}
|
||||
|
||||
if (cwi != GIMode::NONE) {
|
||||
grpState.injection_control(group, Phase::WATER, cwi);
|
||||
}
|
||||
}
|
||||
|
||||
void BlackoilWellModelRestart::
|
||||
loadRestartGuideRates(const int report_step,
|
||||
const GuideRateModel::Target target,
|
||||
const data::Wells& rst_wells,
|
||||
GuideRate& guide_rate) const
|
||||
{
|
||||
for (const auto& [well_name, rst_well] : rst_wells) {
|
||||
if (!wellModel_.hasWell(well_name) || wellModel_.getWellEcl(well_name).isInjector()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
guide_rate.init_grvalue_SI(report_step, well_name,
|
||||
makeGuideRateValue(rst_well.guide_rates, target));
|
||||
}
|
||||
}
|
||||
|
||||
void BlackoilWellModelRestart::
|
||||
loadRestartGuideRates(const int report_step,
|
||||
const GuideRateConfig& config,
|
||||
const std::map<std::string, data::GroupData>& rst_groups,
|
||||
GuideRate& guide_rate) const
|
||||
{
|
||||
const auto target = config.model().target();
|
||||
|
||||
for (const auto& [group_name, rst_group] : rst_groups) {
|
||||
if (!config.has_production_group(group_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& group = config.production_group(group_name);
|
||||
if ((group.guide_rate > 0.0) || (group.target != Group::GuideRateProdTarget::FORM)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
guide_rate.init_grvalue_SI(report_step, group_name,
|
||||
makeGuideRateValue(rst_group.guideRates.production, target));
|
||||
}
|
||||
}
|
||||
|
||||
void BlackoilWellModelRestart::
|
||||
loadRestartData(const data::Wells& rst_wells,
|
||||
const data::GroupAndNetworkValues& grpNwrkValues,
|
||||
const bool handle_ms_well,
|
||||
WellState& well_state,
|
||||
GroupState& grpState) const
|
||||
{
|
||||
using rt = data::Rates::opt;
|
||||
const auto& phases = wellModel_.phaseUsage();
|
||||
const auto np = phases.num_phases;
|
||||
|
||||
std::vector<rt> phs(np);
|
||||
if (phases.phase_used[BlackoilPhases::Aqua]) {
|
||||
phs.at(phases.phase_pos[BlackoilPhases::Aqua]) = rt::wat;
|
||||
}
|
||||
|
||||
if (phases.phase_used[BlackoilPhases::Liquid]) {
|
||||
phs.at( phases.phase_pos[BlackoilPhases::Liquid] ) = rt::oil;
|
||||
}
|
||||
|
||||
if (phases.phase_used[BlackoilPhases::Vapour]) {
|
||||
phs.at( phases.phase_pos[BlackoilPhases::Vapour] ) = rt::gas;
|
||||
}
|
||||
|
||||
for (auto well_index = 0*well_state.size();
|
||||
well_index < well_state.size();
|
||||
++well_index)
|
||||
{
|
||||
const auto& well_name = well_state.name(well_index);
|
||||
|
||||
this->loadRestartWellData(well_name, handle_ms_well, phs,
|
||||
rst_wells.at(well_name),
|
||||
wellModel_.perfData(well_index),
|
||||
well_state.well(well_index));
|
||||
}
|
||||
|
||||
for (const auto& [group, value] : grpNwrkValues.groupData) {
|
||||
this->loadRestartGroupData(group, value, grpState);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Opm
|
106
opm/simulators/wells/BlackoilWellModelRestart.hpp
Normal file
106
opm/simulators/wells/BlackoilWellModelRestart.hpp
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
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_RESTART_HEADER_INCLUDED
|
||||
#define OPM_BLACKOILWELLMODEL_RESTART_HEADER_INCLUDED
|
||||
|
||||
#include <opm/input/eclipse/Schedule/Group/GuideRateModel.hpp>
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class BlackoilWellModelGeneric;
|
||||
namespace data {
|
||||
class GroupData;
|
||||
class GroupAndNetworkValues;
|
||||
}
|
||||
class GroupState;
|
||||
class GuideRate;
|
||||
class GuideRateConfig;
|
||||
struct PerforationData;
|
||||
class PhaseUsage;
|
||||
class SingleWellState;
|
||||
class WellState;
|
||||
|
||||
/// Class for restarting the blackoil well model.
|
||||
class BlackoilWellModelRestart
|
||||
{
|
||||
public:
|
||||
//! \brief Constructor initializes reference to the well model.
|
||||
BlackoilWellModelRestart(const BlackoilWellModelGeneric& wellModel)
|
||||
: wellModel_(wellModel)
|
||||
{}
|
||||
|
||||
//! \brief Loads guide rates from restart structures.
|
||||
void loadRestartGuideRates(const int report_step,
|
||||
const GuideRateModel::Target target,
|
||||
const data::Wells& rst_wells,
|
||||
GuideRate& guide_rate) const;
|
||||
|
||||
//! \brief Loads guide rates from restart structures.
|
||||
void loadRestartGuideRates(const int report_step,
|
||||
const GuideRateConfig& config,
|
||||
const std::map<std::string, data::GroupData>& rst_groups,
|
||||
GuideRate& guide_rate) const;
|
||||
|
||||
//! \brief Loads well data from restart structures.
|
||||
void loadRestartData(const data::Wells& rst_wells,
|
||||
const data::GroupAndNetworkValues& grpNwrkValues,
|
||||
const bool handle_ms_well,
|
||||
WellState& well_state,
|
||||
GroupState& grpState) const;
|
||||
|
||||
private:
|
||||
//! \brief Loads per-connection data from restart structures.
|
||||
void loadRestartConnectionData(const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& 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;
|
||||
|
||||
//! \brief Loads per-well data from restart structures.
|
||||
void loadRestartWellData(const std::string& well_name,
|
||||
const bool handle_ms_well,
|
||||
const std::vector<data::Rates::opt>& phs,
|
||||
const data::Well& rst_well,
|
||||
const std::vector<PerforationData>& old_perf_data,
|
||||
SingleWellState& ws) const;
|
||||
|
||||
//! \brief Loads per-group data from restart structures.
|
||||
void loadRestartGroupData(const std::string& group,
|
||||
const data::GroupData& value,
|
||||
GroupState& grpState) const;
|
||||
|
||||
const BlackoilWellModelGeneric& wellModel_; //!< Reference to well model
|
||||
};
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user