Add optional argument to override output interval - EBOS paramstyle

This commit is contained in:
Joakim Hove 2021-03-08 17:39:37 +01:00
parent 8a901f2700
commit 9d18afb45e
6 changed files with 28 additions and 15 deletions

View File

@ -128,6 +128,7 @@ namespace Opm
const ParseContext& parseContext, const ParseContext& parseContext,
ErrorGuard& errors, ErrorGuard& errors,
std::shared_ptr<const Python> python, std::shared_ptr<const Python> python,
const std::optional<int>& output_interval = {},
const RestartIO::RstState* rst = nullptr); const RestartIO::RstState* rst = nullptr);
template<typename T> template<typename T>
@ -138,6 +139,7 @@ namespace Opm
const ParseContext& parseContext, const ParseContext& parseContext,
T&& errors, T&& errors,
std::shared_ptr<const Python> python, std::shared_ptr<const Python> python,
const std::optional<int>& output_interval = {},
const RestartIO::RstState* rst = nullptr); const RestartIO::RstState* rst = nullptr);
Schedule(const Deck& deck, Schedule(const Deck& deck,
@ -145,6 +147,7 @@ namespace Opm
const FieldPropsManager& fp, const FieldPropsManager& fp,
const Runspec &runspec, const Runspec &runspec,
std::shared_ptr<const Python> python, std::shared_ptr<const Python> python,
const std::optional<int>& output_interval = {},
const RestartIO::RstState* rst = nullptr); const RestartIO::RstState* rst = nullptr);
Schedule(const Deck& deck, Schedule(const Deck& deck,
@ -152,6 +155,7 @@ namespace Opm
const ParseContext& parseContext, const ParseContext& parseContext,
ErrorGuard& errors, ErrorGuard& errors,
std::shared_ptr<const Python> python, std::shared_ptr<const Python> python,
const std::optional<int>& output_interval = {},
const RestartIO::RstState* rst = nullptr); const RestartIO::RstState* rst = nullptr);
template <typename T> template <typename T>
@ -160,16 +164,19 @@ namespace Opm
const ParseContext& parseContext, const ParseContext& parseContext,
T&& errors, T&& errors,
std::shared_ptr<const Python> python, std::shared_ptr<const Python> python,
const std::optional<int>& output_interval = {},
const RestartIO::RstState* rst = nullptr); const RestartIO::RstState* rst = nullptr);
Schedule(const Deck& deck, Schedule(const Deck& deck,
const EclipseState& es, const EclipseState& es,
std::shared_ptr<const Python> python, std::shared_ptr<const Python> python,
const std::optional<int>& output_interval = {},
const RestartIO::RstState* rst = nullptr); const RestartIO::RstState* rst = nullptr);
// The constructor *without* the Python arg should really only be used from Python itself // The constructor *without* the Python arg should really only be used from Python itself
Schedule(const Deck& deck, Schedule(const Deck& deck,
const EclipseState& es, const EclipseState& es,
const std::optional<int>& output_interval = {},
const RestartIO::RstState* rst = nullptr); const RestartIO::RstState* rst = nullptr);
static Schedule serializeObject(); static Schedule serializeObject();
@ -250,7 +257,6 @@ namespace Opm
int first_rst_step() const; int first_rst_step() const;
const std::map< std::string, int >& rst_keywords( size_t timestep ) const; const std::map< std::string, int >& rst_keywords( size_t timestep ) const;
bool rst_keyword(std::size_t timestep, const std::string& keyword) const; bool rst_keyword(std::size_t timestep, const std::string& keyword) const;
void rst_override_interval(std::size_t output_interval);
void applyAction(std::size_t reportStep, const time_point& sim_time, const Action::ActionX& action, const Action::Result& result, const std::unordered_map<std::string, double>& wellpi); void applyAction(std::size_t reportStep, const time_point& sim_time, const Action::ActionX& action, const Action::Result& result, const std::unordered_map<std::string, double>& wellpi);
void applyWellProdIndexScaling(const std::string& well_name, const std::size_t reportStep, const double scalingFactor); void applyWellProdIndexScaling(const std::string& well_name, const std::size_t reportStep, const double scalingFactor);
@ -474,7 +480,7 @@ namespace Opm
bool updateWPAVE(const std::string& wname, std::size_t report_step, const PAvg& pavg); bool updateWPAVE(const std::string& wname, std::size_t report_step, const PAvg& pavg);
void updateGuideRateModel(const GuideRateModel& new_model, std::size_t report_step); void updateGuideRateModel(const GuideRateModel& new_model, std::size_t report_step);
void rst_override_interval(std::size_t output_interval);
GTNode groupTree(const std::string& root_node, std::size_t report_step, std::size_t level, const std::optional<std::string>& parent_name) const; GTNode groupTree(const std::string& root_node, std::size_t report_step, std::size_t level, const std::optional<std::string>& parent_name) const;
bool checkGroups(const ParseContext& parseContext, ErrorGuard& errors); bool checkGroups(const ParseContext& parseContext, ErrorGuard& errors);
bool updateWellStatus( const std::string& well, std::size_t reportStep, Well::Status status, std::optional<KeywordLocation> = {}); bool updateWellStatus( const std::string& well, std::size_t reportStep, Well::Status status, std::optional<KeywordLocation> = {});

