TimeMap: Expose more data

basically, we now can access the beginning of a timestep its length
and the total time passed since the beginning of life, the universe
and all the rest.
This commit is contained in:
Andreas Lauser
2014-02-21 16:58:37 +01:00
parent be137414c8
commit e6c0ff4546
2 changed files with 38 additions and 1 deletions

View File

@@ -30,6 +30,13 @@ namespace Opm {
m_timeList.push_back( boost::posix_time::ptime(startDate) );
}
double TimeMap::getTotalTime() const
{
if (m_timeList.size() < 2)
return 0.0;
boost::posix_time::time_duration deltaT = m_timeList.back() - m_timeList.front();
return static_cast<double>(deltaT.total_milliseconds())/1000.0;
}
void TimeMap::addTime(boost::posix_time::ptime newTime) {
boost::posix_time::ptime lastTime = m_timeList.back();
@@ -146,7 +153,31 @@ namespace Opm {
}
}
}
double TimeMap::getTimeStepLength(int tStepIdx) const
{
assert(0 <= tStepIdx && tStepIdx < numTimesteps());
const boost::posix_time::ptime &t1
= m_timeList[tStepIdx];
const boost::posix_time::ptime &t2
= m_timeList[tStepIdx + 1];
const boost::posix_time::time_duration &deltaT
= t2 - t1;
return static_cast<double>(deltaT.total_milliseconds())/1000.0;
}
double TimeMap::getTimePassedUntil(int tStepIdx) const
{
assert(0 <= tStepIdx && tStepIdx < numTimesteps());
const boost::posix_time::ptime &t1
= m_timeList[tStepIdx];
const boost::posix_time::ptime &t2
= m_timeList.back();
const boost::posix_time::time_duration &deltaT
= t2 - t1;
return static_cast<double>(deltaT.total_milliseconds())/1000.0;
}
}

View File

@@ -36,9 +36,15 @@ namespace Opm {
void addFromDATESKeyword( DeckKeywordConstPtr DATESKeyword );
void addFromTSTEPKeyword( DeckKeywordConstPtr TSTEPKeyword );
size_t size() const;
int numTimesteps() const { return m_timeList.size() - 1; }
double getTotalTime() const;
/// Return the date and time where a given time step starts.
boost::posix_time::ptime getStartTime(int tStepIdx) const
{ return m_timeList[tStepIdx]; }
/// Return the period of time in seconds which passed between the start of the simulation and a given time step.
double getTimePassedUntil(int tStepIdx) const;
/// Return the length of a given time step in seconds.
double getTimeStepLength(int tStepIdx) const;
static boost::posix_time::ptime timeFromEclipse(DeckRecordConstPtr dateRecord);
static boost::posix_time::ptime timeFromEclipse(int day , const std::string& month, int year, const std::string& eclipseTimeString = "00:00:00.000");
static boost::posix_time::time_duration dayTimeFromEclipse(const std::string& eclipseTimeString);