Loading...
Searching...
No Matches
SimulatorTimer.hpp
/*
Copyright 2012 SINTEF ICT, Applied Mathematics.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_SIMULATORTIMER_HEADER_INCLUDED
#define OPM_SIMULATORTIMER_HEADER_INCLUDED
#include <opm/simulators/timestepping/SimulatorTimerInterface.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <cstddef>
#include <iosfwd>
#include <memory>
#include <vector>
namespace Opm
{
class ParameterGroup;
class Schedule;
class SimulatorTimer : public SimulatorTimerInterface
{
public:
// use default implementation of these methods
using SimulatorTimerInterface::currentDateTime;
using SimulatorTimerInterface::currentPosixTime;
SimulatorTimer();
static SimulatorTimer serializationTestObject();
void init(const ParameterGroup& param);
void init(const Schedule& schedule, std::size_t report_step = 0);
bool initialStep() const override;
int numSteps() const;
int currentStepNum() const override;
void setCurrentStepNum(int step);
double currentStepLength() const override;
double stepLengthTaken () const override;
double simulationTimeElapsed() const override;
double totalTime() const;
boost::posix_time::ptime startDateTime() const override;
void setTotalTime(double time);
void report(std::ostream& os) const;
SimulatorTimer& operator++();
void advance() override { this->operator++(); }
bool done() const override;
bool lastStepFailed() const override { return false; }
std::unique_ptr<SimulatorTimerInterface> clone() const override;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(timesteps_);
serializer(current_step_);
serializer(current_time_);
serializer(total_time_);
serializer(start_date_);
}
bool operator==(const SimulatorTimer& rhs) const;
private:
std::vector<double> timesteps_;
int current_step_;
double current_time_;
double total_time_;
boost::gregorian::date start_date_;
};
} // namespace Opm
#endif // OPM_SIMULATORTIMER_HEADER_INCLUDED
Opm::SimulatorTimerInterface::currentPosixTime
virtual time_t currentPosixTime() const
Time elapsed since the start of the POSIX epoch (Jan 1st, 1970) until the current time step begins [s...
Definition SimulatorTimerInterface.cpp:37
Opm::SimulatorTimerInterface::SimulatorTimerInterface
SimulatorTimerInterface()
Default constructor, protected to not allow explicit instances of this class.
Definition SimulatorTimerInterface.hpp:37
Opm::SimulatorTimerInterface::currentDateTime
virtual boost::posix_time::ptime currentDateTime() const
Return the current time as a posix time object.
Definition SimulatorTimerInterface.cpp:28
Opm::SimulatorTimer::setTotalTime
void setTotalTime(double time)
Set total time.
Definition SimulatorTimer.cpp:143
Opm::SimulatorTimer::totalTime
double totalTime() const
Total time.
Definition SimulatorTimer.cpp:134
Opm::SimulatorTimer::lastStepFailed
bool lastStepFailed() const override
Always return false.
Definition SimulatorTimer.hpp:118
Opm::SimulatorTimer::startDateTime
boost::posix_time::ptime startDateTime() const override
Return start date of simulation.
Definition SimulatorTimer.cpp:127
Opm::SimulatorTimer::numSteps
int numSteps() const
Total number of steps.
Definition SimulatorTimer.cpp:89
Opm::SimulatorTimer::currentStepLength
double currentStepLength() const override
Current step length.
Definition SimulatorTimer.cpp:109
Opm::SimulatorTimer::initialStep
bool initialStep() const override
Whether the current step is the first step.
Definition SimulatorTimer.cpp:83
Opm::SimulatorTimer::advance
void advance() override
advance time by currentStepLength
Definition SimulatorTimer.hpp:111
Opm::SimulatorTimer::clone
std::unique_ptr< SimulatorTimerInterface > clone() const override
return copy of object
Definition SimulatorTimer.cpp:175
Opm::SimulatorTimer::setCurrentStepNum
void setCurrentStepNum(int step)
Set current step number.
Definition SimulatorTimer.cpp:101
Opm::SimulatorTimer::report
void report(std::ostream &os) const
Print a report with current and total time etc.
Definition SimulatorTimer.cpp:149
Opm::SimulatorTimer::simulationTimeElapsed
double simulationTimeElapsed() const override
Time elapsed since the start of the simulation until the beginning of the current time step [s].
Definition SimulatorTimer.cpp:122
Opm::SimulatorTimer::currentStepNum
int currentStepNum() const override
Current step number.
Definition SimulatorTimer.cpp:95
Opm::SimulatorTimer::stepLengthTaken
double stepLengthTaken() const override
Previous step length.
Definition SimulatorTimer.cpp:115
Opm::SimulatorTimer::SimulatorTimer
SimulatorTimer()
Default constructor.
Definition SimulatorTimer.cpp:37
Opm::SimulatorTimer::operator++
SimulatorTimer & operator++()
advance time by currentStepLength
Definition SimulatorTimer.cpp:159
Opm::SimulatorTimer::done
bool done() const override
Return true if op++() has been called numSteps() times.
Definition SimulatorTimer.cpp:168
Opm::SimulatorTimer::init
void init(const ParameterGroup &param)
Initialize from parameters.
Definition SimulatorTimer.cpp:59
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43