 |
Version: SMASH-1.8
|
|
Go to the documentation of this file.
10 #ifndef SRC_INCLUDE_CLOCK_H_
11 #define SRC_INCLUDE_CLOCK_H_
24 static constexpr
int LClock = LogArea::Clock::id;
87 virtual void reset(
double start_time,
const bool is_output_clock) = 0;
105 if (
counter_ >= std::numeric_limits<Representation>::max() - 1) {
106 throw std::overflow_error(
"Too many timesteps, clock overflow imminent");
121 if (
counter_ >= std::numeric_limits<Representation>::max() -
122 advance_several_timesteps) {
123 throw std::overflow_error(
"Too many timesteps, clock overflow imminent");
125 counter_ += advance_several_timesteps;
152 virtual ~Clock() =
default;
199 throw std::range_error(
"No negative time increment allowed");
216 throw std::overflow_error(
"Too many timesteps, clock overflow imminent");
231 throw std::range_error(
"No negative time increment allowed");
244 void reset(
const double start_time,
const bool is_output_clock)
override {
246 if (is_output_clock) {
250 reset_time = start_time;
254 reset_time,
" fm/c");
270 template <
typename T>
271 typename std::enable_if<std::is_floating_point<T>::value,
Clock&>::type
273 if (big_timestep < 0.) {
274 throw std::range_error(
"The clock cannot be turned back.");
288 if (
counter_ >= std::numeric_limits<Representation>::max() -
289 advance_several_timesteps) {
290 throw std::overflow_error(
"Too many timesteps, clock overflow imminent");
292 counter_ += advance_several_timesteps;
333 throw std::runtime_error(
"Trying to access undefined zeroth output time");
351 [start_time](
double t) {
352 if (t <= start_time) {
353 logg[
LClock].warn(
"Removing custom output time ", t,
354 " fm since it is earlier than the "
355 "starting time of the simulation");
369 #endif // SRC_INCLUDE_CLOCK_H_
double current_time() const override
static constexpr int LClock
bool operator>(double time) const
Compares the time of the clock against a fixed time.
double timestep_duration() const override
Representation counter_
Internally used to count the number of time steps.
virtual double timestep_duration() const =0
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
virtual void remove_times_in_past(double start_time)=0
Remove output times before the starting time of the simulation if this is a custom clock.
void remove_times_in_past(double start_time) override
Remove all custom times before start_time.
CustomClock(std::vector< double > times)
Initialises a custom clock with explicitly given output times.
bool operator<(double time) const
Compares the time of the clock against a fixed time.
Clock tracks the time in the simulation.
virtual void reset(double start_time, const bool is_output_clock)=0
reset the clock to the starting time of the simulation
void reset(double, bool) override
reset the clock to the starting time of the simulation
bool operator<(const Clock &rhs) const
Compares the times between two clocks.
Clock & operator+=(Representation advance_several_timesteps)
advances the clock by an arbitrary number of ticks.
virtual double next_time() const =0
std::vector< double > custom_times_
Vector of times where output is generated.
virtual double current_time() const =0
Clock with explicitly defined time steps.
double next_time() const override
std::int64_t Representation
The type used for counting ticks/time.
Clock & operator++()
Advances the clock by one tick.