336 : m_t0(
time[0]), m_t1(
time[1]), m_dt(
time[2]), m_increment(0),
339 throw std::invalid_argument(
"Start time cannot be negative: " +
340 std::to_string(m_t0));
343 throw std::invalid_argument(
"Time step (dt) must be greater than zero: " +
344 std::to_string(m_dt));
347 throw std::invalid_argument(
"Time step (dt) is too small: " +
348 std::to_string(m_dt));
350 if (std::abs(m_t0 - m_t1) < 1e-9) {
351 throw std::invalid_argument(
"Start time cannot equal end time: t0 == t1");
353 if (m_saveat > m_t1) {
354 throw std::invalid_argument(
355 "Save interval cannot exceed end time: " + std::to_string(m_saveat) +
356 " > " + std::to_string(m_t1));
453 double get_current()
const {
543 return (get_current() >= m_t1 - 1e-9);
610 void next() { m_increment += 1; }
712 bool do_save()
const {
716 return (std::fmod(get_current() + 1.0e-9, m_saveat) < 1.e-6) || done() ||
725 operator double()
const {
return get_current(); }
735 os <<
"(t0 = " <<
t.m_t0 <<
", t1 = " <<
t.m_t1 <<
", dt = " <<
t.m_dt;
736 os <<
", saveat = " <<
t.m_saveat <<
", t_current = " <<
t.get_current()
void set_increment(int increment)
Set the current time increment.
Definition time.hpp:471
void set_saveat(double saveat)
Set the time interval for saving data.
Definition time.hpp:478
double get_dt() const
Get the time step.
Definition time.hpp:390
double get_saveat() const
Get the time interval for saving data.
Definition time.hpp:464
int get_increment() const
Get the current time increment.
Definition time.hpp:397
Time(const std::array< double, 3 > &time)
Construct a new Time object with the specified time interval and default save interval.
Definition time.hpp:369
double get_t0() const
Get the start time.
Definition time.hpp:376
friend std::ostream & operator<<(std::ostream &os, const Time &t)
Overloaded stream insertion operator to print the Time object.
Definition time.hpp:734
double get_t1() const
Get the end time.
Definition time.hpp:383
Represents the global simulation domain (the "world").
Definition world.hpp:91