#include <clock.h>
Clock with uniformly spaced time steps.
Clock stores a time step size \(\Delta t\) and a base time \(t_0\) as well as a counter \(n\). The current time is calculated from \(t = t_0 + n \cdot \Delta t\). When \(\Delta t\) is changed, \(t_0\) is reset.
Public Member Functions | |
UniformClock ()=default | |
default initializer: Timestep size is set to 0! More... | |
UniformClock (const double time, const double dt, const double time_end) | |
Initialize with base time and time step size. More... | |
double | current_time () const override |
double | next_time () const override |
double | timestep_duration () const override |
void | set_timestep_duration (const double dt) |
Sets the time step size (and resets the counter). More... | |
void | reset (const double start_time, const bool is_output_clock) override |
Resets the time to the starting time of an event. More... | |
void | remove_times_in_past (double) override |
Remove output times before the starting time of the simulation if this is a custom clock. More... | |
template<typename T > | |
std::enable_if< std::is_floating_point< T >::value, Clock & >::type | operator+= (T big_timestep) |
Advances the clock by an arbitrary timestep (multiple of 0.000001 fm). More... | |
Clock & | operator+= (Representation advance_several_timesteps) |
advances the clock by an arbitrary number of ticks. More... | |
![]() | |
Clock & | operator++ () |
Advances the clock by one tick. More... | |
Clock & | operator+= (Representation advance_several_timesteps) |
Advances the clock by an arbitrary number of ticks. More... | |
bool | operator< (const Clock &rhs) const |
Compares the times between two clocks. More... | |
bool | operator< (double time) const |
Compares the time of the clock against a fixed time. More... | |
bool | operator> (double time) const |
Compares the time of the clock against a fixed time. More... | |
virtual | ~Clock ()=default |
Static Private Member Functions | |
static Representation | convert (double x) |
Convert a double x into the internal int representation. More... | |
static double | convert (Representation x) |
Convert an internal int value x into the double representation. More... | |
Private Attributes | |
Representation | timestep_duration_ = 0u |
The time step size \(\Delta t\) in \(10^{-6}\,\mathrm{fm}\). More... | |
Representation | reset_time_ = 0 |
The time of last reset (when counter_ was set to 0). More... | |
Representation | time_end_ = 0 |
The end time of the particle propagation. More... | |
Static Private Attributes | |
static constexpr double | resolution = 0.000001 |
Defines the resolution of the clock (i.e. More... | |
static constexpr double | to_double = resolution |
A multiplier transfering the internal integer to the real time. More... | |
static constexpr double | from_double = 1. / resolution |
A multiplier transfering the real time to the internal integer. More... | |
Additional Inherited Members | |
![]() | |
using | Representation = std::int64_t |
The type used for counting ticks/time. More... | |
![]() | |
Representation | counter_ = 0 |
Internally used to count the number of time steps. More... | |
|
default |
default initializer: Timestep size is set to 0!
|
inline |
Initialize with base time and time step size.
[in] | time | base time |
[in] | dt | step size |
[in] | time_end | end time of particle propagation |
Definition at line 200 of file clock.h.
|
inlineoverridevirtual |
Implements smash::Clock.
Definition at line 209 of file clock.h.
|
inlineoverridevirtual |
This function is needed, because current_time() + timestep_duration() is not the same as the next tick (numerically; this is due to floating point arithmetic).
Implements smash::Clock.
Definition at line 223 of file clock.h.
|
inlineoverridevirtual |
Implements smash::Clock.
Definition at line 235 of file clock.h.
|
inline |
|
inlineoverridevirtual |
Resets the time to the starting time of an event.
[in] | start_time | Starting time of the simulation |
[in] | is_output_clock | whether this is an output clock or a lab clock |
Implements smash::Clock.
Definition at line 264 of file clock.h.
|
inlineoverridevirtual |
Remove output times before the starting time of the simulation if this is a custom clock.
[in] | start_time | starting time of the simulation |
Implements smash::Clock.
|
inline |
Advances the clock by an arbitrary timestep (multiple of 0.000001 fm).
T | type of the timestep |
[in] | big_timestep | Timestep by which the clock is advanced. |
Definition at line 292 of file clock.h.
|
inline |
advances the clock by an arbitrary number of ticks.
[in] | advance_several_timesteps | Number of the timesteps added to the clock |
OverflowError | if the number of the added timesteps exceeds the maximum value. |
|
inlinestaticprivate |
Convert a double x
into the internal int representation.
Definition at line 323 of file clock.h.
|
inlinestaticprivate |
Convert an internal int value x
into the double representation.
Definition at line 327 of file clock.h.
|
staticconstexprprivate |
Defines the resolution of the clock (i.e.
the smallest representable time difference).
The value 0.000001 is very well suited because
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
|
private |
|
private |