Loading...
Searching...
No Matches
AdaptiveSimulatorTimer.hpp
/*
Copyright 2014 IRIS AS
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_ADAPTIVESIMULATORTIMER_HEADER_INCLUDED
#define OPM_ADAPTIVESIMULATORTIMER_HEADER_INCLUDED
#include <cassert>
#include <iosfwd>
#include <vector>
#include <limits>
#include <algorithm>
#include <memory>
#include <numeric>
#include <opm/simulators/timestepping/SimulatorTimerInterface.hpp>
namespace Opm
{
class AdaptiveSimulatorTimer : public SimulatorTimerInterface
{
public:
AdaptiveSimulatorTimer(const boost::posix_time::ptime simulation_start_time,
const double step_length,
const double elapsed_time,
const double last_step_taken,
const int report_step,
const double max_time_step = std::numeric_limits<double>::max());
AdaptiveSimulatorTimer& operator++ ();
void advance() override { this->operator++ (); }
void provideTimeStepEstimate( const double dt_estimate );
bool initialStep () const override;
int currentStepNum () const override;
int reportStepNum() const override;
double currentStepLength () const override;
// \brief Set next step length
void setCurrentStepLength(double dt);
double totalTime() const;
double simulationTimeElapsed() const override;
bool done () const override;
double averageStepLength() const;
double maxStepLength () const;
double minStepLength () const;
double stepLengthTaken () const override;
void report(std::ostream& os) const;
boost::posix_time::ptime startDateTime() const override;
bool lastStepFailed() const override { return last_step_failed_; }
void setLastStepFailed(bool last_step_failed) { last_step_failed_ = last_step_failed; }
std::unique_ptr<SimulatorTimerInterface> clone() const override;
protected:
std::shared_ptr<boost::posix_time::ptime> start_date_time_;
const double start_time_;
const double total_time_;
const int report_step_;
const double max_time_step_;
double current_time_;
double dt_;
int current_step_;
std::vector< double > steps_;
bool last_step_failed_;
};
} // namespace Opm
#endif // OPM_SIMULATORTIMER_HEADER_INCLUDED
Opm::AdaptiveSimulatorTimer::advance
void advance() override
advance time by currentStepLength
Definition AdaptiveSimulatorTimer.hpp:61
Opm::AdaptiveSimulatorTimer::stepLengthTaken
double stepLengthTaken() const override
Previous step length.
Definition AdaptiveSimulatorTimer.cpp:127
Opm::AdaptiveSimulatorTimer::minStepLength
double minStepLength() const
return min step length used so far
Definition AdaptiveSimulatorTimer.cpp:158
Opm::AdaptiveSimulatorTimer::clone
std::unique_ptr< SimulatorTimerInterface > clone() const override
return copy of object
Definition AdaptiveSimulatorTimer.cpp:183
Opm::AdaptiveSimulatorTimer::lastStepFailed
bool lastStepFailed() const override
Return true if last time step failed.
Definition AdaptiveSimulatorTimer.hpp:110
Opm::AdaptiveSimulatorTimer::initialStep
bool initialStep() const override
Whether this is the first step.
Definition AdaptiveSimulatorTimer.cpp:63
Opm::AdaptiveSimulatorTimer::provideTimeStepEstimate
void provideTimeStepEstimate(const double dt_estimate)
provide and estimate for new time step size
Definition AdaptiveSimulatorTimer.cpp:79
Opm::AdaptiveSimulatorTimer::startDateTime
boost::posix_time::ptime startDateTime() const override
start date time of simulation
Definition AdaptiveSimulatorTimer.cpp:176
Opm::AdaptiveSimulatorTimer::report
void report(std::ostream &os) const
report start and end time as well as used steps so far
Definition AdaptiveSimulatorTimer.cpp:166
Opm::AdaptiveSimulatorTimer::setLastStepFailed
void setLastStepFailed(bool last_step_failed)
tell the timestepper whether timestep failed or not
Definition AdaptiveSimulatorTimer.hpp:113
Opm::AdaptiveSimulatorTimer::totalTime
double totalTime() const
Definition AdaptiveSimulatorTimer.cpp:135
Opm::AdaptiveSimulatorTimer::currentStepLength
double currentStepLength() const override
Definition AdaptiveSimulatorTimer.cpp:115
Opm::AdaptiveSimulatorTimer::AdaptiveSimulatorTimer
AdaptiveSimulatorTimer(const boost::posix_time::ptime simulation_start_time, const double step_length, const double elapsed_time, const double last_step_taken, const int report_step, const double max_time_step=std::numeric_limits< double >::max())
constructor taking a simulator timer to determine start and end time
Definition AdaptiveSimulatorTimer.cpp:39
Opm::AdaptiveSimulatorTimer::done
bool done() const override
Definition AdaptiveSimulatorTimer.cpp:139
Opm::AdaptiveSimulatorTimer::currentStepNum
int currentStepNum() const override
Definition AdaptiveSimulatorTimer.cpp:110
Opm::AdaptiveSimulatorTimer::averageStepLength
double averageStepLength() const
return average step length used so far
Definition AdaptiveSimulatorTimer.cpp:141
Opm::AdaptiveSimulatorTimer::reportStepNum
int reportStepNum() const override
return current report step
Definition AdaptiveSimulatorTimer.cpp:113
Opm::AdaptiveSimulatorTimer::maxStepLength
double maxStepLength() const
return max step length used so far
Definition AdaptiveSimulatorTimer.cpp:151
Opm::AdaptiveSimulatorTimer::operator++
AdaptiveSimulatorTimer & operator++()
advance time by currentStepLength
Definition AdaptiveSimulatorTimer.cpp:68
Opm::AdaptiveSimulatorTimer::simulationTimeElapsed
double simulationTimeElapsed() const override
Definition AdaptiveSimulatorTimer.cpp:137
Opm::SimulatorTimerInterface::SimulatorTimerInterface
SimulatorTimerInterface()
Default constructor, protected to not allow explicit instances of this class.
Definition SimulatorTimerInterface.hpp:37
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43