View File

@ -105,6 +105,7 @@ namespace {
const ParseContext& parseContext, const ParseContext& parseContext,
ErrorGuard& errors, ErrorGuard& errors,
[[maybe_unused]] std::shared_ptr<const Python> python, [[maybe_unused]] std::shared_ptr<const Python> python,
const std::optional<int>& output_interval,
const RestartIO::RstState * rst) const RestartIO::RstState * rst)
try : try :
m_static( python, deck, runspec ), m_static( python, deck, runspec ),
@ -120,6 +121,8 @@ namespace {
} else } else
this->iterateScheduleSection( 0, this->m_sched_deck.size(), parseContext, errors, false, nullptr, &grid, &fp); this->iterateScheduleSection( 0, this->m_sched_deck.size(), parseContext, errors, false, nullptr, &grid, &fp);
if (output_interval.has_value())
this->rst_override_interval(output_interval.value());
} }
catch (const OpmInputError& opm_error) { catch (const OpmInputError& opm_error) {
throw; throw;
@ -141,8 +144,9 @@ namespace {
const ParseContext& parseContext, const ParseContext& parseContext,
T&& errors, T&& errors,
std::shared_ptr<const Python> python, std::shared_ptr<const Python> python,
const std::optional<int>& output_interval,
const RestartIO::RstState * rst) : const RestartIO::RstState * rst) :
Schedule(deck, grid, fp, runspec, parseContext, errors, python, rst) Schedule(deck, grid, fp, runspec, parseContext, errors, python, output_interval, rst)
{} {}
@ -151,12 +155,13 @@ namespace {
const FieldPropsManager& fp, const FieldPropsManager& fp,
const Runspec &runspec, const Runspec &runspec,
std::shared_ptr<const Python> python, std::shared_ptr<const Python> python,
const std::optional<int>& output_interval,
const RestartIO::RstState * rst) : const RestartIO::RstState * rst) :
Schedule(deck, grid, fp, runspec, ParseContext(), ErrorGuard(), python, rst) Schedule(deck, grid, fp, runspec, ParseContext(), ErrorGuard(), python, output_interval, 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::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& parse_context, ErrorGuard& errors, std::shared_ptr<const Python> python, const std::optional<int>& output_interval, const RestartIO::RstState * rst) :
Schedule(deck, Schedule(deck,
es.getInputGrid(), es.getInputGrid(),
es.fieldProps(), es.fieldProps(),
@ -164,12 +169,13 @@ namespace {
parse_context, parse_context,
errors, errors,
python, python,
output_interval,
rst) rst)
{} {}
template <typename T> 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::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& parse_context, T&& errors, std::shared_ptr<const Python> python, const std::optional<int>& output_interval, const RestartIO::RstState * rst) :
Schedule(deck, Schedule(deck,
es.getInputGrid(), es.getInputGrid(),
es.fieldProps(), es.fieldProps(),
@ -177,17 +183,18 @@ namespace {
parse_context, parse_context,
errors, errors,
python, python,
output_interval,
rst) rst)
{} {}
Schedule::Schedule(const Deck& deck, const EclipseState& es, std::shared_ptr<const Python> python, const RestartIO::RstState * rst) : Schedule::Schedule(const Deck& deck, const EclipseState& es, std::shared_ptr<const Python> python, const std::optional<int>& output_interval, const RestartIO::RstState * rst) :
Schedule(deck, es, ParseContext(), ErrorGuard(), python, rst) Schedule(deck, es, ParseContext(), ErrorGuard(), python, output_interval, rst)
{} {}
Schedule::Schedule(const Deck& deck, const EclipseState& es, const RestartIO::RstState * rst) : Schedule::Schedule(const Deck& deck, const EclipseState& es, const std::optional<int>& output_interval, const RestartIO::RstState * rst) :
Schedule(deck, es, ParseContext(), ErrorGuard(), std::make_shared<const Python>(), rst) Schedule(deck, es, ParseContext(), ErrorGuard(), std::make_shared<const Python>(), output_interval, rst)
{} {}
Schedule::Schedule(std::shared_ptr<const Python> python_handle) : Schedule::Schedule(std::shared_ptr<const Python> python_handle) :

View File

@ -156,7 +156,7 @@ BOOST_AUTO_TEST_CASE(RUN) {
const int report_step = 50; const int report_step = 50;
const auto& rst_state = Opm::RestartIO::RstState::load(rst, report_step); const auto& rst_state = Opm::RestartIO::RstState::load(rst, report_step);
Schedule sched_rst(deck, state, python, &rst_state); Schedule sched_rst(deck, state, python, {}, &rst_state);
const auto& rfti_well = sched_rst.getWell("RFTI", report_step); const auto& rfti_well = sched_rst.getWell("RFTI", report_step);
const auto& rftp_well = sched_rst.getWell("RFTP", report_step); const auto& rftp_well = sched_rst.getWell("RFTP", report_step);
BOOST_CHECK(rftp_well.getStatus() == Well::Status::SHUT); BOOST_CHECK(rftp_well.getStatus() == Well::Status::SHUT);

View File

@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(LoadRestartSim) {
EclIO::ERst rst_file("SPE1CASE2.X0060"); EclIO::ERst rst_file("SPE1CASE2.X0060");
auto rst_state = RestartIO::RstState::load(rst_file, 60); auto rst_state = RestartIO::RstState::load(rst_file, 60);
EclipseState ecl_state_restart(restart_deck); EclipseState ecl_state_restart(restart_deck);
Schedule restart_sched(restart_deck, ecl_state_restart, python, &rst_state); Schedule restart_sched(restart_deck, ecl_state_restart, python, {}, &rst_state);
// Verify that sched and restart_sched are identical from report_step 60 and onwords. // Verify that sched and restart_sched are identical from report_step 60 and onwords.
} }

View File

@ -3584,7 +3584,7 @@ BOOST_AUTO_TEST_CASE(SKIPREST_VFP) {
const auto& rst_filename = es.getIOConfig().getRestartFileName( init_config.getRestartRootName(), report_step, false ); const auto& rst_filename = es.getIOConfig().getRestartFileName( init_config.getRestartRootName(), report_step, false );
Opm::EclIO::ERst rst_file(rst_filename); Opm::EclIO::ERst rst_file(rst_filename);
const auto& rst = Opm::RestartIO::RstState::load(rst_file, report_step); const auto& rst = Opm::RestartIO::RstState::load(rst_file, report_step);
const auto sched = Schedule{ deck, es, python , &rst}; const auto sched = Schedule{ deck, es, python , {}, &rst};
BOOST_CHECK_NO_THROW( sched[3].vfpprod(5) ); BOOST_CHECK_NO_THROW( sched[3].vfpprod(5) );
} }

View File

@ -78,7 +78,7 @@ Opm::Schedule load_schedule(std::shared_ptr<const Opm::Python> python, const std
Opm::EclIO::ERst rst_file(rst_filename); Opm::EclIO::ERst rst_file(rst_filename);
const auto& rst = Opm::RestartIO::RstState::load(rst_file, report_step); const auto& rst = Opm::RestartIO::RstState::load(rst_file, report_step);
return Opm::Schedule(deck, state, python, &rst); return Opm::Schedule(deck, state, python, {}, &rst);
} else } else
return Opm::Schedule(deck, state, python); return Opm::Schedule(deck, state, python);
} }