mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-24 16:30:02 -06:00
Use Schedule time functions - avoid TimeMap
This commit is contained in:
parent
831f1db872
commit
6f15765f53
@ -858,11 +858,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 +967,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 +1026,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 +1050,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 +1239,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));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2743,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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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() );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user