#include <clock.h>
Clock with uniformly spaced time steps.
This clock stores a time step size \(\Delta t\), a base time \(t_0\) as well as an end time \(t_{end}\) and 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 to the present time and \(n\) is set to 0. As soon as \(t\geq t_{end}\), the clock will always return \(t_{end}\) as current and next time. The time step size can be retrieved and the returned value is
\[ \begin{aligned} \Delta t \qquad&\mbox{if}& &t\leq t_{end}-\Delta t \\ t_{end}-t \qquad&\mbox{if}& t_{end}-\Delta t<{}&t<t_{end} \\ 0.0 \qquad&\mbox{if}& &t\geq t_{end} \\ \end{aligned} \]
In the last case, i.e. if the time step size is required when the clock ticked beyond the simulation end, a warning is given to the user.
Public Member Functions | |
UniformClock ()=default | |
default initializer: Timestep size is set to 0! More... | |
UniformClock (double time, double dt, 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 (double dt) |
Sets the time step size (and resets the counter). More... | |
void | reset (double start_time, 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... | |
Public Member Functions inherited from smash::Clock | |
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 internal times of two clocks. More... | |
bool | operator< (double time) const |
Compares the internal time of the clock against a fixed time. More... | |
bool | operator> (double time) const |
Compares the internal time of the clock against a fixed time. More... | |
virtual | ~Clock ()=default |
Protected Member Functions | |
double | present_internal_time () const override |
Access the internal time of the clock, independently from the end time. More... | |
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_ = 0 |
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 (namely the smallest representable time difference). More... | |
static constexpr double | to_double = resolution |
A multiplier transferring the internal integer to the real time. More... | |
static constexpr double | from_double = 1. / resolution |
A multiplier transferring the real time to the internal integer. More... | |
Additional Inherited Members | |
Public Types inherited from smash::Clock | |
using | Representation = std::int64_t |
The type used for counting ticks/time. More... | |
Protected Attributes inherited from smash::Clock | |
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 234 of file clock.h.
|
inlineoverridevirtual |
Implements smash::Clock.
Definition at line 252 of file clock.h.
|
inlineoverridevirtual |
Implements smash::Clock.
Definition at line 269 of file clock.h.
|
inlineoverridevirtual |
Implements smash::Clock.
Definition at line 288 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 320 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 | Time step by which the clock is advanced. |
Definition at line 348 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. |
|
inlineoverrideprotectedvirtual |
Access the internal time of the clock, independently from the end time.
Implements smash::Clock.
|
inlinestaticprivate |
Convert a double x
into the internal int representation.
Definition at line 389 of file clock.h.
|
inlinestaticprivate |
Convert an internal int value x
into the double representation.
Definition at line 393 of file clock.h.
|
staticconstexprprivate |
Defines the resolution of the clock (namely the smallest representable time difference).
The value 0.000001 is very well suited because
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
|
private |
|
private |