Merge pull request #2207 from joakim-hove/sched-rptconfig

Sched rptconfig
This commit is contained in:
Joakim Hove 2021-01-14 11:52:19 +01:00 committed by GitHub
commit 32dec137a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 67 additions and 37 deletions

View File

@ -26,16 +26,28 @@
namespace Opm {
class RPTConfig: public std::unordered_map<std::string,unsigned> {
#if __cplusplus <= 201703L
class RPTConfig {
public:
bool contains(const std::string&) const;
#endif
public:
using std::unordered_map<std::string,unsigned>::unordered_map;
using Map = std::unordered_map<std::string, unsigned>;
RPTConfig() = default;
RPTConfig(const DeckKeyword&);
bool contains(const std::string& key) const;
template<class Serializer>
void serializeOp(Serializer& serializer) {
serializer.template map<Map, false>( m_mnemonics );
}
std::unordered_map<std::string, unsigned>::const_iterator begin() const { return this->m_mnemonics.begin(); };
std::unordered_map<std::string, unsigned>::const_iterator end() const { return this->m_mnemonics.end(); };
std::size_t size() const { return this->m_mnemonics.size(); };
unsigned& at(const std::string& key) { return this->m_mnemonics.at(key); };
static RPTConfig serializeObject();
bool operator==(const RPTConfig& other) const;
private:
std::unordered_map<std::string, unsigned> m_mnemonics;
};
}

View File

@ -48,6 +48,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleDeck.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/RPTConfig.hpp>
#include <opm/common/utility/ActiveGridCells.hpp>
#include <opm/io/eclipse/rst/state.hpp>
@ -104,7 +105,6 @@ namespace Opm
class EclipseState;
class FieldPropsManager;
class Runspec;
class RPTConfig;
class SCHEDULESection;
class SummaryState;
class TimeMap;
@ -288,8 +288,6 @@ namespace Opm
const Action::Actions& actions(std::size_t timeStep) const;
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;
std::size_t numGroups() const;
@ -392,7 +390,6 @@ namespace Opm
RFTConfig rft_config;
RestartConfig restart_config;
std::optional<int> exit_status;
DynamicState<std::shared_ptr<RPTConfig>> rpt_config;
std::vector<ScheduleState> snapshots;

View File

@ -26,6 +26,7 @@
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/RPTConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/PAvg.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
@ -112,6 +113,9 @@ namespace Opm {
const Network::ExtNetwork& network() const;
void network(Network::ExtNetwork network);
const RPTConfig& rpt_config() const;
void rpt_config(RPTConfig rpt_config);
template<class Serializer>
void serializeOp(Serializer& serializer) {
serializer(m_start_time);
@ -130,6 +134,7 @@ namespace Opm {
serializer(m_gconsump);
serializer(m_wlist_manager);
serializer(m_network);
serializer(m_rptconfig);
}
private:
@ -150,6 +155,7 @@ namespace Opm {
std::shared_ptr<GConSump> m_gconsump;
std::shared_ptr<WListManager> m_wlist_manager;
std::shared_ptr<Network::ExtNetwork> m_network;
std::shared_ptr<RPTConfig> m_rptconfig;
};
}

View File

@ -263,7 +263,7 @@ void EclipseIO::writeTimeStep(const Action::State& action_state,
if (!isSubstep) {
for (const auto& report : schedule.report_config(report_step)) {
for (const auto& report : schedule[report_step].rpt_config()) {
std::stringstream ss;
const auto& unit_system = this->impl->es.getUnits();

View File

@ -742,7 +742,7 @@ namespace {
}
void Schedule::handleRPTSCHED(const HandlerContext& handlerContext, const ParseContext&, ErrorGuard&) {
this->rpt_config.update(handlerContext.currentStep, std::make_shared<RPTConfig>(handlerContext.keyword));
this->snapshots.back().rpt_config( RPTConfig(handlerContext.keyword ));
}
void Schedule::handleTUNING(const HandlerContext& handlerContext, const ParseContext&, ErrorGuard&) {

View File

@ -41,21 +41,32 @@ namespace {
}
Opm::RPTConfig::RPTConfig(const DeckKeyword& keyword) :
std::unordered_map<std::string,unsigned> {}
{
namespace Opm {
RPTConfig RPTConfig::serializeObject() {
RPTConfig rptc;
rptc.m_mnemonics.emplace( "KEY", 100 );
return rptc;
}
RPTConfig::RPTConfig(const DeckKeyword& keyword) {
const auto& mnemonics { keyword.getStringData() } ;
for (const auto& mnemonic : mnemonics) {
if (mnemonic == "NOTHING") {
clear();
} else {
emplace(parse_mnemonic(mnemonic));
}
if (mnemonic == "NOTHING")
this->m_mnemonics.clear();
else
this->m_mnemonics.emplace(parse_mnemonic(mnemonic));
}
}
#if __cplusplus <= 201703L
bool Opm::RPTConfig::contains(const std::string& key) const {
return find(key) != end();
bool RPTConfig::operator==(const RPTConfig& other) const {
return this->m_mnemonics == other.m_mnemonics;
}
bool RPTConfig::contains(const std::string& key) const {
return this->m_mnemonics.find(key) != this->m_mnemonics.end();
}
}
#endif

View File

@ -119,8 +119,7 @@ namespace {
m_actions(this->m_timeMap, std::make_shared<Action::Actions>()),
m_glo(this->m_timeMap, std::make_shared<GasLiftOpt>()),
rft_config(this->m_timeMap),
restart_config(m_timeMap, deck, parseContext, errors),
rpt_config(this->m_timeMap, std::make_shared<RPTConfig>())
restart_config(m_timeMap, deck, parseContext, errors)
{
if (rst)
this->load_rst(*rst, grid, fp);
@ -1466,11 +1465,6 @@ void Schedule::iterateScheduleSection(std::optional<std::size_t> load_offset,
return *ptr;
}
const RPTConfig& Schedule::report_config(std::size_t timeStep) const {
const auto& ptr = this->rpt_config.get(timeStep);
return *ptr;
}
std::optional<int> Schedule::exitStatus() const {
return this->exit_status;
}
@ -1637,7 +1631,6 @@ void Schedule::iterateScheduleSection(std::optional<std::size_t> load_offset,
compareDynState(this->udq_active, data.udq_active) &&
compareDynState(this->guide_rate_config, data.guide_rate_config) &&
compareDynState(this->m_actions, data.m_actions) &&
compareDynState(this->rpt_config, data.rpt_config) &&
rft_config == data.rft_config &&
this->restart_config == data.restart_config &&
this->snapshots == data.snapshots;
@ -2049,6 +2042,7 @@ void Schedule::create_first(const std::chrono::system_clock::time_point& start_t
sched_state.gconsump( GConSump() );
sched_state.wlist_manager( WListManager() );
sched_state.network( Network::ExtNetwork() );
sched_state.rpt_config( RPTConfig() );
this->addGroup("FIELD", 0);
}

View File

@ -154,6 +154,7 @@ bool ScheduleState::operator==(const ScheduleState& other) const {
*this->m_gconsale == *other.m_gconsale &&
*this->m_gconsump == *other.m_gconsump &&
*this->m_wlist_manager == *other.m_wlist_manager &&
*this->m_rptconfig == *other.m_rptconfig &&
this->m_nupcol == other.m_nupcol;
}
@ -170,6 +171,7 @@ ScheduleState ScheduleState::serializeObject() {
ts.m_gconsump = std::make_shared<GConSump>( GConSump::serializeObject() );
ts.m_gconsale = std::make_shared<GConSale>( GConSale::serializeObject() );
ts.m_wlist_manager = std::make_shared<WListManager>( WListManager::serializeObject() );
ts.m_rptconfig = std::make_shared<RPTConfig>( RPTConfig::serializeObject() );
return ts;
}
@ -250,4 +252,12 @@ void ScheduleState::network(Network::ExtNetwork network) {
this->m_network = std::make_shared<Network::ExtNetwork>( std::move(network) );
}
const RPTConfig& ScheduleState::rpt_config() const {
return *this->m_rptconfig;
}
void ScheduleState::rpt_config(RPTConfig rpt_config) {
this->m_rptconfig = std::make_shared<RPTConfig>(std::move(rpt_config));
}
}

View File

@ -125,7 +125,7 @@ RPTSCHED
// Empty initial report configuration
{
auto report_config = sched.report_config(0);
auto report_config = sched[0].rpt_config();
BOOST_CHECK_EQUAL(report_config.size(), 0U);
BOOST_CHECK(!report_config.contains("FIPFOAM"));
@ -134,7 +134,7 @@ RPTSCHED
// Configuration at step 1
{
auto report_config = sched.report_config(1);
auto report_config = sched[1].rpt_config();
BOOST_CHECK_EQUAL( report_config.size() , 2U);
for (const auto& p : report_config) {
@ -153,7 +153,7 @@ RPTSCHED
// Configuration at step 2 - the special 'NOTHING' has cleared everything
{
auto report_config = sched.report_config(2);
auto report_config = sched[2].rpt_config();
BOOST_CHECK_EQUAL(report_config.size(), 0U);
BOOST_CHECK(!report_config.contains("FIPFOAM"));