Merge pull request #2325 from OPM/restart-config-private
Hide RestartConfig as private member of Schedule class
This commit is contained in:
@@ -245,8 +245,12 @@ namespace Opm
|
||||
*/
|
||||
void filterConnections(const ActiveGridCells& grid);
|
||||
std::size_t size() const;
|
||||
const RestartConfig& restart() const;
|
||||
RestartConfig& restart();
|
||||
|
||||
bool write_rst_file(std::size_t report_step, bool log=true) const;
|
||||
int first_rst_step() 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;
|
||||
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 applyWellProdIndexScaling(const std::string& well_name, const std::size_t reportStep, const double scalingFactor);
|
||||
@@ -447,6 +451,9 @@ namespace Opm
|
||||
std::optional<int> exit_status;
|
||||
std::vector<ScheduleState> snapshots;
|
||||
|
||||
RestartConfig& restart();
|
||||
const RestartConfig& restart() const;
|
||||
|
||||
void load_rst(const RestartIO::RstState& rst,
|
||||
const EclipseGrid& grid,
|
||||
const FieldPropsManager& fp);
|
||||
|
||||
@@ -88,10 +88,6 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
const RestartConfig& restart(const Schedule& sch) {
|
||||
return sch.restart();
|
||||
}
|
||||
|
||||
const ScheduleState& getitem(const Schedule& sch, std::size_t index) {
|
||||
return sch[index];
|
||||
}
|
||||
@@ -117,7 +113,6 @@ void python::common::export_Schedule(py::module& module) {
|
||||
.def_property_readonly( "start", &get_start_time )
|
||||
.def_property_readonly( "end", &get_end_time )
|
||||
.def_property_readonly( "timesteps", &get_timesteps )
|
||||
.def_property_readonly("restart", &restart)
|
||||
.def("__len__", &Schedule::size)
|
||||
.def("__getitem__", &getitem)
|
||||
.def( "shut_well", &Schedule::shut_well)
|
||||
@@ -128,9 +123,4 @@ void python::common::export_Schedule(py::module& module) {
|
||||
.def( "get_well", &get_well)
|
||||
.def( "__contains__", &has_well );
|
||||
|
||||
py::class_< RestartConfig >( module, "RestartConfig")
|
||||
.def( "getKeyword", &RestartConfig::getKeyword )
|
||||
.def( "getFirstRestartStep", &RestartConfig::getFirstRestartStep )
|
||||
.def( "getWriteRestartFile", &RestartConfig::getWriteRestartFile, py::arg("reportStep"), py::arg("log") = true);
|
||||
|
||||
}
|
||||
|
||||
@@ -68,12 +68,6 @@ class TestSchedule(unittest.TestCase):
|
||||
prod = sch.get_well("PROD", 10)
|
||||
self.assertEqual(prod.status(), "SHUT")
|
||||
|
||||
def test_restart(self):
|
||||
deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA'))
|
||||
state = EclipseState(deck)
|
||||
sch = Schedule( deck, state )
|
||||
rst = sch.restart
|
||||
|
||||
|
||||
def test_well_names(self):
|
||||
deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA'))
|
||||
|
||||
@@ -236,7 +236,7 @@ void EclipseIO::writeTimeStep(const Action::State& action_state,
|
||||
but there is an unsupported option to the RPTSCHED keyword which
|
||||
will request restart output from every timestep.
|
||||
*/
|
||||
if(!isSubstep && schedule.restart().getWriteRestartFile(report_step))
|
||||
if(!isSubstep && schedule.write_rst_file(report_step))
|
||||
{
|
||||
EclIO::OutputStream::Restart rstFile {
|
||||
EclIO::OutputStream::ResultSet { this->impl->outputDir,
|
||||
|
||||
@@ -1185,6 +1185,26 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
|
||||
return this->restart_config;
|
||||
}
|
||||
|
||||
bool Schedule::write_rst_file(std::size_t report_step, bool log) const {
|
||||
return this->restart_config.getWriteRestartFile(report_step, log);
|
||||
}
|
||||
|
||||
int Schedule::first_rst_step() const {
|
||||
return this->restart_config.getFirstRestartStep();
|
||||
}
|
||||
|
||||
const std::map< std::string, int >& Schedule::rst_keywords( size_t timestep ) const {
|
||||
return this->restart_config.getRestartKeywords(timestep);
|
||||
}
|
||||
|
||||
bool Schedule::rst_keyword(std::size_t timeStep, const std::string& keyword) const {
|
||||
return this->restart_config.getKeyword(keyword, timeStep);
|
||||
}
|
||||
|
||||
void Schedule::rst_override_interval(std::size_t output_interval) {
|
||||
this->restart_config.overrideRestartWriteInterval(output_interval);
|
||||
}
|
||||
|
||||
bool Schedule::operator==(const Schedule& data) const {
|
||||
|
||||
return this->m_restart_info == data.m_restart_info &&
|
||||
|
||||
@@ -41,13 +41,12 @@ inline std::string path_prefix() {
|
||||
}
|
||||
|
||||
inline void verifyRestartConfig( const Schedule& sched, std::vector<std::tuple<int , bool, boost::gregorian::date>>& rptConfig) {
|
||||
const auto& rst = sched.restart();
|
||||
for (auto rptrst : rptConfig) {
|
||||
int report_step = std::get<0>(rptrst);
|
||||
bool save = std::get<1>(rptrst);
|
||||
boost::gregorian::date report_date = std::get<2>(rptrst);
|
||||
|
||||
BOOST_CHECK_EQUAL( save, rst.getWriteRestartFile( report_step ) );
|
||||
BOOST_CHECK_EQUAL( save, sched.write_rst_file( report_step ) );
|
||||
if (save) {
|
||||
std::time_t t = sched.simTime(report_step);
|
||||
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
|
||||
@@ -356,10 +355,9 @@ BOOST_AUTO_TEST_CASE( RestartConfig2 ) {
|
||||
auto deck = parser.parseFile(path_prefix() + "IOConfig/RPT_TEST2.DATA");
|
||||
EclipseState state( deck);
|
||||
Schedule schedule(deck, state, python);
|
||||
const auto& rstConfig = schedule.restart();
|
||||
verifyRestartConfig(schedule, rptConfig);
|
||||
|
||||
BOOST_CHECK_EQUAL( rstConfig.getFirstRestartStep() , 0 );
|
||||
BOOST_CHECK_EQUAL( schedule.first_rst_step() , 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user