mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3073 from joakim-hove/timemap-api
Remove timemap member from Schedule
This commit is contained in:
commit
4ed085ddc3
@ -49,6 +49,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp>
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
|
||||
|
||||
#include <opm/simulators/utils/readDeck.hpp>
|
||||
@ -448,7 +449,7 @@ public:
|
||||
std::move(parseContext_), /* initFromRestart = */ false,
|
||||
/* checkDeck = */ enableExperiments);
|
||||
|
||||
this->summaryState_ = std::make_unique<Opm::SummaryState>( std::chrono::system_clock::from_time_t(this->eclSchedule_->getStartTime() ));
|
||||
this->summaryState_ = std::make_unique<Opm::SummaryState>( Opm::TimeService::from_time_t(this->eclSchedule_->getStartTime() ));
|
||||
this->udqState_ = std::make_unique<Opm::UDQState>( this->eclSchedule_->getUDQConfig(0).params().undefinedValue() );
|
||||
this->actionState_ = std::make_unique<Opm::Action::State>() ;
|
||||
|
||||
|
@ -99,6 +99,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/RockwnodTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/OverburdTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/RocktabTable.hpp>
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
#include <opm/material/common/ConditionalStorage.hpp>
|
||||
|
||||
#include <dune/common/version.hh>
|
||||
@ -858,11 +859,10 @@ public:
|
||||
auto& simulator = this->simulator();
|
||||
const auto& eclState = simulator.vanguard().eclState();
|
||||
const auto& schedule = simulator.vanguard().schedule();
|
||||
const auto& timeMap = schedule.getTimeMap();
|
||||
|
||||
// Set the start time of the simulation
|
||||
simulator.setStartTime(timeMap.getStartTime(/*reportStepIdx=*/0));
|
||||
simulator.setEndTime(timeMap.getTotalTime());
|
||||
simulator.setStartTime(schedule.getStartTime());
|
||||
simulator.setEndTime(schedule.simTime(schedule.size() - 1));
|
||||
|
||||
// We want the episode index to be the same as the report step index to make
|
||||
// things simpler, so we have to set the episode index to -1 because it is
|
||||
@ -968,7 +968,7 @@ public:
|
||||
// to the first "real" episode/report step
|
||||
// for restart the episode index and start is already set
|
||||
if (!initconfig.restartRequested()) {
|
||||
simulator.startNextEpisode(timeMap.getTimeStepLength(0));
|
||||
simulator.startNextEpisode(schedule.seconds(0));
|
||||
simulator.setEpisodeIndex(0);
|
||||
}
|
||||
}
|
||||
@ -1027,7 +1027,6 @@ public:
|
||||
auto& eclState = simulator.vanguard().eclState();
|
||||
const auto& schedule = simulator.vanguard().schedule();
|
||||
const auto& events = schedule[episodeIdx].events();
|
||||
const auto& timeMap = schedule.getTimeMap();
|
||||
|
||||
if (episodeIdx >= 0 && events.hasEvent(Opm::ScheduleEvents::GEO_MODIFIER)) {
|
||||
// bring the contents of the keywords to the current state of the SCHEDULE
|
||||
@ -1052,12 +1051,12 @@ public:
|
||||
std::ostringstream ss;
|
||||
boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%d-%b-%Y");
|
||||
boost::posix_time::ptime curDateTime =
|
||||
boost::posix_time::from_time_t(timeMap.getStartTime(episodeIdx));
|
||||
boost::posix_time::from_time_t(schedule.simTime(episodeIdx));
|
||||
ss.imbue(std::locale(std::locale::classic(), facet));
|
||||
ss << "Report step " << episodeIdx + 1
|
||||
<< "/" << timeMap.numTimesteps()
|
||||
<< " at day " << timeMap.getTimePassedUntil(episodeIdx)/(24*3600)
|
||||
<< "/" << timeMap.getTotalTime()/(24*3600)
|
||||
<< "/" << schedule.size() - 1
|
||||
<< " at day " << schedule.seconds(episodeIdx)/(24*3600)
|
||||
<< "/" << schedule.seconds(schedule.size() - 1)/(24*3600)
|
||||
<< ", date = " << curDateTime.date()
|
||||
<< "\n ";
|
||||
OpmLog::info(ss.str());
|
||||
@ -1241,18 +1240,17 @@ public:
|
||||
{
|
||||
auto& simulator = this->simulator();
|
||||
auto& schedule = simulator.vanguard().schedule();
|
||||
const auto& timeMap = schedule.getTimeMap();
|
||||
|
||||
int episodeIdx = simulator.episodeIndex();
|
||||
|
||||
// check if we're finished ...
|
||||
if (episodeIdx + 1 >= static_cast<int>(timeMap.numTimesteps())) {
|
||||
if (episodeIdx + 1 >= static_cast<int>(schedule.size() - 1)) {
|
||||
simulator.setFinished(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// .. if we're not yet done, start the next episode (report step)
|
||||
simulator.startNextEpisode(timeMap.getTimeStepLength(episodeIdx + 1));
|
||||
simulator.startNextEpisode(schedule.stepLength(episodeIdx + 1));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1381,7 +1379,7 @@ public:
|
||||
|
||||
const auto& wellpi = this->fetchWellPI(reportStep, *action, schedule, matching_wells);
|
||||
|
||||
schedule.applyAction(reportStep, std::chrono::system_clock::from_time_t(simTime), *action, actionResult, wellpi);
|
||||
schedule.applyAction(reportStep, Opm::TimeService::from_time_t(simTime), *action, actionResult, wellpi);
|
||||
actionState.add_run(*action, simTime);
|
||||
|
||||
for ( const auto& [wname, _] : wellpi) {
|
||||
@ -2742,16 +2740,15 @@ private:
|
||||
auto& simulator = this->simulator();
|
||||
const auto& schedule = simulator.vanguard().schedule();
|
||||
const auto& eclState = simulator.vanguard().eclState();
|
||||
const auto& timeMap = schedule.getTimeMap();
|
||||
const auto& initconfig = eclState.getInitConfig();
|
||||
{
|
||||
int restart_step = initconfig.getRestartStep();
|
||||
|
||||
simulator.setStartTime(timeMap.getStartTime(/*timeStepIdx=*/0));
|
||||
simulator.setTime(timeMap.getTimePassedUntil(restart_step));
|
||||
simulator.setStartTime(schedule.simTime(0));
|
||||
simulator.setTime(schedule.seconds(restart_step));
|
||||
|
||||
simulator.startNextEpisode(simulator.startTime() + simulator.time(),
|
||||
timeMap.getTimeStepLength(restart_step));
|
||||
schedule.stepLength(restart_step));
|
||||
simulator.setEpisodeIndex(restart_step);
|
||||
}
|
||||
eclWriter_->beginRestart();
|
||||
|
@ -605,7 +605,7 @@ public:
|
||||
if (wellTopologyChanged_(eclState, reportStepIdx))
|
||||
return true;
|
||||
|
||||
if (schedule.getTimeMap().numTimesteps() <= (unsigned) reportStepIdx)
|
||||
if ((schedule.size() - 1) <= (unsigned) reportStepIdx)
|
||||
// for the "until the universe dies" episode, the wells don't change
|
||||
return false;
|
||||
|
||||
@ -660,7 +660,7 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
if (schedule.getTimeMap().numTimesteps() <= (unsigned) reportStepIdx)
|
||||
if ((schedule.size() - 1) <= (unsigned) reportStepIdx)
|
||||
// for the "until the universe dies" episode, the wells don't change
|
||||
return false;
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <opm/simulators/wells/VFPProperties.hpp>
|
||||
#include <opm/simulators/wells/VFPInjProperties.hpp>
|
||||
#include <opm/simulators/wells/VFPProdProperties.hpp>
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
@ -52,7 +53,7 @@ struct Setup
|
||||
const Runspec runspec(deck);
|
||||
python = std::make_shared<Python>();
|
||||
schedule.reset( new Schedule(deck, *ecl_state, python));
|
||||
summary_state.reset( new SummaryState(std::chrono::system_clock::from_time_t(schedule->getStartTime())));
|
||||
summary_state.reset( new SummaryState(TimeService::from_time_t(schedule->getStartTime())));
|
||||
}
|
||||
const int step = 0;
|
||||
const auto& sched_state = schedule->operator[](step);
|
||||
|
@ -608,13 +608,12 @@ namespace Opm
|
||||
{
|
||||
|
||||
const auto& schedule = this->schedule();
|
||||
const auto& timeMap = schedule.getTimeMap();
|
||||
auto& ioConfig = eclState().getIOConfig();
|
||||
simtimer_ = std::make_unique<SimulatorTimer>();
|
||||
|
||||
// initialize variables
|
||||
const auto& initConfig = eclState().getInitConfig();
|
||||
simtimer_->init(timeMap, (size_t)initConfig.getRestartStep());
|
||||
simtimer_->init(schedule, (size_t)initConfig.getRestartStep());
|
||||
|
||||
if (this->output_cout_) {
|
||||
std::ostringstream oss;
|
||||
|
@ -231,7 +231,7 @@ public:
|
||||
|
||||
ebosSimulator_.startNextEpisode(
|
||||
ebosSimulator_.startTime()
|
||||
+ schedule().getTimeMap().getTimePassedUntil(timer.currentStepNum()),
|
||||
+ schedule().seconds(timer.currentStepNum()),
|
||||
timer.currentStepLength());
|
||||
ebosSimulator_.setEpisodeIndex(timer.currentStepNum());
|
||||
solver->model().beginReportStep();
|
||||
|
@ -49,16 +49,16 @@ namespace Opm
|
||||
}
|
||||
|
||||
/// Use the SimulatorTimer as a shim around opm-parser's Opm::TimeMap
|
||||
void SimulatorTimer::init(const TimeMap& timeMap, size_t report_step)
|
||||
void SimulatorTimer::init(const Schedule& schedule, size_t report_step)
|
||||
{
|
||||
total_time_ = timeMap.getTotalTime();
|
||||
timesteps_.resize(timeMap.numTimesteps());
|
||||
for ( size_t i = 0; i < timeMap.numTimesteps(); ++i ) {
|
||||
timesteps_[i] = timeMap.getTimeStepLength(i);
|
||||
total_time_ = schedule.seconds( schedule.size() - 1 );
|
||||
timesteps_.resize(schedule.size() - 1);
|
||||
for ( size_t i = 0; i < schedule.size() - 1; ++i ) {
|
||||
timesteps_[i] = schedule.stepLength(i);
|
||||
}
|
||||
|
||||
setCurrentStepNum(report_step);
|
||||
start_date_ = boost::posix_time::from_time_t( timeMap.getStartTime(0)).date();
|
||||
start_date_ = boost::posix_time::from_time_t(schedule.getStartTime()).date();
|
||||
}
|
||||
|
||||
/// Whether the current step is the first step.
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef OPM_SIMULATORTIMER_HEADER_INCLUDED
|
||||
#define OPM_SIMULATORTIMER_HEADER_INCLUDED
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/simulators/timestepping/SimulatorTimerInterface.hpp>
|
||||
|
||||
#include <iosfwd>
|
||||
@ -46,8 +46,8 @@ namespace Opm
|
||||
/// stepsize_days (default 1)
|
||||
void init(const ParameterGroup& param);
|
||||
|
||||
/// Use the SimulatorTimer as a shim around opm-parser's Opm::TimeMap
|
||||
void init(const TimeMap& timeMap, size_t report_step = 0);
|
||||
/// Use the SimulatorTimer as a shim around opm-commons Schedule class
|
||||
void init(const Schedule& schedule, size_t report_step = 0);
|
||||
|
||||
/// Whether the current step is the first step.
|
||||
bool initialStep() const;
|
||||
|
@ -283,7 +283,7 @@ std::size_t packSize(const RestartValue& data, Dune::MPIHelper::MPICommunicator
|
||||
+ packSize(data.extra, comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const std::chrono::system_clock::time_point&, Dune::MPIHelper::MPICommunicator comm)
|
||||
std::size_t packSize(const Opm::time_point&, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::time_t tp;
|
||||
return packSize(tp, comm);
|
||||
@ -576,10 +576,10 @@ void pack(const RestartValue& data, std::vector<char>& buffer, int& position,
|
||||
pack(data.extra, buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const std::chrono::system_clock::time_point& data, std::vector<char>& buffer, int& position,
|
||||
void pack(const Opm::time_point& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(std::chrono::system_clock::to_time_t(data), buffer, position, comm);
|
||||
pack(Opm::TimeService::to_time_t(data), buffer, position, comm);
|
||||
}
|
||||
|
||||
|
||||
@ -887,12 +887,12 @@ void unpack(RestartValue& data, std::vector<char>& buffer, int& position,
|
||||
unpack(data.extra, buffer, position, comm);
|
||||
}
|
||||
|
||||
void unpack(std::chrono::system_clock::time_point& data, std::vector<char>& buffer, int& position,
|
||||
void unpack(Opm::time_point& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::time_t tp;
|
||||
unpack(tp, buffer, position, comm);
|
||||
data = std::chrono::system_clock::from_time_t(tp);
|
||||
data = Opm::TimeService::from_time_t(tp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <opm/output/eclipse/EclipseIO.hpp>
|
||||
#include <opm/output/eclipse/Summary.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
|
||||
#include <dune/common/parallel/mpihelper.hh>
|
||||
|
||||
@ -321,7 +322,7 @@ ADD_PACK_PROTOTYPES(data::WellRates)
|
||||
ADD_PACK_PROTOTYPES(RestartKey)
|
||||
ADD_PACK_PROTOTYPES(RestartValue)
|
||||
ADD_PACK_PROTOTYPES(std::string)
|
||||
ADD_PACK_PROTOTYPES(std::chrono::system_clock::time_point)
|
||||
ADD_PACK_PROTOTYPES(Opm::time_point)
|
||||
|
||||
} // end namespace Mpi
|
||||
|
||||
|
@ -29,6 +29,10 @@
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/simulators/timestepping/SimulatorTimer.hpp>
|
||||
#include <opm/parser/eclipse/Units/Units.hpp>
|
||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
@ -40,14 +44,17 @@ BOOST_AUTO_TEST_CASE(CreateTimer)
|
||||
const std::string filename1 = "TESTTIMER.DATA";
|
||||
Opm::Parser parser;
|
||||
Opm::Deck parserDeck = parser.parseFile( filename1);
|
||||
|
||||
Opm::TimeMap timeMap( parserDeck );
|
||||
auto python = std::make_shared<Opm::Python>();
|
||||
Opm::EclipseGrid grid(10,10,10);
|
||||
Opm::FieldPropsManager fp(parserDeck, Opm::Phases{true, true, true}, grid, Opm::TableManager());
|
||||
Opm::Runspec runspec(parserDeck);
|
||||
Opm::Schedule schedule( parserDeck, grid, fp, runspec, python );
|
||||
Opm::SimulatorTimer simtimer;
|
||||
|
||||
boost::gregorian::date defaultStartDate( 2012, 1, 1);
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(defaultStartDate), simtimer.currentDateTime() );
|
||||
|
||||
simtimer.init(timeMap);
|
||||
simtimer.init(schedule);
|
||||
boost::gregorian::date startDate( 2014, 3, 26);
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(startDate), simtimer.currentDateTime() );
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include <opm/grid/GridManager.hpp>
|
||||
#include <opm/parser/eclipse/Units/Units.hpp>
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
|
||||
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
|
||||
#include <opm/grid/GridHelpers.hpp>
|
||||
@ -73,7 +74,7 @@ struct SetupTest {
|
||||
const Opm::Runspec runspec (deck);
|
||||
python = std::make_shared<Opm::Python>();
|
||||
schedule.reset( new Opm::Schedule(deck, *ecl_state, python));
|
||||
summaryState.reset( new Opm::SummaryState(std::chrono::system_clock::from_time_t(schedule->getStartTime())));
|
||||
summaryState.reset( new Opm::SummaryState(Opm::TimeService::from_time_t(schedule->getStartTime())));
|
||||
}
|
||||
current_timestep = 0;
|
||||
};
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/Units/Units.hpp>
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
|
||||
#include <opm/grid/GridHelpers.hpp>
|
||||
|
||||
@ -57,7 +58,7 @@ struct Setup
|
||||
, grid (es.getInputGrid())
|
||||
, python( std::make_shared<Opm::Python>() )
|
||||
, sched(deck, es, python)
|
||||
, st(std::chrono::system_clock::from_time_t(sched.getStartTime()))
|
||||
, st(Opm::TimeService::from_time_t(sched.getStartTime()))
|
||||
{
|
||||
initWellPerfData();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user