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
 
TimeStepoperator= (const TimeStep &src)=default
 copy a time step
 
TimeStepoperator+= (const double dt)
 increment time step
 
bool operator< (TimeStep const &ts) const
 compare current time
 
bool operator<= (TimeStep const &ts) const
 compare current time
 
bool operator== (TimeStep const &ts) const
 compare current time
 
double previous () const
 return previous time step
 
double current () const
 return current time step
 
double dt () const
 time step size from _previous
 
std::size_t timeStepNumber () const
 the time step number
 
void setAccepted (bool const accepted)
 
bool isAccepted () const
 

Private Attributes

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

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

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