26 #include <boost/circular_buffer.hpp> 43 template<
class T>
class Iterator;
118 TimeStep(
double init_time, std::shared_ptr<TimeUnitConversion> time_unit_conversion = std::make_shared<TimeUnitConversion>());
134 TimeStep make_next(
double new_length)
const;
144 TimeStep make_next(
double new_lenght,
double end_time)
const;
149 unsigned int index()
const {
return index_;}
151 double end()
const {
return end_;}
157 inline bool gt(
double other_time)
const 158 {
return ! safe_compare(other_time, end());}
163 inline bool ge(
double other_time)
const 164 {
return safe_compare(end(), other_time); }
169 inline bool lt(
double other_time)
const 170 {
return ! safe_compare(end(), other_time); }
175 inline bool le(
double other_time)
const 176 {
return safe_compare(other_time, end()); }
181 inline bool eq(
double other_time)
const 182 {
return this->le(other_time) && this->ge(other_time); }
185 {
return this->ge(other_time) && this->lt(other_time + length_); }
203 double get_coef()
const;
209 {
return (index_ == other.
index_)
211 && (end_ == other.
end_);
218 bool safe_compare(
double t1,
double t0)
const;
303 <<
"Time step index: " << EI_Index::val
304 <<
", history index: " << EI_BackIndex::val
305 <<
" out of history of size: " << EI_HistorySize::val);
309 static const Input::Type::Tuple & get_input_time_type(
double lower_bound= -std::numeric_limits<double>::max(),
310 double upper_bound=std::numeric_limits<double>::max());
316 {
return time_marks_;}
329 bool timestep_output =
true);
366 return (end_time_ == max_end_time)
367 && (max_time_step_ == end_time_ - init_time_);
379 void set_dt_limits(
double min_dt,
double max_dt,
Input::Array dt_limits_list);
392 int set_upper_constraint(
double upper, std::string message);
411 int set_lower_constraint(
double lower, std::string message);
420 double fix_dt_until_mark();
437 double reduce_timestep(
double factor);
447 const TimeStep &step(
int index=-1)
const;
453 {
return eq_mark_type_;}
459 {
return eq_mark_type_ | marks().type_fixed_time(); }
477 {
return time_marks_.next(*
this, mask);}
483 {
return time_marks_.last(*
this, mask);}
489 {
return upper_constraint_;}
495 {
return lower_constraint_;}
501 {
return end_of_fixed_dt_interval_;}
507 {
return time_step_changed_;}
514 {
return this->init_time_;}
519 inline double t()
const 520 {
return step().end();}
526 {
if (step().index() >0)
return step(-2).length();
527 else return inf_time;
534 {
if (step().index() >0)
return step(-2).end();
535 else return step().end() - step().length();
542 inline double dt()
const 543 {
return step().length();}
559 double estimate_dt()
const;
565 {
return t()+estimate_dt();}
569 {
return end_time_; }
573 {
return (this->step().ge(end_time_) || t() == inf_time); }
585 {
return step().index();}
592 void view(
const char *name=
"")
const;
610 double get_coef()
const;
615 std::string get_unit_string()
const;
653 void init_common(
double init_time,
double end_time,
TimeMark::Type type);
658 void set_permanent_constraint();
663 static const unsigned int size_of_recent_steps_ = 3;
bool operator==(const TimeStep &other)
double max_dt
max DT limit
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
std::ofstream timesteps_output_
Handle for file for output time steps to YAML format.
double upper_constraint() const
double time
time of DT limits record
double coef_
Conversion coefficient of all time values within the equation.
double end_time_
End time of the simulation.
bool contains(double other_time) const
std::vector< DtLimitRow > dt_limits_table_
Table of DT limits.
bool is_end() const
Returns true if the actual time is greater than or equal to the end time.
DtLimitRow(double t, double min, double max)
TimeMarks::iterator last(const TimeMark::Type &mask) const
TimeMarks::iterator next(const TimeMark::Type &mask) const
std::shared_ptr< TimeUnitConversion > time_unit_conversion_
Conversion unit of all time values within the equation.
double end_of_fixed_dt() const
Helper class storing unit conversion coefficient and functionality for conversion of units...
unsigned int dt_limits_pos_
Index to actual position of DT limits.
static const double max_end_time
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()
Structure that stores one record of DT limit.
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
bool timestep_output_
Special flag allows forbid output time steps during multiple initialization of TimeGovernor.
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.
Dedicated class for storing path to input and output files.
double max_time_step_
Permanent upper limit for the time step.
FilePath timesteps_output_file_
File path for timesteps_output_ stream.
std::shared_ptr< TimeUnitConversion > time_unit_conversion_
Conversion unit of all time values within the equation.
bool limits_time_marks_
Allows add all times defined in dt_limits_table_ to list of TimeMarks.
double min_dt
min DT limit
double last_printed_timestep_
Store last printed time to YAML output, try multiplicity output of one time.
std::string upper_constraint_message_
Description of the upper constraint.
bool gt(double other_time) const
unsigned int index() const
std::string unit_string_
String representation of global unit of all time values within the equation.
double fixed_time_step_
Next fixed time step.
std::string get_unit_string() const
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.