00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OPM_ADAPTIVESIMULATORTIMER_HEADER_INCLUDED
00020 #define OPM_ADAPTIVESIMULATORTIMER_HEADER_INCLUDED
00021
00022 #include <cassert>
00023 #include <iostream>
00024 #include <vector>
00025
00026 #include <algorithm>
00027 #include <numeric>
00028
00029 #include <opm/simulators/timestepping/SimulatorTimerInterface.hpp>
00030
00031 namespace Opm
00032 {
00033
00039 class AdaptiveSimulatorTimer : public SimulatorTimerInterface
00040 {
00041 public:
00046 AdaptiveSimulatorTimer( const SimulatorTimerInterface& timer,
00047 const double lastStepTaken,
00048 const double maxTimeStep = std::numeric_limits<double>::max() );
00049
00051 AdaptiveSimulatorTimer& operator++ ();
00052
00054 void advance() { this->operator++ (); }
00055
00057 void provideTimeStepEstimate( const double dt_estimate );
00058
00060 bool initialStep () const;
00061
00063 int currentStepNum () const;
00064
00066 int reportStepNum() const;
00067
00069 double currentStepLength () const;
00070
00072 double totalTime() const;
00073
00075 double simulationTimeElapsed() const;
00076
00078 bool done () const;
00079
00081 double averageStepLength() const;
00082
00084 double maxStepLength () const;
00085
00087 double minStepLength () const;
00088
00091 double stepLengthTaken () const;
00092
00094 void report(std::ostream& os) const;
00095
00097 boost::posix_time::ptime startDateTime() const;
00098
00100 bool lastStepFailed() const {return lastStepFailed_;}
00101
00103 void setLastStepFailed(bool lastStepFailed) {lastStepFailed_ = lastStepFailed;}
00104
00106 virtual std::unique_ptr< SimulatorTimerInterface > clone() const;
00107
00108 protected:
00109 const boost::posix_time::ptime start_date_time_;
00110 const double start_time_;
00111 const double total_time_;
00112 const int report_step_;
00113 const double max_time_step_;
00114
00115 double current_time_;
00116 double dt_;
00117 int current_step_;
00118
00119 std::vector< double > steps_;
00120 bool lastStepFailed_;
00121
00122 };
00123
00124 }
00125
00126 #endif // OPM_SIMULATORTIMER_HEADER_INCLUDED