26 #include <boost/circular_buffer.hpp>
44 template<
class T>
class Iterator;
69 "See the key 'common_time_unit'.");
128 TimeStep(
double init_time, std::shared_ptr<TimeUnitConversion> time_unit_conversion = std::make_shared<TimeUnitConversion>());
167 inline bool gt(
double other_time)
const
173 inline bool ge(
double other_time)
const
179 inline bool lt(
double other_time)
const
185 inline bool le(
double other_time)
const
191 inline bool eq(
double other_time)
const
192 {
return this->
le(other_time) && this->
ge(other_time); }
195 {
return this->
ge(other_time) && this->
lt(other_time +
length_); }
319 <<
"Time step index: " << EI_Index::val
320 <<
", history index: " << EI_BackIndex::val
321 <<
" out of history of size: " << EI_HistorySize::val);
326 double upper_bound=std::numeric_limits<double>::max());
345 bool timestep_output =
true);
535 inline double t()
const
558 inline double dt()
const
608 void view(
const char *name=
"")
const;
Dedicated class for storing path to input and output files.
Basic time management functionality for unsteady (and steady) solvers (class Equation).
TimeMark::Type equation_fixed_mark_type() const
std::shared_ptr< TimeUnitConversion > time_unit_conversion_
Conversion unit of all time values within the equation.
bool time_step_changed_
Flag is set if the time step has been changed (lasts only one time step).
std::shared_ptr< TimeUnitConversion > get_unit_conversion() const
Getter for time unit conversion object.
double reduce_timestep(double factor)
Force timestep reduction in particular in the case of failure of the non-linear solver.
double lower_constraint() const
std::ofstream timesteps_output_
Handle for file for output time steps to YAML format.
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
void add_time_marks_grid(double step, TimeMark::Type mark_type=TimeMark::none_type) const
void set_dt_limits(double min_dt, double max_dt, Input::Array dt_limits_list)
Sets dt limits for time dependent DT limits in simulation.
TYPEDEF_ERR_INFO(EI_Index, int)
double min_time_step_
Permanent lower limit for the time step.
double last_upper_constraint_
Upper constraint used for choice of current time.
static const Input::Type::Tuple & get_input_time_type(double lower_bound=-std::numeric_limits< double >::max(), double upper_bound=std::numeric_limits< double >::max())
double end_time_
End time of the simulation.
bool steady_
True if the time governor is used for steady problem.
TimeMarks::iterator next(const TimeMark::Type &mask) const
FilePath timesteps_output_file_
File path for timesteps_output_ stream.
bool limits_time_marks_
Allows add all times defined in dt_limits_table_ to list of TimeMarks.
double lower_constraint_
Lower constraint for the choice of the next time step.
DECLARE_INPUT_EXCEPTION(ExcTimeGovernorMessage,<< EI_Message::val)
static const unsigned int size_of_recent_steps_
double end_of_fixed_dt_interval_
End of interval if fixed time step.
static const Input::Type::Record & get_input_type()
std::string upper_constraint_message_
Description of the upper constraint.
int set_lower_constraint(double lower, std::string message)
Sets lower constraint for the next time step estimating.
std::string lower_constraint_message_
Description of the upper constraint.
TYPEDEF_ERR_INFO(EI_BackIndex, unsigned int)
TimeMark::Type eq_mark_type_
TimeMark type of the equation.
std::vector< DtLimitRow > dt_limits_table_
Table of DT limits.
double upper_constraint_
Upper constraint for the choice of the next time step.
bool is_end() const
Returns true if the actual time is greater than or equal to the end time.
int set_upper_constraint(double upper, std::string message)
Sets upper constraint for the next time step estimating.
double fixed_time_step_
Next fixed time step.
double upper_constraint() const
bool is_changed_dt() const
double read_coef(Input::Iterator< Input::Record > unit_it) const
static TimeMarks time_marks_
void view(const char *name="") const
boost::circular_buffer< TimeStep > recent_steps_
Circular buffer of recent time steps. Implicit size is 3.
double end_time() const
End time.
bool is_time_step_fixed_
Flag that is set when the fixed step is set (lasts only one time step).
DECLARE_EXCEPTION(ExcMissingTimeStep,<< "Time step index: "<< EI_Index::val<< ", history index: "<< EI_BackIndex::val<< " out of history of size: "<< EI_HistorySize::val)
double last_lower_constraint_
Lower constraint used for choice of current time.
double estimate_dt() const
Estimate choice of next time step according to actual setting of constraints.
static const double time_step_precision
TimeGovernor(const Input::Record &input, TimeMark::Type fixed_time_mask=TimeMark::none_type, bool timestep_output=true)
Constructor for unsteady solvers.
static const double max_end_time
void set_permanent_constraint()
Sets permanent constraints for actual time step.
TimeMarks::iterator last(const TimeMark::Type &mask) const
TimeMark::Type equation_mark_type() const
double last_printed_timestep_
Store last printed time to YAML output, try multiplicity output of one time.
double estimate_time() const
double fix_dt_until_mark()
Fixing time step until fixed time mark.
double init_time_
Initial time.
bool timestep_output_
Special flag allows forbid output time steps during multiple initialization of TimeGovernor.
bool is_current(const TimeMark::Type &mask) const
const TimeStep & step(int index=-1) const
TYPEDEF_ERR_INFO(EI_HistorySize, unsigned int)
static const double inf_time
Infinity time used for steady case.
static TimeMarks & marks()
double end_of_fixed_dt() const
unsigned int dt_limits_pos_
Index to actual position of DT limits.
double max_time_step_
Permanent upper limit for the time step.
bool is_steady() const
Returns true if the time governor is used for steady problem.
void init_common(double init_time, double end_time, TimeMark::Type type)
Common part of the constructors. Set most important parameters, check they are valid and set default ...
void next_time()
Proceed to the next time according to current estimated time step.
static const Type none_type
Mark Type with all bits unset.
Iterator over TimeMark objects in TimeMarks object (database of TimeMark objects).
This class is a collection of time marks to manage various events occurring during simulation time.
TimeMarks::iterator last(const TimeStep &time_step, const TimeMark::Type &mask) const
TimeMark::Type type_fixed_time()
TimeMarks::iterator next(const TimeGovernor &tg, const TimeMark::Type &mask) const
Representation of one time step..
bool eq(double other_time) const
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
bool operator==(const TimeStep &other)
bool ge(double other_time) const
std::shared_ptr< TimeUnitConversion > time_unit_conversion_
Conversion unit of all time values within the equation.
bool gt(double other_time) const
TimeStep make_next(double new_length) const
double end_
End time point of the time step.
bool le(double other_time) const
double read_coef(Input::Iterator< Input::Record > unit_it) const
bool lt(double other_time) const
bool contains(double other_time) const
std::shared_ptr< TimeUnitConversion > get_unit_conversion() const
Getter for time unit conversion object.
bool safe_compare(double t1, double t0) const
unsigned int index_
Index of the step is index if the end time. Zero time step is artificial.
unsigned int index() const
Helper class storing unit conversion coefficient and functionality for conversion of units.
double read_unit_coef_from_input(const Input::Record &input) const
Reads the Unit record and computes the coef.
double coef_
Conversion coefficient of all time values within the equation.
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time) const
double read_coef(Input::Iterator< Input::Record > unit_it) const
std::string unit_string_
String representation of global unit of all time values within the equation.
std::string get_unit_string() const
static Input::Type::Default get_input_default()
Global macros to enhance readability and debugging, general constants.
Structure that stores one record of DT limit.
double max_dt
max DT limit
double time
time of DT limits record
DtLimitRow(double t, double min, double max)
double min_dt
min DT limit
std::ostream & operator<<(std::ostream &out, const TimeStep &t_step)