move loadRestartGuideRates(Config) into BlackoilWellModelRestart

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

View File

@ -57,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;
@ -415,29 +385,6 @@ getWellEcl(const std::string& well_name) const
return *well_ecl;
}
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,
@ -521,12 +468,14 @@ initFromRestartFile(const RestartValue& restartValues,
}
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;
@ -1146,7 +1095,6 @@ checkGroupHigherConstraints(const Group& group,
changed = true;
}
}
}
return changed;

View File

@ -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 GuideRateConfig& config,
const std::map<std::string, data::GroupData>& rst_groups);
std::unordered_map<std::string, data::GroupGuideRates>
calculateAllGroupGuiderates(const int reportStepIdx) const;

View File

@ -23,6 +23,8 @@
#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>
@ -192,4 +194,27 @@ loadRestartGuideRates(const int report_step,
}
}
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));
}
}
} // namespace Opm

View File

@ -36,6 +36,7 @@ class GroupData;
}
class GroupState;
class GuideRate;
class GuideRateConfig;
struct PerforationData;
class SingleWellState;
@ -67,6 +68,12 @@ public:
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;
private:
//! \brief Loads per-connection data from restart structures.
void loadRestartConnectionData(const std::vector<data::Rates::opt>& phs,