Added start_date_ property to the SimulatorTimer class

This commit is contained in:
Joakim Hove 2012-11-07 14:53:26 +01:00
parent 158c33eb53
commit 09b3ef785c
2 changed files with 72 additions and 57 deletions

View File

@ -30,7 +30,8 @@ namespace Opm
/// Default constructor.
SimulatorTimer::SimulatorTimer()
: current_step_(0),
current_time_(0.0)
current_time_(0.0),
start_date_(2012,1,1) // A really arbitrary default starting value?!
{
}
@ -52,6 +53,7 @@ namespace Opm
{
timesteps_ = deck.getTSTEP().tstep_;
total_time_ = std::accumulate(timesteps_.begin(), timesteps_.end(), 0.0);
start_date_ = deck.getStartDate();
}
/// Total number of steps.
@ -92,6 +94,14 @@ namespace Opm
return current_time_;
}
boost::posix_time::ptime SimulatorTimer::currentDateTime() const
{
return boost::posix_time::ptime(start_date_) + boost::posix_time::seconds( (int) current_time_ );
}
/// Total time.
double SimulatorTimer::totalTime() const
{

View File

@ -22,6 +22,8 @@
#include <iosfwd>
#include <vector>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
namespace Opm
{
@ -60,6 +62,8 @@ namespace Opm
/// Current time.
double currentTime() const;
boost::posix_time::ptime currentDateTime() const;
/// Total time.
double totalTime() const;
@ -84,6 +88,7 @@ namespace Opm
int current_step_;
double current_time_;
double total_time_;
boost::gregorian::date start_date_;
};