opm-simulators
Opm::AdaptiveSimulatorTimer Class Reference

Simulation timer for adaptive time stepping. More...

#include <AdaptiveSimulatorTimer.hpp>

Inheritance diagram for Opm::AdaptiveSimulatorTimer:
Opm::SimulatorTimerInterface

Public Member Functions

 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 More...
 
AdaptiveSimulatorTimeroperator++ ()
 advance time by currentStepLength
 
void advance () override
 advance time by currentStepLength
 
void provideTimeStepEstimate (const double dt_estimate)
 provide and estimate for new time step size
 
bool initialStep () const override
 Whether this is the first step.
 
int currentStepNum () const override
 
int reportStepNum () const override
 return current report step
 
double currentStepLength () const override
 
void setCurrentStepLength (double dt)
 
double totalTime () const
 
double simulationTimeElapsed () const override
 
bool done () const override
 
double averageStepLength () const
 return average step length used so far
 
double maxStepLength () const
 return max step length used so far
 
double minStepLength () const
 return min step length used so far
 
double stepLengthTaken () const override
 Previous step length. More...
 
void report (std::ostream &os) const
 report start and end time as well as used steps so far
 
boost::posix_time::ptime startDateTime () const override
 start date time of simulation
 
bool lastStepFailed () const override
 Return true if last time step failed.
 
void setLastStepFailed (bool last_step_failed)
 tell the timestepper whether timestep failed or not
 
double reportStepStartTime () const
 Reservoir coupling constructs a fresh timer per sync chunk, so start_time_, total_time_, and current_step_ describe the chunk rather than the enclosing report step. More...
 
double reportStepTotalTime () const
 
int reportStepSubstepNum () const
 
void setReportStepStartTime (double t)
 
void setReportStepTotalTime (double t)
 
void setReportStepSubstepOffset (int n)
 
int reportStepSubstepOffset () const
 
std::unique_ptr< SimulatorTimerInterfaceclone () const override
 return copy of object
 
- Public Member Functions inherited from Opm::SimulatorTimerInterface
virtual ~SimulatorTimerInterface ()
 destructor
 
virtual boost::posix_time::ptime currentDateTime () const
 Return the current time as a posix time object.
 
virtual time_t currentPosixTime () const
 Time elapsed since the start of the POSIX epoch (Jan 1st, 1970) until the current time step begins [s]. More...
 
virtual double reportStepLengthTaken () const
 Previous report step length. More...
 

Protected Attributes

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_
 
std::optional< double > report_step_start_time_
 Optional report-step start time for the "report step view" accessors. More...
 
std::optional< double > report_step_total_time_
 Optional report-step end time for the "report step view" accessors. More...
 
int report_step_substep_offset_ = 0
 Number of substeps already taken in this report step before this timer was constructed (i.e. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Opm::SimulatorTimerInterface
 SimulatorTimerInterface ()
 Default constructor, protected to not allow explicit instances of this class.
 

Detailed Description

Simulation timer for adaptive time stepping.

Constructor & Destructor Documentation

◆ AdaptiveSimulatorTimer()

Opm::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

Parameters
simulation_start_timeStart time for simulation
step_lengthTime step length
elapsed_timeCurrent elapsed time
last_step_takenLast suggested time step
report_stepCurrent report step index
max_time_stepmaximum time step allowed

Member Function Documentation

◆ currentStepLength()

double Opm::AdaptiveSimulatorTimer::currentStepLength ( ) const
overridevirtual

◆ currentStepNum()

int Opm::AdaptiveSimulatorTimer::currentStepNum ( ) const
overridevirtual

◆ done()

bool Opm::AdaptiveSimulatorTimer::done ( ) const
overridevirtual

◆ reportStepStartTime()

double Opm::AdaptiveSimulatorTimer::reportStepStartTime ( ) const

Reservoir coupling constructs a fresh timer per sync chunk, so start_time_, total_time_, and current_step_ describe the chunk rather than the enclosing report step.

The accessors below return a "report step view" that the rescoup outer loop populates (via the setters) so that log lines can show the report-step start and end and a substep counter that increments across chunks. When the view is not set, they fall through to the per-timer fields, so the non-rescoup path's behavior and output are unchanged.

◆ simulationTimeElapsed()

double Opm::AdaptiveSimulatorTimer::simulationTimeElapsed ( ) const
overridevirtual

◆ stepLengthTaken()

double Opm::AdaptiveSimulatorTimer::stepLengthTaken ( ) const
overridevirtual

Previous step length.

This is the length of the step that was taken to arrive at this time.

Implements Opm::SimulatorTimerInterface.

◆ totalTime()

double Opm::AdaptiveSimulatorTimer::totalTime ( ) const

Member Data Documentation

◆ report_step_start_time_

std::optional<double> Opm::AdaptiveSimulatorTimer::report_step_start_time_
protected

Optional report-step start time for the "report step view" accessors.

Set by the rescoup outer loop on each per-sync-chunk timer; unset on a non-rescoup timer.

◆ report_step_substep_offset_

int Opm::AdaptiveSimulatorTimer::report_step_substep_offset_ = 0
protected

Number of substeps already taken in this report step before this timer was constructed (i.e.

in earlier sync chunks). Added to current_step_ by reportStepSubstepNum() to give a counter that increments across sync chunks. Zero on a non-rescoup timer.

◆ report_step_total_time_

std::optional<double> Opm::AdaptiveSimulatorTimer::report_step_total_time_
protected

Optional report-step end time for the "report step view" accessors.

Same population pattern as report_step_start_time_.


The documentation for this class was generated from the following files: