OGS
NumLib::TimeStep Class Referencefinal

Detailed Description

Time step object.

TimeStep class contains previous time( \(t_{n}\)), current time ( \(t_{n+1}\)), time step length ( \(\Delta t_{n+1}\)), and the number of time steps ( \(n+1\)).

Definition at line 27 of file TimeStep.h.

#include <TimeStep.h>

Public Member Functions

 TimeStep (double current_time)
 
 TimeStep (double previous_time, double current_time, std::size_t n)
 
 TimeStep (const TimeStep &src)=default
 copy a time step More...
 
TimeStepoperator= (const TimeStep &src)=default
 copy a time step More...
 
TimeStepoperator+= (const double dt)
 increment time step More...
 
bool operator< (TimeStep const &ts) const
 compare current time More...
 
bool operator<= (TimeStep const &ts) const
 compare current time More...
 
bool operator== (TimeStep const &ts) const
 compare current time More...
 
double previous () const
 return previous time step More...
 
double current () const
 return current time step More...
 
double dt () const
 time step size from _previous More...
 
std::size_t timeStepNumber () const
 the time step number More...
 
void setAccepted (bool const accepted)
 
bool isAccepted () const
 

Private Attributes

double _previous
 previous time step More...
 
double _current
 current time step More...
 
double _dt
 time step size More...
 
std::size_t _time_step_number
 the number of time steps More...
 
bool _is_accepted = true
 is the timestep accepted More...
 

Constructor & Destructor Documentation

◆ TimeStep() [1/3]

NumLib::TimeStep::TimeStep ( double  current_time)
inlineexplicit

Initialize a time step

Parameters
current_timecurrent time

Definition at line 34 of file TimeStep.h.

35  : _previous(current_time),
36  _current(current_time),
39  {
40  }
double _current
current time step
Definition: TimeStep.h:103
double _previous
previous time step
Definition: TimeStep.h:101
std::size_t _time_step_number
the number of time steps
Definition: TimeStep.h:107
double _dt
time step size
Definition: TimeStep.h:105

◆ TimeStep() [2/3]

NumLib::TimeStep::TimeStep ( double  previous_time,
double  current_time,
std::size_t  n 
)
inline

Initialize a time step

Parameters
previous_timeprevious time
current_timecurrent time
nthe number of time steps

Definition at line 48 of file TimeStep.h.

49  : _previous(previous_time),
50  _current(current_time),
53  {
54  }

◆ TimeStep() [3/3]

NumLib::TimeStep::TimeStep ( const TimeStep src)
default

copy a time step

Member Function Documentation

◆ current()

double NumLib::TimeStep::current ( ) const
inline

return current time step

Definition at line 90 of file TimeStep.h.

90 { return _current; }

References _current.

Referenced by NumLib::FixedTimeStepping::next().

◆ dt()

◆ isAccepted()

bool NumLib::TimeStep::isAccepted ( ) const
inline

◆ operator+=()

TimeStep& NumLib::TimeStep::operator+= ( const double  dt)
inline

increment time step

Definition at line 63 of file TimeStep.h.

64  {
66  _current += dt;
67  _dt = dt;
69  return *this;
70  }
double dt() const
time step size from _previous
Definition: TimeStep.h:92

References _current, _dt, _previous, _time_step_number, and dt().

◆ operator<()

bool NumLib::TimeStep::operator< ( TimeStep const &  ts) const
inline

compare current time

Definition at line 73 of file TimeStep.h.

74  {
75  return (_current < ts._current);
76  }

References _current.

◆ operator<=()

bool NumLib::TimeStep::operator<= ( TimeStep const &  ts) const
inline

compare current time

Definition at line 78 of file TimeStep.h.

79  {
80  return (_current <= ts._current);
81  }

References _current.

◆ operator=()

TimeStep& NumLib::TimeStep::operator= ( const TimeStep src)
default

copy a time step

◆ operator==()

bool NumLib::TimeStep::operator== ( TimeStep const &  ts) const
inline

compare current time

Definition at line 83 of file TimeStep.h.

84  {
85  return (_current == ts._current);
86  }

References _current.

◆ previous()

double NumLib::TimeStep::previous ( ) const
inline

return previous time step

Definition at line 88 of file TimeStep.h.

88 { return _previous; }

References _previous.

Referenced by NumLib::IterationNumberBasedTimeStepping::next().

◆ setAccepted()

void NumLib::TimeStep::setAccepted ( bool const  accepted)
inline

Definition at line 96 of file TimeStep.h.

96 { _is_accepted = accepted; }

References _is_accepted.

Referenced by NumLib::EvolutionaryPIDcontroller::next().

◆ timeStepNumber()

std::size_t NumLib::TimeStep::timeStepNumber ( ) const
inline

Member Data Documentation

◆ _current

double NumLib::TimeStep::_current
private

current time step

Definition at line 103 of file TimeStep.h.

Referenced by current(), operator+=(), operator<(), operator<=(), and operator==().

◆ _dt

double NumLib::TimeStep::_dt
private

time step size

Definition at line 105 of file TimeStep.h.

Referenced by dt(), and operator+=().

◆ _is_accepted

bool NumLib::TimeStep::_is_accepted = true
private

is the timestep accepted

Definition at line 109 of file TimeStep.h.

Referenced by isAccepted(), and setAccepted().

◆ _previous

double NumLib::TimeStep::_previous
private

previous time step

Definition at line 101 of file TimeStep.h.

Referenced by operator+=(), and previous().

◆ _time_step_number

std::size_t NumLib::TimeStep::_time_step_number
private

the number of time steps

Definition at line 107 of file TimeStep.h.

Referenced by operator+=(), and timeStepNumber().


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