AdaptiveSimulatorTimer.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2014 IRIS AS
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef OPM_ADAPTIVESIMULATORTIMER_HEADER_INCLUDED
20 #define OPM_ADAPTIVESIMULATORTIMER_HEADER_INCLUDED
21 
22 #include <cassert>
23 #include <iostream>
24 #include <vector>
25 
26 #include <algorithm>
27 #include <numeric>
28 
30 
31 namespace Opm
32 {
33 
40  {
41  public:
47  const double lastStepTaken,
48  const double maxTimeStep = std::numeric_limits<double>::max() );
49 
52 
54  void advance() { this->operator++ (); }
55 
57  void provideTimeStepEstimate( const double dt_estimate );
58 
60  int currentStepNum () const;
61 
63  int reportStepNum() const;
64 
66  double currentStepLength () const;
67 
69  double totalTime() const;
70 
72  double simulationTimeElapsed() const;
73 
75  bool done () const;
76 
78  double averageStepLength() const;
79 
81  double maxStepLength () const;
82 
84  double minStepLength () const;
85 
88  double stepLengthTaken () const;
89 
91  void report(std::ostream& os) const;
92 
94  boost::posix_time::ptime startDateTime() const;
95 
96  protected:
97  const boost::posix_time::ptime start_date_time_;
98  const double start_time_;
99  const double total_time_;
100  const int report_step_;
101  const double max_time_step_;
102 
104  double dt_;
106 
107  std::vector< double > steps_;
108  };
109 
110 } // namespace Opm
111 
112 #endif // OPM_SIMULATORTIMER_HEADER_INCLUDED
Definition: AnisotropicEikonal.hpp:43
const double total_time_
Definition: AdaptiveSimulatorTimer.hpp:99
AdaptiveSimulatorTimer(const SimulatorTimerInterface &timer, const double lastStepTaken, const double maxTimeStep=std::numeric_limits< double >::max())
constructor taking a simulator timer to determine start and end time
double simulationTimeElapsed() const
void report(std::ostream &os) const
report start and end time as well as used steps so far
double maxStepLength() const
return max step length used so far
void provideTimeStepEstimate(const double dt_estimate)
provide and estimate for new time step size
const int report_step_
Definition: AdaptiveSimulatorTimer.hpp:100
boost::posix_time::ptime startDateTime() const
start date time of simulation
double stepLengthTaken() const
Previous step length. This is the length of the step that was taken to arrive at this time...
Simulation timer for adaptive time stepping.
Definition: AdaptiveSimulatorTimer.hpp:39
double currentStepLength() const
double averageStepLength() const
return average step length used so far
double current_time_
Definition: AdaptiveSimulatorTimer.hpp:103
AdaptiveSimulatorTimer & operator++()
advance time by currentStepLength
Interface class for SimulatorTimer objects, to be improved.
Definition: SimulatorTimerInterface.hpp:33
const boost::posix_time::ptime start_date_time_
Definition: AdaptiveSimulatorTimer.hpp:97
double minStepLength() const
return min step length used so far
int reportStepNum() const
return current report step
int current_step_
Definition: AdaptiveSimulatorTimer.hpp:105
void advance()
advance time by currentStepLength
Definition: AdaptiveSimulatorTimer.hpp:54
const double start_time_
Definition: AdaptiveSimulatorTimer.hpp:98
double dt_
Definition: AdaptiveSimulatorTimer.hpp:104
std::vector< double > steps_
Definition: AdaptiveSimulatorTimer.hpp:107
const double max_time_step_
Definition: AdaptiveSimulatorTimer.hpp:101