Merge pull request #1962 from wito/schedule-keyword-cleanup

Various Code Consistency Changes in Schedule.
This commit is contained in:
Joakim Hove 2020-09-27 10:16:10 +02:00 committed by GitHub
commit 6ee4e5ce9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 859 additions and 884 deletions

View File

@ -181,25 +181,25 @@ namespace Opm
time_t getStartTime() const;
time_t posixStartTime() const;
time_t posixEndTime() const;
time_t simTime(size_t timeStep) const;
double seconds(size_t timeStep) const;
double stepLength(size_t timeStep) const;
time_t simTime(std::size_t timeStep) const;
double seconds(std::size_t timeStep) const;
double stepLength(std::size_t timeStep) const;
std::optional<int> exitStatus() const;
const TimeMap& getTimeMap() const;
size_t numWells() const;
size_t numWells(size_t timestep) const;
std::size_t numWells() const;
std::size_t numWells(std::size_t timestep) const;
bool hasWell(const std::string& wellName) const;
bool hasWell(const std::string& wellName, std::size_t timeStep) const;
std::vector<std::string> wellNames(const std::string& pattern, size_t timeStep, const std::vector<std::string>& matching_wells = {}) const;
std::vector<std::string> wellNames(const std::string& pattern, std::size_t timeStep, const std::vector<std::string>& matching_wells = {}) const;
std::vector<std::string> wellNames(const std::string& pattern) const;
std::vector<std::string> wellNames(size_t timeStep) const;
std::vector<std::string> wellNames(std::size_t timeStep) const;
std::vector<std::string> wellNames() const;
std::vector<std::string> groupNames(const std::string& pattern, size_t timeStep) const;
std::vector<std::string> groupNames(size_t timeStep) const;
std::vector<std::string> groupNames(const std::string& pattern, std::size_t timeStep) const;
std::vector<std::string> groupNames(std::size_t timeStep) const;
std::vector<std::string> groupNames(const std::string& pattern) const;
std::vector<std::string> groupNames() const;
/*
@ -211,68 +211,68 @@ namespace Opm
3. If there are less than WELLDIMS::MAXGROUPS nullptr is used.
4. The very last element corresponds to the FIELD group.
*/
std::vector<const Group*> restart_groups(size_t timeStep) const;
std::vector<const Group*> restart_groups(std::size_t timeStep) const;
void updateWell(std::shared_ptr<Well> well, size_t reportStep);
std::vector<std::string> changed_wells(size_t reportStep) const;
const Well& getWell(const std::string& wellName, size_t timeStep) const;
void updateWell(std::shared_ptr<Well> well, std::size_t reportStep);
std::vector<std::string> changed_wells(std::size_t reportStep) const;
const Well& getWell(const std::string& wellName, std::size_t timeStep) const;
const Well& getWellatEnd(const std::string& well_name) const;
std::vector<Well> getWells(size_t timeStep) const;
std::vector<Well> getWells(std::size_t timeStep) const;
std::vector<Well> getWellsatEnd() const;
void shut_well(const std::string& well_name, std::size_t report_step);
void stop_well(const std::string& well_name, std::size_t report_step);
void open_well(const std::string& well_name, std::size_t report_step);
std::vector<const Group*> getChildGroups2(const std::string& group_name, size_t timeStep) const;
std::vector<Well> getChildWells2(const std::string& group_name, size_t timeStep) const;
const OilVaporizationProperties& getOilVaporizationProperties(size_t timestep) const;
const Well::ProducerCMode& getGlobalWhistctlMmode(size_t timestep) const;
std::vector<const Group*> getChildGroups2(const std::string& group_name, std::size_t timeStep) const;
std::vector<Well> getChildWells2(const std::string& group_name, std::size_t timeStep) const;
const OilVaporizationProperties& getOilVaporizationProperties(std::size_t timestep) const;
const Well::ProducerCMode& getGlobalWhistctlMmode(std::size_t timestep) const;
const UDQActive& udqActive(size_t timeStep) const;
const WellTestConfig& wtestConfig(size_t timestep) const;
const GConSale& gConSale(size_t timestep) const;
const GConSump& gConSump(size_t timestep) const;
const WListManager& getWListManager(size_t timeStep) const;
const UDQConfig& getUDQConfig(size_t timeStep) const;
const UDQActive& udqActive(std::size_t timeStep) const;
const WellTestConfig& wtestConfig(std::size_t timestep) const;
const GConSale& gConSale(std::size_t timestep) const;
const GConSump& gConSump(std::size_t timestep) const;
const WListManager& getWListManager(std::size_t timeStep) const;
const UDQConfig& getUDQConfig(std::size_t timeStep) const;
const Action::Actions& actions(std::size_t timeStep) const;
void evalAction(const SummaryState& summary_state, size_t timeStep);
void evalAction(const SummaryState& summary_state, std::size_t timeStep);
const RPTConfig& report_config(std::size_t timeStep) const;
GTNode groupTree(std::size_t report_step) const;
GTNode groupTree(const std::string& root_node, std::size_t report_step) const;
size_t numGroups() const;
size_t numGroups(size_t timeStep) const;
std::size_t numGroups() const;
std::size_t numGroups(std::size_t timeStep) const;
bool hasGroup(const std::string& groupName) const;
bool hasGroup(const std::string& groupName, std::size_t timeStep) const;
const Group& getGroup(const std::string& groupName, size_t timeStep) const;
const Group& getGroup(const std::string& groupName, std::size_t timeStep) const;
const Tuning& getTuning(size_t timeStep) const;
const Tuning& getTuning(std::size_t timeStep) const;
const MessageLimits& getMessageLimits() const;
void invalidNamePattern (const std::string& namePattern, std::size_t report_step, const ParseContext& parseContext, ErrorGuard& errors, const DeckKeyword& keyword) const;
const GuideRateConfig& guideRateConfig(size_t timeStep) const;
const GuideRateConfig& guideRateConfig(std::size_t timeStep) const;
const RFTConfig& rftConfig() const;
const Events& getEvents() const;
const Events& getWellGroupEvents(const std::string& wellGroup) const;
bool hasWellGroupEvent(const std::string& wellGroup, uint64_t event_mask, size_t reportStep) const;
const Deck& getModifierDeck(size_t timeStep) const;
bool hasWellGroupEvent(const std::string& wellGroup, uint64_t event_mask, std::size_t reportStep) const;
const Deck& getModifierDeck(std::size_t timeStep) const;
bool hasOilVaporizationProperties() const;
const VFPProdTable& getVFPProdTable(int table_id, size_t timeStep) const;
const VFPInjTable& getVFPInjTable(int table_id, size_t timeStep) const;
std::map<int, std::shared_ptr<const VFPProdTable> > getVFPProdTables(size_t timeStep) const;
std::map<int, std::shared_ptr<const VFPInjTable> > getVFPInjTables(size_t timeStep) const;
const VFPProdTable& getVFPProdTable(int table_id, std::size_t timeStep) const;
const VFPInjTable& getVFPInjTable(int table_id, std::size_t timeStep) const;
std::map<int, std::shared_ptr<const VFPProdTable> > getVFPProdTables(std::size_t timeStep) const;
std::map<int, std::shared_ptr<const VFPInjTable> > getVFPInjTables(std::size_t timeStep) const;
/*
Will remove all completions which are connected to cell which is not
active. Will scan through all wells and all timesteps.
*/
void filterConnections(const ActiveGridCells& grid);
size_t size() const;
std::size_t size() const;
const RestartConfig& restart() const;
RestartConfig& restart();
void applyAction(size_t reportStep, const Action::ActionX& action, const Action::Result& result);
int getNupcol(size_t reportStep) const;
void applyAction(std::size_t reportStep, const Action::ActionX& action, const Action::Result& result);
int getNupcol(std::size_t reportStep) const;
const Network::ExtNetwork& network(std::size_t report_step) const;
@ -369,7 +369,7 @@ namespace Opm
const EclipseGrid& grid,
const FieldPropsManager& fp,
const UnitSystem& unit_system);
void addWell(Well well, size_t report_step);
void addWell(Well well, std::size_t report_step);
void addWell(const std::string& wellName,
const std::string& group,
int headI,
@ -381,7 +381,7 @@ namespace Opm
bool automaticShutIn,
int pvt_table,
Well::GasInflowEquation gas_inflow,
size_t timeStep,
std::size_t timeStep,
Connection::Order wellConnectionOrder,
const UnitSystem& unit_system);
@ -389,40 +389,40 @@ namespace Opm
void updateNetwork(std::shared_ptr<Network::ExtNetwork> network, std::size_t report_step);
GTNode groupTree(const std::string& root_node, std::size_t report_step, std::size_t level, const std::optional<std::string>& parent_name) const;
void updateGroup(std::shared_ptr<Group> group, size_t reportStep);
void updateGroup(std::shared_ptr<Group> group, std::size_t reportStep);
bool checkGroups(const ParseContext& parseContext, ErrorGuard& errors);
void updateUDQActive( std::size_t timeStep, std::shared_ptr<UDQActive> udq );
bool updateWellStatus( const std::string& well, size_t reportStep , Well::Status status, bool update_connections);
void addWellToGroup( const std::string& group_name, const std::string& well_name , size_t timeStep);
bool updateWellStatus( const std::string& well, std::size_t reportStep , Well::Status status, bool update_connections);
void addWellToGroup( const std::string& group_name, const std::string& well_name , std::size_t timeStep);
void iterateScheduleSection(std::shared_ptr<const Python> python, const std::string& input_path, const ParseContext& parseContext , ErrorGuard& errors, const SCHEDULESection& , const EclipseGrid& grid,
const FieldPropsManager& fp);
void addACTIONX(const Action::ActionX& action, std::size_t currentStep);
void addGroupToGroup( const std::string& parent_group, const std::string& child_group, size_t timeStep);
void addGroupToGroup( const std::string& parent_group, const Group& child_group, size_t timeStep);
void addGroup(const std::string& groupName , size_t timeStep, const UnitSystem& unit_system);
void addWell(const std::string& wellName, const DeckRecord& record, size_t timeStep, Connection::Order connection_order, const UnitSystem& unit_system);
void addGroupToGroup( const std::string& parent_group, const std::string& child_group, std::size_t timeStep);
void addGroupToGroup( const std::string& parent_group, const Group& child_group, std::size_t timeStep);
void addGroup(const std::string& groupName , std::size_t timeStep, const UnitSystem& unit_system);
void addWell(const std::string& wellName, const DeckRecord& record, std::size_t timeStep, Connection::Order connection_order, const UnitSystem& unit_system);
void checkUnhandledKeywords( const SCHEDULESection& ) const;
void checkIfAllConnectionsIsShut(size_t currentStep);
void checkIfAllConnectionsIsShut(std::size_t currentStep);
void updateUDQ(const DeckKeyword& keyword, std::size_t current_step);
void handleKeyword(std::shared_ptr<const Python> python,
const std::string& input_path,
size_t currentStep,
std::size_t currentStep,
const SCHEDULESection& section,
size_t keywordIdx,
std::size_t keywordIdx,
const DeckKeyword& keyword,
const ParseContext& parseContext, ErrorGuard& errors,
const EclipseGrid& grid,
const FieldPropsManager& fp,
std::vector<std::pair<const DeckKeyword*, size_t > >& rftProperties);
void addWellGroupEvent(const std::string& wellGroup, ScheduleEvents::Events event, size_t reportStep);
std::vector<std::pair<const DeckKeyword*, std::size_t > >& rftProperties);
void addWellGroupEvent(const std::string& wellGroup, ScheduleEvents::Events event, std::size_t reportStep);
template<template<class, class> class Map, class Type, class Key>
std::pair<std::vector<Type>, std::vector<std::pair<Key, std::vector<size_t>>>>
std::pair<std::vector<Type>, std::vector<std::pair<Key, std::vector<std::size_t>>>>
splitDynMap(const Map<Key, Opm::DynamicState<Type>>& map)
{
// we have to pack the unique ptrs separately, and use an index map
// to allow reconstructing the appropriate structures.
std::vector<std::pair<Key, std::vector<size_t>>> asMap;
std::vector<std::pair<Key, std::vector<std::size_t>>> asMap;
std::vector<Type> unique;
for (const auto& it : map) {
auto indices = it.second.split(unique);
@ -434,7 +434,7 @@ namespace Opm
template<template<class, class> class Map, class Type, class Key>
void reconstructDynMap(const std::vector<Type>& unique,
const std::vector<std::pair<Key, std::vector<size_t>>>& asMap,
const std::vector<std::pair<Key, std::vector<std::size_t>>>& asMap,
Map<Key, Opm::DynamicState<Type>>& result)
{
for (const auto& it : asMap) {
@ -458,15 +458,26 @@ namespace Opm
};
/**
* Handles a "normal" keyword. A normal keyword is one that can be handled by a function with the standard set of arguments (the ones that are passed to this function.
* Handles a "normal" keyword. A normal keyword is one that can be handled by a function with the standard set of arguments (the ones that are passed to this function).
*
* \return `true` if the keyword was handled
* Normal keywords are found in the file KeywordHandlers.cpp; to add a new keyword handler to the file, add its signature in the list below,
* add the implementation to KeywordHandlers.cpp, and add a pointer to the handler in the dispatch registry in the implementation of this method, found at the bottom of
* KeywordHandlers.cpp.
*
* For the benefit of automatic cross-checking of the lists, all of these are in alphabetical order.
*
* @param handlerContext context object containing the environment in which the handler was invoked
* @param parseContext context object containing the parsing environment
* @param errors the error handling object for the current parsing process
*
* @return `true` if the keyword was handled
*/
bool handleNormalKeyword(const HandlerContext&, const ParseContext&, ErrorGuard&);
bool handleNormalKeyword(const HandlerContext& handlerContext, const ParseContext& parseContext, ErrorGuard& errors);
/// Keyword Handlers
// Keyword Handlers
void handlePYACTION (std::shared_ptr<const Python> python, const std::string& input_path, const DeckKeyword&, std::size_t currentStep);
// Normal keyword handlers -- in KeywordHandlers.cpp
void handleBRANPROP (const HandlerContext&, const ParseContext&, ErrorGuard&);
void handleCOMPDAT (const HandlerContext&, const ParseContext&, ErrorGuard&);
void handleCOMPLUMP (const HandlerContext&, const ParseContext&, ErrorGuard&);

View File

@ -36,12 +36,7 @@
#include <opm/parser/eclipse/Deck/DeckSection.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/C.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/G.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/L.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/N.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/P.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/V.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/W.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
@ -49,7 +44,6 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicVector.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp>
@ -137,7 +131,7 @@ namespace {
must therefor also scan the part of the deck prior to the
SCHEDULE section to initialize valid MessageLimits object.
*/
for (size_t keywordIdx = 0; keywordIdx < deck.size(); ++keywordIdx) {
for (std::size_t keywordIdx = 0; keywordIdx < deck.size(); ++keywordIdx) {
const auto& keyword = deck.getKeyword(keywordIdx);
if (keyword.name() == "SCHEDULE")
break;
@ -174,7 +168,7 @@ namespace {
{}
Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& parse_context, ErrorGuard& errors, std::shared_ptr<const Python> python, const RestartIO::RstState * rst) :
Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& parse_context, ErrorGuard& errors, std::shared_ptr<const Python> python, const RestartIO::RstState * rst) :
Schedule(deck,
es.getInputGrid(),
es.fieldProps(),
@ -186,7 +180,6 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
{}
template <typename T>
Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& parse_context, T&& errors, std::shared_ptr<const Python> python, const RestartIO::RstState * rst) :
Schedule(deck,
@ -267,15 +260,15 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
void Schedule::handleKeyword(std::shared_ptr<const Python> python,
const std::string& input_path,
size_t currentStep,
std::size_t currentStep,
const SCHEDULESection& section,
size_t keywordIdx,
std::size_t keywordIdx,
const DeckKeyword& keyword,
const ParseContext& parseContext,
ErrorGuard& errors,
const EclipseGrid& grid,
const FieldPropsManager& fp,
std::vector<std::pair<const DeckKeyword*, size_t > >& rftProperties) {
std::vector<std::pair<const DeckKeyword*, std::size_t > >& rftProperties) {
const HandlerContext handlerContext { section, keyword, keywordIdx, currentStep, grid, fp };
@ -295,8 +288,8 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
void Schedule::iterateScheduleSection(std::shared_ptr<const Opm::Python> python, const std::string& input_path, const ParseContext& parseContext , ErrorGuard& errors, const SCHEDULESection& section , const EclipseGrid& grid,
const FieldPropsManager& fp) {
std::vector<std::pair< const DeckKeyword* , size_t> > rftProperties;
size_t keywordIdx = 0;
std::vector<std::pair< const DeckKeyword* , std::size_t> > rftProperties;
std::size_t keywordIdx = 0;
/*
The keywords in the skiprest_whitelist set are loaded from the
SCHEDULE section even though the SKIPREST keyword is in action. The
@ -305,7 +298,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
*/
std::unordered_set<std::string> skiprest_whitelist = {"VFPPROD", "VFPINJ", "RPTSCHED", "RPTRST", "TUNING", "MESSAGES"};
size_t currentStep;
std::size_t currentStep;
if (this->m_timeMap.skiprest())
currentStep = 0;
else
@ -324,9 +317,9 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
if (action_keyword.name() == "ENDACTIO")
break;
if (Action::ActionX::valid_keyword(action_keyword.name()))
if (Action::ActionX::valid_keyword(action_keyword.name())) {
action.addKeyword(action_keyword);
else {
} else {
std::string msg = "The keyword " + action_keyword.name() + " is not supported in a ACTIONX block.";
parseContext.handleError( ParseContext::ACTIONX_ILLEGAL_KEYWORD, msg, errors);
}
@ -360,7 +353,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
for (auto rftPair = rftProperties.begin(); rftPair != rftProperties.end(); ++rftPair) {
const DeckKeyword& keyword = *rftPair->first;
size_t timeStep = rftPair->second;
std::size_t timeStep = rftPair->second;
if (keyword.name() == "WRFT")
applyWRFT(keyword, timeStep);
@ -388,10 +381,9 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return;
}
using PY = ParserKeywords::PYACTION;
const auto& name = keyword.getRecord(0).getItem<PY::NAME>().get<std::string>(0);
const auto& run_count = Action::PyAction::from_string( keyword.getRecord(0).getItem<PY::RUN_COUNT>().get<std::string>(0) );
const auto& module_arg = keyword.getRecord(1).getItem<PY::FILENAME>().get<std::string>(0);
const auto& name = keyword.getRecord(0).getItem<ParserKeywords::PYACTION::NAME>().get<std::string>(0);
const auto& run_count = Action::PyAction::from_string( keyword.getRecord(0).getItem<ParserKeywords::PYACTION::RUN_COUNT>().get<std::string>(0) );
const auto& module_arg = keyword.getRecord(1).getItem<ParserKeywords::PYACTION::FILENAME>().get<std::string>(0);
std::string module;
if (input_path.empty())
module = module_arg;
@ -405,8 +397,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
}
void Schedule::applyEXIT(const DeckKeyword& keyword, std::size_t report_step) {
using ex = ParserKeywords::EXIT;
int status = keyword.getRecord(0).getItem<ex::STATUS_CODE>().get<int>(0);
int status = keyword.getRecord(0).getItem<ParserKeywords::EXIT::STATUS_CODE>().get<int>(0);
OpmLog::info("Simulation exit with status: " + std::to_string(status) + " requested as part of ACTIONX at report_step: " + std::to_string(report_step));
this->exit_status = status;
}
@ -423,7 +414,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
this->updateWellStatus(well_name, report_step, Well::Status::STOP, true);
}
void Schedule::updateWell(std::shared_ptr<Well> well, size_t reportStep) {
void Schedule::updateWell(std::shared_ptr<Well> well, std::size_t reportStep) {
auto& dynamic_state = this->wells_static.at(well->name());
dynamic_state.update(reportStep, std::move(well));
}
@ -433,7 +424,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
Function is quite dangerous - because if this is called while holding a
Well pointer that will go stale and needs to be refreshed.
*/
bool Schedule::updateWellStatus( const std::string& well_name, size_t reportStep , Well::Status status, bool update_connections) {
bool Schedule::updateWellStatus( const std::string& well_name, std::size_t reportStep , Well::Status status, bool update_connections) {
bool update = false;
auto& dynamic_state = this->wells_static.at(well_name);
auto well2 = std::make_shared<Well>(*dynamic_state[reportStep]);
@ -481,7 +472,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
constexpr auto open = Well::Status::OPEN;
bool action_mode = !matching_wells.empty();
for( const auto& record : keyword ) {
for (const auto& record : keyword) {
const auto& wellNamePattern = record.getItem( "WELL" ).getTrimmedString(0);
const auto& status_str = record.getItem( "STATUS" ).getTrimmedString( 0 );
const auto well_names = this->wellNames(wellNamePattern, currentStep, matching_wells);
@ -491,25 +482,23 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
/* if all records are defaulted or just the status is set, only
* well status is updated
*/
if( conn_defaulted( record ) ) {
if (conn_defaulted( record )) {
const auto well_status = Well::StatusFromString( status_str );
for (const auto& wname : well_names) {
{
const auto& well = this->getWell(wname, currentStep);
if( well_status == open && !well.canOpen() ) {
auto days = m_timeMap.getTimePassedUntil( currentStep ) / (60 * 60 * 24);
std::string msg = "Well " + wname
+ " where crossflow is banned has zero total rate."
+ " This well is prevented from opening at "
+ std::to_string( days ) + " days";
OpmLog::note(msg);
} else {
this->updateWellStatus( wname, currentStep, well_status, false );
if (well_status == open)
this->rft_config.addWellOpen(wname, currentStep);
const auto& well = this->getWell(wname, currentStep);
if (well_status == open && !well.canOpen()) {
auto days = m_timeMap.getTimePassedUntil( currentStep ) / (60 * 60 * 24);
std::string msg = "Well " + wname
+ " where crossflow is banned has zero total rate."
+ " This well is prevented from opening at "
+ std::to_string( days ) + " days";
OpmLog::note(msg);
} else {
this->updateWellStatus( wname, currentStep, well_status, false );
if (well_status == open)
this->rft_config.addWellOpen(wname, currentStep);
OpmLog::info(Well::Status2String(well_status) + " well: " + wname + " at report step: " + std::to_string(currentStep));
}
OpmLog::info(Well::Status2String(well_status) + " well: " + wname + " at report step: " + std::to_string(currentStep));
}
}
@ -518,16 +507,15 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
for (const auto& wname : well_names) {
const auto comp_status = Connection::StateFromString( status_str );
{
auto& dynamic_state = this->wells_static.at(wname);
auto well_ptr = std::make_shared<Well>( *dynamic_state[currentStep] );
if (well_ptr->handleWELOPEN(record, comp_status, action_mode)) {
// The updateWell call breaks test at line 825 and 831 in ScheduleTests
this->updateWell(well_ptr, currentStep);
const auto well_status = Well::StatusFromString( status_str );
OpmLog::info(Well::Status2String(well_status) + " well: " + wname + " at report step: " + std::to_string(currentStep));
}
auto& dynamic_state = this->wells_static.at(wname);
auto well_ptr = std::make_shared<Well>( *dynamic_state[currentStep] );
if (well_ptr->handleWELOPEN(record, comp_status, action_mode)) {
// The updateWell call breaks test at line 825 and 831 in ScheduleTests
this->updateWell(well_ptr, currentStep);
const auto well_status = Well::StatusFromString( status_str );
OpmLog::info(Well::Status2String(well_status) + " well: " + wname + " at report step: " + std::to_string(currentStep));
}
m_events.addEvent( ScheduleEvents::COMPLETION_CHANGE, currentStep );
}
}
@ -566,11 +554,11 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
* any well is subsequently opened
*/
for( const auto& record : keyword ) {
for (const auto& record : keyword) {
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
const auto well_names = wellNames(wellNamePattern, currentStep);
for(const auto& well_name : well_names)
for (const auto& well_name : well_names)
this->rft_config.updateRFT(well_name, currentStep, RFTConfig::RFT::YES);
}
@ -579,13 +567,13 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
}
void Schedule::applyWRFTPLT(const DeckKeyword& keyword, std::size_t currentStep) {
for( const auto& record : keyword ) {
for (const auto& record : keyword) {
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
RFTConfig::RFT RFTKey = RFTConfig::RFTFromString(record.getItem("OUTPUT_RFT").getTrimmedString(0));
RFTConfig::PLT PLTKey = RFTConfig::PLTFromString(record.getItem("OUTPUT_PLT").getTrimmedString(0));
const auto well_names = wellNames(wellNamePattern, currentStep);
for(const auto& well_name : well_names) {
for (const auto& well_name : well_names) {
this->rft_config.updateRFT(well_name, currentStep, RFTKey);
this->rft_config.updatePLT(well_name, currentStep, PLTKey);
}
@ -626,18 +614,16 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return this->groupTree(root_node, report_step, 0, {});
}
GTNode Schedule::groupTree(std::size_t report_step) const {
return this->groupTree("FIELD", report_step);
}
void Schedule::addWell(const std::string& wellName,
const DeckRecord& record,
size_t timeStep,
std::size_t timeStep,
Connection::Order wellConnectionOrder,
const UnitSystem& unit_system)
{
using WS = ParserKeywords::WELSPECS;
// We change from eclipse's 1 - n, to a 0 - n-1 solution
int headI = record.getItem("HEAD_I").get< int >(0) - 1;
int headJ = record.getItem("HEAD_J").get< int >(0) - 1;
@ -651,8 +637,9 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
preferredPhase = Phase::OIL;
OpmLog::warning("LIQ_PREFERRED_PHASE",
"LIQ preferred phase not supported for well " + wellName + ", using OIL instead");
} else
} else {
preferredPhase = get_phase(phaseStr);
}
}
const auto& refDepthItem = record.getItem("REF_DEPTH");
double refDepth = refDepthItem.hasValue( 0 )
@ -673,8 +660,8 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
}
const std::string& group = record.getItem<ParserKeywords::WELSPECS::GROUP>().getTrimmedString(0);
auto pvt_table = record.getItem<WS::P_TABLE>().get<int>(0);
auto gas_inflow = Well::GasInflowEquationFromString( record.getItem<WS::INFLOW_EQ>().get<std::string>(0) );
auto pvt_table = record.getItem<ParserKeywords::WELSPECS::P_TABLE>().get<int>(0);
auto gas_inflow = Well::GasInflowEquationFromString( record.getItem<ParserKeywords::WELSPECS::INFLOW_EQ>().get<std::string>(0) );
this->addWell(wellName,
group,
@ -692,8 +679,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
unit_system);
}
void Schedule::addWell(Well well, size_t report_step) {
void Schedule::addWell(Well well, std::size_t report_step) {
const std::string wname = well.name();
m_events.addEvent( ScheduleEvents::NEW_WELL , report_step );
@ -706,7 +692,6 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
dynamic_well_state.update(report_step, std::make_shared<Well>(std::move(well)));
}
void Schedule::addWell(const std::string& wellName,
const std::string& group,
int headI,
@ -718,7 +703,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
bool automaticShutIn,
int pvt_table,
Well::GasInflowEquation gas_inflow,
size_t timeStep,
std::size_t timeStep,
Connection::Order wellConnectionOrder,
const UnitSystem& unit_system) {
@ -743,11 +728,11 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
}
size_t Schedule::numWells() const {
std::size_t Schedule::numWells() const {
return wells_static.size();
}
size_t Schedule::numWells(size_t timestep) const {
std::size_t Schedule::numWells(std::size_t timestep) const {
auto well_names = this->wellNames(timestep);
return well_names.size();
}
@ -764,44 +749,45 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return well.hasBeenDefined(timeStep);
}
std::vector< const Group* > Schedule::getChildGroups2(const std::string& group_name, size_t timeStep) const {
std::vector< const Group* > Schedule::getChildGroups2(const std::string& group_name, std::size_t timeStep) const {
if (!hasGroup(group_name))
throw std::invalid_argument("No such group: '" + group_name + "'");
{
const auto& group = getGroup( group_name, timeStep );
std::vector<const Group*> child_groups;
if (group.defined( timeStep )) {
for (const auto& child_name : group.groups())
child_groups.push_back( std::addressof(this->getGroup(child_name, timeStep)));
const auto& group = getGroup(group_name, timeStep);
std::vector<const Group*> child_groups;
if (group.defined( timeStep )) {
for (const auto& child_name : group.groups()) {
child_groups.push_back( std::addressof(this->getGroup(child_name, timeStep)));
}
return child_groups;
}
return child_groups;
}
std::vector< Well > Schedule::getChildWells2(const std::string& group_name, size_t timeStep) const {
std::vector< Well > Schedule::getChildWells2(const std::string& group_name, std::size_t timeStep) const {
if (!hasGroup(group_name))
throw std::invalid_argument("No such group: '" + group_name + "'");
{
const auto& dynamic_state = this->groups.at(group_name);
const auto& group_ptr = dynamic_state.get(timeStep);
if (group_ptr) {
std::vector<Well> wells;
if (group_ptr->groups().size()) {
for (const auto& child_name : group_ptr->groups()) {
const auto& child_wells = getChildWells2( child_name, timeStep);
wells.insert( wells.end() , child_wells.begin() , child_wells.end());
}
} else {
for (const auto& well_name : group_ptr->wells( ))
wells.push_back( this->getWell( well_name, timeStep ));
const auto& dynamic_state = this->groups.at(group_name);
const auto& group_ptr = dynamic_state.get(timeStep);
if (group_ptr) {
std::vector<Well> wells;
if (group_ptr->groups().size()) {
for (const auto& child_name : group_ptr->groups()) {
const auto& child_wells = getChildWells2(child_name, timeStep);
wells.insert(wells.end(), child_wells.begin(), child_wells.end());
}
} else {
for (const auto& well_name : group_ptr->wells()) {
wells.push_back( this->getWell(well_name, timeStep));
}
}
return wells;
} else
return {};
return wells;
} else {
return {};
}
}
@ -821,10 +807,12 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
if (prev) {
if (!well_ptr->cmp_structure( *prev ))
wells.push_back( well_ptr->name() );
} else
} else {
wells.push_back( well_ptr->name() );
} else
}
} else {
wells.push_back( well_ptr->name() );
}
}
}
@ -832,7 +820,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
}
std::vector<Well> Schedule::getWells(size_t timeStep) const {
std::vector<Well> Schedule::getWells(std::size_t timeStep) const {
std::vector<Well> wells;
if (timeStep >= this->m_timeMap.size())
throw std::invalid_argument("timeStep argument beyond the length of the simulation");
@ -849,12 +837,11 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return this->getWells(this->m_timeMap.size() - 1);
}
const Well& Schedule::getWellatEnd(const std::string& well_name) const {
return this->getWell(well_name, this->m_timeMap.size() - 1);
}
const Well& Schedule::getWell(const std::string& wellName, size_t timeStep) const {
const Well& Schedule::getWell(const std::string& wellName, std::size_t timeStep) const {
if (this->wells_static.count(wellName) == 0)
throw std::invalid_argument("No such well: " + wellName);
@ -866,7 +853,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return *well_ptr;
}
const Group& Schedule::getGroup(const std::string& groupName, size_t timeStep) const {
const Group& Schedule::getGroup(const std::string& groupName, std::size_t timeStep) const {
if (this->groups.count(groupName) == 0)
throw std::invalid_argument("No such group: '" + groupName + "'");
@ -878,7 +865,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return *group_ptr;
}
void Schedule::updateGroup(std::shared_ptr<Group> group, size_t reportStep) {
void Schedule::updateGroup(std::shared_ptr<Group> group, std::size_t reportStep) {
auto& dynamic_state = this->groups.at(group->name());
dynamic_state.update(reportStep, std::move(group));
}
@ -898,7 +885,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
*/
std::vector<std::string> Schedule::wellNames(const std::string& pattern, size_t timeStep, const std::vector<std::string>& matching_wells) const {
std::vector<std::string> Schedule::wellNames(const std::string& pattern, std::size_t timeStep, const std::vector<std::string>& matching_wells) const {
if (pattern.size() == 0)
return {};
@ -959,7 +946,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return names;
}
std::vector<std::string> Schedule::groupNames(const std::string& pattern, size_t timeStep) const {
std::vector<std::string> Schedule::groupNames(const std::string& pattern, std::size_t timeStep) const {
if (pattern.size() == 0)
return {};
@ -988,7 +975,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return {};
}
std::vector<std::string> Schedule::groupNames(size_t timeStep) const {
std::vector<std::string> Schedule::groupNames(std::size_t timeStep) const {
std::vector<std::string> names;
for (const auto& group_pair : this->groups) {
const auto& dynamic_state = group_pair.second;
@ -1045,8 +1032,8 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
}
void Schedule::addGroup(const std::string& groupName, size_t timeStep, const UnitSystem& unit_system) {
const size_t gseqIndex = this->groups.size();
void Schedule::addGroup(const std::string& groupName, std::size_t timeStep, const UnitSystem& unit_system) {
const std::size_t gseqIndex = this->groups.size();
groups.insert( std::make_pair( groupName, DynamicState<std::shared_ptr<Group>>(this->m_timeMap, nullptr)));
auto group_ptr = std::make_shared<Group>(groupName, gseqIndex, timeStep, this->getUDQConfig(timeStep).params().undefinedValue(), unit_system);
@ -1063,11 +1050,11 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
this->addGroupToGroup("FIELD", *group_ptr, timeStep);
}
size_t Schedule::numGroups() const {
std::size_t Schedule::numGroups() const {
return groups.size();
}
size_t Schedule::numGroups(size_t timeStep) const {
std::size_t Schedule::numGroups(std::size_t timeStep) const {
const auto group_names = this->groupNames(timeStep);
return group_names.size();
}
@ -1086,7 +1073,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
&& grpMap->second.at(timeStep);
}
void Schedule::addGroupToGroup( const std::string& parent_group, const Group& child_group, size_t timeStep) {
void Schedule::addGroupToGroup( const std::string& parent_group, const Group& child_group, std::size_t timeStep) {
// Add to new parent
auto& dynamic_state = this->groups.at(parent_group);
auto parent_ptr = std::make_shared<Group>( *dynamic_state[timeStep] );
@ -1106,11 +1093,11 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
}
}
void Schedule::addGroupToGroup( const std::string& parent_group, const std::string& child_group, size_t timeStep) {
void Schedule::addGroupToGroup( const std::string& parent_group, const std::string& child_group, std::size_t timeStep) {
this->addGroupToGroup(parent_group, this->getGroup(child_group, timeStep), timeStep);
}
void Schedule::addWellToGroup( const std::string& group_name, const std::string& well_name , size_t timeStep) {
void Schedule::addWellToGroup( const std::string& group_name, const std::string& well_name , std::size_t timeStep) {
const auto& well = this->getWell(well_name, timeStep);
const auto old_gname = well.groupName();
if (old_gname != group_name) {
@ -1130,15 +1117,14 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
group_ptr->addWell(well_name);
this->updateGroup(group_ptr, timeStep);
this->m_events.addEvent( ScheduleEvents::GROUP_CHANGE , timeStep);
}
}
const Tuning& Schedule::getTuning(size_t timeStep) const {
const Tuning& Schedule::getTuning(std::size_t timeStep) const {
return this->m_tuning.get( timeStep );
}
const Deck& Schedule::getModifierDeck(size_t timeStep) const {
const Deck& Schedule::getModifierDeck(std::size_t timeStep) const {
return m_modifierDeck.iget( timeStep );
}
@ -1154,12 +1140,12 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
throw std::invalid_argument("No such well og group " + wellGroup);
}
void Schedule::addWellGroupEvent(const std::string& wellGroup, ScheduleEvents::Events event, size_t reportStep) {
void Schedule::addWellGroupEvent(const std::string& wellGroup, ScheduleEvents::Events event, std::size_t reportStep) {
auto& events = this->wellgroup_events.at(wellGroup);
events.addEvent(event, reportStep);
}
bool Schedule::hasWellGroupEvent(const std::string& wellGroup, uint64_t event_mask, size_t reportStep) const {
bool Schedule::hasWellGroupEvent(const std::string& wellGroup, uint64_t event_mask, std::size_t reportStep) const {
const auto& events = this->getWellGroupEvents(wellGroup);
return events.hasEvent(event_mask, reportStep);
}
@ -1168,23 +1154,23 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return this->m_events;
}
const OilVaporizationProperties& Schedule::getOilVaporizationProperties(size_t timestep) const {
const OilVaporizationProperties& Schedule::getOilVaporizationProperties(std::size_t timestep) const {
return m_oilvaporizationproperties.get(timestep);
}
const Well::ProducerCMode& Schedule::getGlobalWhistctlMmode(size_t timestep) const {
const Well::ProducerCMode& Schedule::getGlobalWhistctlMmode(std::size_t timestep) const {
return global_whistctl_mode.get(timestep);
}
bool Schedule::hasOilVaporizationProperties() const {
for( size_t i = 0; i < this->m_timeMap.size(); ++i )
if( m_oilvaporizationproperties.at( i ).defined() ) return true;
for (std::size_t i = 0; i < this->m_timeMap.size(); ++i)
if (m_oilvaporizationproperties.at( i ).defined()) return true;
return false;
}
void Schedule::checkIfAllConnectionsIsShut(size_t timeStep) {
void Schedule::checkIfAllConnectionsIsShut(std::size_t timeStep) {
const auto& well_names = this->wellNames(timeStep);
for (const auto& wname : well_names) {
const auto& well = this->getWell(wname, timeStep);
@ -1226,7 +1212,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
}
}
const VFPProdTable& Schedule::getVFPProdTable(int table_id, size_t timeStep) const {
const VFPProdTable& Schedule::getVFPProdTable(int table_id, std::size_t timeStep) const {
const auto pair = vfpprod_tables.find(table_id);
if (pair == vfpprod_tables.end())
throw std::invalid_argument("No such table id: " + std::to_string(table_id));
@ -1238,7 +1224,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return *table_ptr;
}
const VFPInjTable& Schedule::getVFPInjTable(int table_id, size_t timeStep) const {
const VFPInjTable& Schedule::getVFPInjTable(int table_id, std::size_t timeStep) const {
const auto pair = vfpinj_tables.find(table_id);
if (pair == vfpinj_tables.end())
throw std::invalid_argument("No such table id: " + std::to_string(table_id));
@ -1250,7 +1236,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return *table_ptr;
}
std::map<int, std::shared_ptr<const VFPInjTable> > Schedule::getVFPInjTables(size_t timeStep) const {
std::map<int, std::shared_ptr<const VFPInjTable> > Schedule::getVFPInjTables(std::size_t timeStep) const {
std::map<int, std::shared_ptr<const VFPInjTable> > tables;
for (const auto& pair : this->vfpinj_tables) {
if (pair.second.get(timeStep)) {
@ -1260,7 +1246,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return tables;
}
std::map<int, std::shared_ptr<const VFPProdTable> > Schedule::getVFPProdTables(size_t timeStep) const {
std::map<int, std::shared_ptr<const VFPProdTable> > Schedule::getVFPProdTables(std::size_t timeStep) const {
std::map<int, std::shared_ptr<const VFPProdTable> > tables;
for (const auto& pair : this->vfpprod_tables) {
if (pair.second.get(timeStep)) {
@ -1270,45 +1256,45 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return tables;
}
const UDQActive& Schedule::udqActive(size_t timeStep) const {
const UDQActive& Schedule::udqActive(std::size_t timeStep) const {
return *this->udq_active[timeStep];
}
void Schedule::updateUDQActive( size_t timeStep, std::shared_ptr<UDQActive> udq ) {
void Schedule::updateUDQActive( std::size_t timeStep, std::shared_ptr<UDQActive> udq ) {
this->udq_active.update(timeStep, udq);
}
const WellTestConfig& Schedule::wtestConfig(size_t timeStep) const {
const WellTestConfig& Schedule::wtestConfig(std::size_t timeStep) const {
const auto& ptr = this->wtest_config.get(timeStep);
return *ptr;
}
const GConSale& Schedule::gConSale(size_t timeStep) const {
const GConSale& Schedule::gConSale(std::size_t timeStep) const {
const auto& ptr = this->gconsale.get(timeStep);
return *ptr;
}
const GConSump& Schedule::gConSump(size_t timeStep) const {
const GConSump& Schedule::gConSump(std::size_t timeStep) const {
const auto& ptr = this->gconsump.get(timeStep);
return *ptr;
}
const WListManager& Schedule::getWListManager(size_t timeStep) const {
const WListManager& Schedule::getWListManager(std::size_t timeStep) const {
const auto& ptr = this->wlist_manager.get(timeStep);
return *ptr;
}
const UDQConfig& Schedule::getUDQConfig(size_t timeStep) const {
const UDQConfig& Schedule::getUDQConfig(std::size_t timeStep) const {
const auto& ptr = this->udq_config.get(timeStep);
return *ptr;
}
const GuideRateConfig& Schedule::guideRateConfig(size_t timeStep) const {
const GuideRateConfig& Schedule::guideRateConfig(std::size_t timeStep) const {
const auto& ptr = this->guide_rate_config.get(timeStep);
return *ptr;
}
const RPTConfig& Schedule::report_config(size_t timeStep) const {
const RPTConfig& Schedule::report_config(std::size_t timeStep) const {
const auto& ptr = this->rpt_config.get(timeStep);
return *ptr;
}
@ -1317,20 +1303,20 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return this->exit_status;
}
size_t Schedule::size() const {
std::size_t Schedule::size() const {
return this->m_timeMap.size();
}
double Schedule::seconds(size_t timeStep) const {
double Schedule::seconds(std::size_t timeStep) const {
return this->m_timeMap.seconds(timeStep);
}
time_t Schedule::simTime(size_t timeStep) const {
time_t Schedule::simTime(std::size_t timeStep) const {
return this->m_timeMap[timeStep];
}
double Schedule::stepLength(size_t timeStep) const {
double Schedule::stepLength(std::size_t timeStep) const {
return this->m_timeMap.getTimeStepLength(timeStep);
}
@ -1340,7 +1326,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return *ptr;
}
void Schedule::applyAction(size_t reportStep, const Action::ActionX& action, const Action::Result& result) {
void Schedule::applyAction(std::size_t reportStep, const Action::ActionX& action, const Action::Result& result) {
ParseContext parseContext;
ErrorGuard errors;
@ -1363,16 +1349,15 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
return this->restart_config;
}
const RestartConfig& Schedule::restart() const {
return this->restart_config;
}
int Schedule::getNupcol(size_t reportStep) const {
int Schedule::getNupcol(std::size_t reportStep) const {
return this->m_nupcol.get(reportStep);
}
bool Schedule::operator==(const Schedule& data) const {
bool Schedule::operator==(const Schedule& data) const {
auto&& comparePtr = [](const auto& t1, const auto& t2) {
if ((t1 && !t2) || (!t1 && t2))
return false;
@ -1434,82 +1419,80 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
}
namespace {
// Duplicated from Well.cpp
Connection::Order order_from_int(int int_value) {
switch(int_value) {
case 0:
return Connection::Order::TRACK;
case 1:
return Connection::Order::DEPTH;
case 2:
return Connection::Order::INPUT;
default:
throw std::invalid_argument("Invalid integer value: " + std::to_string(int_value) + " encountered when determining connection ordering");
// Duplicated from Well.cpp
Connection::Order order_from_int(int int_value) {
switch(int_value) {
case 0:
return Connection::Order::TRACK;
case 1:
return Connection::Order::DEPTH;
case 2:
return Connection::Order::INPUT;
default:
throw std::invalid_argument("Invalid integer value: " + std::to_string(int_value) + " encountered when determining connection ordering");
}
}
}
}
void Schedule::load_rst(const RestartIO::RstState& rst_state, const EclipseGrid& grid, const FieldPropsManager& fp, const UnitSystem& unit_system)
{
double udq_undefined = 0;
const auto report_step = rst_state.header.report_step - 1;
void Schedule::load_rst(const RestartIO::RstState& rst_state, const EclipseGrid& grid, const FieldPropsManager& fp, const UnitSystem& unit_system)
{
double udq_undefined = 0;
const auto report_step = rst_state.header.report_step - 1;
for (const auto& rst_group : rst_state.groups)
this->addGroup(rst_group.name, report_step, unit_system);
for (const auto& rst_group : rst_state.groups)
this->addGroup(rst_group.name, report_step, unit_system);
for (const auto& rst_well : rst_state.wells) {
Opm::Well well(rst_well, report_step, unit_system, udq_undefined);
std::vector<Opm::Connection> rst_connections;
for (const auto& rst_well : rst_state.wells) {
Opm::Well well(rst_well, report_step, unit_system, udq_undefined);
std::vector<Opm::Connection> rst_connections;
for (const auto& rst_conn : rst_well.connections)
rst_connections.emplace_back(rst_conn, grid, fp);
for (const auto& rst_conn : rst_well.connections)
rst_connections.emplace_back(rst_conn, grid, fp);
if (rst_well.segments.empty()) {
Opm::WellConnections connections(order_from_int(rst_well.completion_ordering),
rst_well.ij[0],
rst_well.ij[1],
rst_connections);
well.updateConnections( std::make_shared<WellConnections>( std::move(connections) ), grid, fp.get_int("PVTNUM"));
} else {
std::unordered_map<int, Opm::Segment> rst_segments;
for (const auto& rst_segment : rst_well.segments) {
Opm::Segment segment(rst_segment);
rst_segments.insert(std::make_pair(rst_segment.segment, std::move(segment)));
if (rst_well.segments.empty()) {
Opm::WellConnections connections(order_from_int(rst_well.completion_ordering),
rst_well.ij[0],
rst_well.ij[1],
rst_connections);
well.updateConnections( std::make_shared<WellConnections>( std::move(connections) ), grid, fp.get_int("PVTNUM"));
} else {
std::unordered_map<int, Opm::Segment> rst_segments;
for (const auto& rst_segment : rst_well.segments) {
Opm::Segment segment(rst_segment);
rst_segments.insert(std::make_pair(rst_segment.segment, std::move(segment)));
}
auto [connections, segments] = Compsegs::rstUpdate(rst_well, rst_connections, rst_segments);
well.updateConnections( std::make_shared<WellConnections>(std::move(connections)), grid, fp.get_int("PVTNUM"));
well.updateSegments( std::make_shared<WellSegments>(std::move(segments) ));
}
auto [connections, segments] = Compsegs::rstUpdate(rst_well, rst_connections, rst_segments);
well.updateConnections( std::make_shared<WellConnections>(std::move(connections)), grid, fp.get_int("PVTNUM"));
well.updateSegments( std::make_shared<WellSegments>(std::move(segments) ));
this->addWell(well, report_step);
this->addWellToGroup(well.groupName(), well.name(), report_step);
}
this->addWell(well, report_step);
this->addWellToGroup(well.groupName(), well.name(), report_step);
m_tuning.update(report_step, rst_state.tuning);
m_events.addEvent( ScheduleEvents::TUNING_CHANGE , report_step);
}
m_tuning.update(report_step, rst_state.tuning);
m_events.addEvent( ScheduleEvents::TUNING_CHANGE , report_step);
}
std::shared_ptr<const Python> Schedule::python() const
{
return this->python_handle;
}
std::shared_ptr<const Python> Schedule::python() const
{
return this->python_handle;
}
void Schedule::updateNetwork(std::shared_ptr<Network::ExtNetwork> network, std::size_t report_step) {
this->m_network.update(report_step, std::move(network));
}
const Network::ExtNetwork& Schedule::network(std::size_t report_step) const {
return *this->m_network[report_step];
}
const GasLiftOpt& Schedule::glo(std::size_t report_step) const {
return *this->m_glo[report_step];
}
void Schedule::updateNetwork(std::shared_ptr<Network::ExtNetwork> network, std::size_t report_step) {
this->m_network.update(report_step, std::move(network));
}
const Network::ExtNetwork& Schedule::network(std::size_t report_step) const {
return *this->m_network[report_step];
}
const GasLiftOpt& Schedule::glo(std::size_t report_step) const {
return *this->m_glo[report_step];
}
namespace {
/*