move loadRestartGuideRates(Target) into BlackoilWellModelRestart

This commit is contained in:
Arne Morten Kvarving 2022-10-24 09:36:05 +02:00
parent ffeddfe280
commit 2e433a5bc2
4 changed files with 60 additions and 25 deletions

View File

@ -371,7 +371,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)
@ -415,22 +415,6 @@ getWellEcl(const std::string& well_name) const
return *well_ecl;
}
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,
@ -529,9 +513,10 @@ initFromRestartFile(const RestartValue& restartValues,
this->phase_usage_, handle_ms_well, this->wellState());
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_);
}
}

View File

@ -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;
@ -286,10 +286,6 @@ protected:
std::map<std::string, data::GroupData>& gvalues) const;
void assignNodeValues(std::map<std::string, data::NodeData>& nodevalues) const;
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);

View File

@ -29,6 +29,38 @@
#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::
@ -144,6 +176,20 @@ loadRestartGroupData(const std::string& group,
}
}
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));
}
}
} // namespace Opm

View File

@ -23,6 +23,7 @@
#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>
@ -34,6 +35,7 @@ namespace data {
class GroupData;
}
class GroupState;
class GuideRate;
struct PerforationData;
class SingleWellState;
@ -59,6 +61,12 @@ public:
const data::GroupData& value,
GroupState& grpState) const;
//! \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;
private:
//! \brief Loads per-connection data from restart structures.
void loadRestartConnectionData(const std::vector<data::Rates::opt>& phs,