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()); }
123 {
return (index_ == other.
index_)
125 && (end_ == other.
end_);
132 bool safe_compare(
double t1,
double t0)
const;
213 <<
"Time step index: " << EI_Index::val
214 <<
", history index: " << EI_BackIndex::val
215 <<
" out of history of size: " << EI_HistorySize::val);
223 {
return time_marks_;}
268 void set_permanent_constraint(
double min_dt,
double max_dt);
281 int set_upper_constraint(
double upper, std::string message);
300 int set_lower_constraint(
double lower, std::string message);
309 double fix_dt_until_mark();
326 double reduce_timestep(
double factor);
336 const TimeStep &step(
int index=-1)
const;
342 {
return eq_mark_type_;}
348 {
return eq_mark_type_ | marks().type_fixed_time(); }
360 {
return time_marks_.is_current(*
this, equation_mark_type() | mask); }
366 {
return time_marks_.next(*
this, mask);}
372 {
return time_marks_.last(*
this, mask);}
378 {
return upper_constraint_;}
384 {
return lower_constraint_;}
390 {
return end_of_fixed_dt_interval_;}
396 {
return time_step_changed_;}
403 {
return this->init_time_;}
408 inline double t()
const 409 {
return step().end();}
415 {
if (step().index() >0)
return step(-2).length();
416 else return inf_time;
423 {
if (step().index() >0)
return step(-2).end();
424 else return step().end() - step().length();
431 inline double dt()
const 432 {
return step().length();}
448 double estimate_dt()
const;
454 {
return t()+estimate_dt();}
458 {
return end_time_; }
462 {
return (this->step().ge(end_time_) || t() == inf_time); }
474 {
return step().index();}
481 void view(
const char *name=
"")
const;
497 void init_common(
double init_time,
double end_time,
TimeMark::Type type);
508 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 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
bool is_current(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.
double min_time_step_
Permanent lower limit for the time step.