Flow123d  DF_patch_fe_data_tables-3c41206
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TimeStep Class Reference

Representation of one time step.. More...

#include <time_governor.hh>

Public Member Functions

 TimeStep (double init_time, std::shared_ptr< TimeUnitConversion > time_unit_conversion=std::make_shared< TimeUnitConversion >())
 
 TimeStep ()
 
 TimeStep (const TimeStep &other)
 
TimeStep make_next (double new_length) const
 
TimeStep make_next (double new_lenght, double end_time) const
 
unsigned int index () const
 
double length () const
 
double end () const
 
bool gt (double other_time) const
 
bool ge (double other_time) const
 
bool lt (double other_time) const
 
bool le (double other_time) const
 
bool eq (double other_time) const
 
bool contains (double other_time) const
 
double read_time (Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
 
double read_coef (Input::Iterator< Input::Record > unit_it) const
 
double get_coef () const
 
std::shared_ptr< TimeUnitConversionget_unit_conversion () const
 Getter for time unit conversion object. More...
 
bool operator== (const TimeStep &other)
 

Private Member Functions

bool safe_compare (double t1, double t0) const
 

Private Attributes

unsigned int index_
 Index of the step is index if the end time. Zero time step is artificial. More...
 
double length_
 
double end_
 End time point of the time step. More...
 
std::shared_ptr< TimeUnitConversiontime_unit_conversion_
 Conversion unit of all time values within the equation. More...
 

Detailed Description

Representation of one time step..

Time step consists of the time step length() and from time step @end() time. More over we store the index of the time step within it time governor.

The reason to store both the end time and the length of the time step is to allow safe comparisons of the time with safety margin small relative to the time step length.

Definition at line 123 of file time_governor.hh.

Constructor & Destructor Documentation

◆ TimeStep() [1/3]

TimeStep::TimeStep ( double  init_time,
std::shared_ptr< TimeUnitConversion time_unit_conversion = std::make_shared<TimeUnitConversion>() 
)

Constructor of the zero time step.

Definition at line 203 of file time_governor.cc.

◆ TimeStep() [2/3]

TimeStep::TimeStep ( )

Default constructor. Creates undefined time step.

Definition at line 212 of file time_governor.cc.

◆ TimeStep() [3/3]

TimeStep::TimeStep ( const TimeStep other)

Copy constructor.

Definition at line 223 of file time_governor.cc.

Member Function Documentation

◆ contains()

bool TimeStep::contains ( double  other_time) const
inline

Definition at line 194 of file time_governor.hh.

Here is the caller graph for this function:

◆ end()

double TimeStep::end ( ) const
inline

Definition at line 161 of file time_governor.hh.

Here is the caller graph for this function:

◆ eq()

bool TimeStep::eq ( double  other_time) const
inline

Definition at line 191 of file time_governor.hh.

Here is the caller graph for this function:

◆ ge()

bool TimeStep::ge ( double  other_time) const
inline

Definition at line 173 of file time_governor.hh.

Here is the caller graph for this function:

◆ get_coef()

double TimeStep::get_coef ( ) const

Return global time unit coefficient of equation. Shortcut for time_unit_conversion_ function.

Definition at line 271 of file time_governor.cc.

◆ get_unit_conversion()

std::shared_ptr< TimeUnitConversion > TimeStep::get_unit_conversion ( ) const

Getter for time unit conversion object.

Definition at line 277 of file time_governor.cc.

◆ gt()

TimeStep::gt ( double  other_time) const
inline

Performs rounding safe comparison time > other_time, i.e. time is strictly greater than given parameter other_time with precision relative to the magnitude of the numbers time step. TODO: introduce type TimeDouble with overloaded comparison operators, use it consistently in TimeMarks.

Performs rounding safe comparison time >= other_time See

Performs rounding safe comparison time < other_time. See

Performs rounding safe comparison time <= other_time. See

Performs rounding safe comparison time (step) == other_time. See

Definition at line 167 of file time_governor.hh.

◆ index()

unsigned int TimeStep::index ( ) const
inline

Getters.

Definition at line 159 of file time_governor.hh.

Here is the caller graph for this function:

◆ le()

bool TimeStep::le ( double  other_time) const
inline

Definition at line 185 of file time_governor.hh.

Here is the caller graph for this function:

◆ length()

double TimeStep::length ( ) const
inline

Definition at line 160 of file time_governor.hh.

Here is the caller graph for this function:

◆ lt()

bool TimeStep::lt ( double  other_time) const
inline

Definition at line 179 of file time_governor.hh.

Here is the caller graph for this function:

◆ make_next() [1/2]

TimeStep TimeStep::make_next ( double  new_lenght,
double  end_time 
) const

Create subsequent time step, with the @end_time explicitly specified. This allow slight discrepancy to overcome rounding errors in the case of fixed time step. Otherwise using small fixed time step, we may miss long term fixed goal time.

Definition at line 239 of file time_governor.cc.

◆ make_next() [2/2]

TimeStep TimeStep::make_next ( double  new_length) const

Create subsequent time step.

Definition at line 232 of file time_governor.cc.

◆ operator==()

bool TimeStep::operator== ( const TimeStep other)
inline

Returns true if two time steps are exactly the same.

Definition at line 224 of file time_governor.hh.

◆ read_coef()

double TimeStep::read_coef ( Input::Iterator< Input::Record unit_it) const

Read and return time unit coefficient given in unit_it or global coefficient of equation stored in time_unit_conversion_, if iterator is not defined. Shortcut for time_unit_conversion_ function.

Definition at line 265 of file time_governor.cc.

Here is the caller graph for this function:

◆ read_time()

double TimeStep::read_time ( Input::Iterator< Input::Tuple time_it,
double  default_time = std::numeric_limits<double>::quiet_NaN() 
) const

Read and return time value multiplied by coefficient of given unit or global coefficient of equation stored in time_unit_conversion_. If time Tuple is not defined (e. g. Tuple is optional key) return default_time value. Shortcut for time_unit_conversion_ function.

Definition at line 259 of file time_governor.cc.

Here is the caller graph for this function:

◆ safe_compare()

bool TimeStep::safe_compare ( double  t1,
double  t0 
) const
private

Definition at line 251 of file time_governor.cc.

Here is the caller graph for this function:

Member Data Documentation

◆ end_

double TimeStep::end_
private

End time point of the time step.

Definition at line 242 of file time_governor.hh.

◆ index_

unsigned int TimeStep::index_
private

Index of the step is index if the end time. Zero time step is artificial.

Definition at line 237 of file time_governor.hh.

◆ length_

double TimeStep::length_
private

Length of the time step. Theoretically end minus end of the previous time step. However may be slightly different due to rounding errors.

Definition at line 240 of file time_governor.hh.

◆ time_unit_conversion_

std::shared_ptr<TimeUnitConversion> TimeStep::time_unit_conversion_
private

Conversion unit of all time values within the equation.

Definition at line 244 of file time_governor.hh.


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