25 #include <boost/circular_buffer.hpp> 75 TimeStep make_next(
double new_length)
const;
85 TimeStep make_next(
double new_lenght,
double end_time)
const;
90 unsigned int index()
const {
return index_;}
91 double length()
const {
return length_;}
92 double end()
const {
return end_;}
98 inline bool gt(
double other_time)
const 99 {
return ! safe_compare(other_time, end());}
104 inline bool ge(
double other_time)
const 105 {
return safe_compare(end(), other_time); }
110 inline bool lt(
double other_time)
const 111 {
return ! safe_compare(end(), other_time); }
116 inline bool le(
double other_time)
const 117 {
return safe_compare(other_time, end()); }
122 inline bool eq(
double other_time)
const 123 {
return this->le(other_time) && this->ge(other_time); }
126 {
return this->ge(other_time) && this->lt(other_time + length_); }
132 {
return (index_ == other.
index_)
134 && (end_ == other.
end_);
141 bool safe_compare(
double t1,
double t0)
const;
224 <<
"Time step index: " << EI_Index::val
225 <<
", history index: " << EI_BackIndex::val
226 <<
" out of history of size: " << EI_HistorySize::val);
234 {
return time_marks_;}
279 void set_permanent_constraint(
double min_dt,
double max_dt);
292 int set_upper_constraint(
double upper, std::string message);
311 int set_lower_constraint(
double lower, std::string message);
320 double fix_dt_until_mark();
337 double reduce_timestep(
double factor);
347 const TimeStep &step(
int index=-1)
const;
353 {
return eq_mark_type_;}
359 {
return eq_mark_type_ | marks().type_fixed_time(); }
377 {
return time_marks_.next(*
this, mask);}
383 {
return time_marks_.last(*
this, mask);}
389 {
return upper_constraint_;}
395 {
return lower_constraint_;}
401 {
return end_of_fixed_dt_interval_;}
407 {
return time_step_changed_;}
414 {
return this->init_time_;}
419 inline double t()
const 420 {
return step().end();}
426 {
if (step().index() >0)
return step(-2).length();
427 else return inf_time;
434 {
if (step().index() >0)
return step(-2).end();
435 else return step().end() - step().length();
442 inline double dt()
const 443 {
return step().length();}
459 double estimate_dt()
const;
465 {
return t()+estimate_dt();}
469 {
return end_time_; }
473 {
return (this->step().ge(end_time_) || t() == inf_time); }
485 {
return step().index();}
492 void view(
const char *name=
"")
const;
514 void init_common(
double init_time,
double end_time,
TimeMark::Type type);
519 static const unsigned int size_of_recent_steps_ = 3;
bool operator==(const TimeStep &other)
double init_time_
Initial time.
double lower_constraint_
Lower constraint for the choice of the next time step.
Iterator over TimeMark objects in TimeMarks object (database of TimeMark objects).
double end_time() const
End time.
double estimate_time() const
bool is_time_step_fixed_
Flag that is set when the fixed step is set (lasts only one time step).
boost::circular_buffer< TimeStep > recent_steps_
Circular buffer of recent time steps. Implicit size is 3.
static TimeMarks time_marks_
bool lt(double other_time) const
double upper_constraint() const
double end_time_
End time of the simulation.
bool contains(double other_time) const
bool is_end() const
Returns true if the actual time is greater than or equal to the end time.
TimeMarks::iterator last(const TimeMark::Type &mask) const
TimeMarks::iterator next(const TimeMark::Type &mask) const
double end_of_fixed_dt() const
Basic time management functionality for unsteady (and steady) solvers (class Equation).
static const Type none_type
Mark Type with all bits unset.
static TimeMarks & marks()
bool time_step_changed_
Flag is set if the time step has been changed (lasts only one time step).
bool le(double other_time) const
double upper_constraint_
Upper constraint for the choice of the next time step.
TimeMark::Type eq_mark_type_
TimeMark type of the equation.
Global macros to enhance readability and debugging, general constants.
bool ge(double other_time) const
static const double time_step_precision
TimeMark::Type equation_fixed_mark_type() const
TimeMark::Type equation_mark_type() const
bool is_changed_dt() const
double last_lower_constraint_
Lower constraint used for choice of current time.
double lower_constraint() const
unsigned int index_
Index of the step is index if the end time. Zero time step is artificial.
This class is a collection of time marks to manage various events occurring during simulation time...
double end_of_fixed_dt_interval_
End of interval if fixed time step.
bool steady_
True if the time governor is used for steady problem.
bool is_steady() const
Returns true if the time governor is used for steady problem.
double max_time_step_
Permanent upper limit for the time step.
std::string upper_constraint_message_
Description of the upper constraint.
bool gt(double other_time) const
unsigned int index() const
double fixed_time_step_
Next fixed time step.
double last_upper_constraint_
Upper constraint used for choice of current time.
static const double inf_time
Infinity time used for steady case.
Representation of one time step..
double end_
End time point of the time step.
std::string lower_constraint_message_
Description of the upper constraint.
bool eq(double other_time) const
double min_time_step_
Permanent lower limit for the time step.