Flow123d  JS_before_hm-883-gc471082
time_governor.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file time_governor.hh
15  * @brief Basic time management class.
16  * @author Jan Brezina
17  */
18 
19 #ifndef TIME_HH_
20 #define TIME_HH_
21 
22 #include <limits>
23 #include <cmath>
24 #include <algorithm>
25 #include <fstream>
26 #include <boost/circular_buffer.hpp>
27 #include <boost/exception/info.hpp>
28 #include <iosfwd>
29 #include <string>
30 
31 #include "system/global_defs.h"
32 #include "system/system.hh"
33 #include "system/file_path.hh"
35 #include "input/input_exception.hh"
36 #include "system/exc_common.hh"
37 #include "system/exceptions.hh"
38 #include "tools/time_marks.hh"
39 
40 namespace Input {
41  class Record;
42  class Tuple;
43  template<class T> class Iterator;
44  namespace Type {
45  class Record;
46  class Tuple;
47  }
48 }
49 
50 
51 
52 /**
53  * @brief Helper class storing unit conversion coefficient and functionality for conversion of units.
54  *
55  * This class has created one instance for each TimeGovernor object. This object is shared with all
56  * TimeSteps.
57  */
59 public:
60  // Constructor set coef_ from user defined unit
61  TimeUnitConversion(std::string user_defined_unit);
62 
63  // Default constructor
65 
66  /**
67  * Read and return time value multiplied by coefficient of given unit or global coefficient of equation
68  * stored in coeff_. If time Tuple is not defined (e. g. Tuple is optional key) return default_time value.
69  */
70  double read_time(Input::Iterator<Input::Tuple> time_it, double default_time) const;
71 
72  /**
73  * Read and return time unit coefficient given in unit_it or global coefficient of equation stored
74  * in coeff_, if iterator is not defined.
75  */
76  double read_coef(Input::Iterator<std::string> unit_it) const;
77 
78  /**
79  * Return global time unit coefficient of equation stored in coeff_.
80  */
81  inline double get_coef() const {
82  return coef_;
83  }
84 
85  /**
86  * Return string representation of global time unit.
87  */
88  inline std::string get_unit_string() const {
89  return unit_string_;
90  }
91 
92 protected:
93  /// Conversion coefficient of all time values within the equation.
94  double coef_;
95 
96  /// String representation of global unit of all time values within the equation.
97  std::string unit_string_;
98 
99 };
100 
101 
102 
103 /**
104  * @brief Representation of one time step.\
105  *
106  * Time step consists of the time step @p length() and from time step @end() time.
107  * More over we store the index of the time step within it time governor.
108  *
109  * The reason to store both the end time and the length of the time step is to allow
110  * safe comparisons of the time with safety margin small relative to the
111  * time step length.
112  */
113 class TimeStep {
114 public:
115  /**
116  * Constructor of the zero time step.
117  */
118  TimeStep(double init_time, std::shared_ptr<TimeUnitConversion> time_unit_conversion = std::make_shared<TimeUnitConversion>());
119 
120  /**
121  * Default constructor.
122  * Creates undefined time step.
123  */
124  TimeStep();
125 
126  /**
127  * Copy constructor.
128  */
129  TimeStep(const TimeStep &other);
130 
131  /**
132  * Create subsequent time step.
133  */
134  TimeStep make_next(double new_length) const;
135 
136  /**
137  * Create subsequent time step, with the @end_time
138  * explicitly specified. This allow slight discrepancy to
139  * overcome rounding errors in the case of fixed time step.
140  * Otherwise using small fixed time step, we may miss long term fixed
141  * goal time.
142  *
143  */
144  TimeStep make_next(double new_lenght, double end_time) const;
145 
146  /**
147  * Getters.
148  */
149  unsigned int index() const {return index_;}
150  double length() const { return length_;}
151  double end() const { return end_;}
152  /**
153  * Performs rounding safe comparison time > other_time, i.e. time is strictly greater than given parameter
154  * other_time with precision relative to the magnitude of the numbers time step.
155  * TODO: introduce type TimeDouble with overloaded comparison operators, use it consistently in TimeMarks.
156  */
157  inline bool gt(double other_time) const
158  { return ! safe_compare(other_time, end());}
159 
160  /**
161  * Performs rounding safe comparison time >= other_time See @fn gt
162  */
163  inline bool ge(double other_time) const
164  { return safe_compare(end(), other_time); }
165 
166  /**
167  * Performs rounding safe comparison time < other_time. See @fn gt
168  */
169  inline bool lt(double other_time) const
170  { return ! safe_compare(end(), other_time); }
171 
172  /**
173  * Performs rounding safe comparison time <= other_time. See @fn gt
174  */
175  inline bool le(double other_time) const
176  { return safe_compare(other_time, end()); }
177 
178  /**
179  * Performs rounding safe comparison time (step) == other_time. See @fn gt
180  */
181  inline bool eq(double other_time) const
182  { return this->le(other_time) && this->ge(other_time); }
183 
184  inline bool contains(double other_time) const
185  { return this->ge(other_time) && this->lt(other_time + length_); }
186 
187  /**
188  * Read and return time value multiplied by coefficient of given unit or global coefficient of equation
189  * stored in time_unit_conversion_. If time Tuple is not defined (e. g. Tuple is optional key) return
190  * default_time value.
191  */
192  double read_time(Input::Iterator<Input::Tuple> time_it, double default_time=std::numeric_limits<double>::quiet_NaN()) const;
193 
194  /**
195  * Read and return time unit coefficient given in unit_it or global coefficient of equation stored
196  * in time_unit_conversion_, if iterator is not defined.
197  */
198  double read_coef(Input::Iterator<std::string> unit_it) const;
199 
200  /**
201  * Return global time unit coefficient of equation stored in coeff_.
202  */
203  double get_coef() const;
204 
205  /**
206  * Returns true if two time steps are exactly the same.
207  */
208  bool operator==(const TimeStep & other)
209  { return (index_ == other.index_)
210  && (length_ == other.length_)
211  && (end_ == other.end_);
212  }
213 private:
214 
215  /* Returns true if t1-t0 > delta. Where delta is choosen
216  * related to the current time step and magnitude of t1, t0.
217  */
218  bool safe_compare(double t1, double t0) const;
219 
220  /// Index of the step is index if the end time. Zero time step is artificial.
221  unsigned int index_;
222  /// Length of the time step. Theoretically @p end minus end of the previous time step.
223  /// However may be slightly different due to rounding errors.
224  double length_;
225  /// End time point of the time step.
226  double end_;
227  /// Conversion unit of all time values within the equation.
228  std::shared_ptr<TimeUnitConversion> time_unit_conversion_;
229 };
230 
231 std::ostream& operator<<(std::ostream& out, const TimeStep& t_step);
232 
233 
234 
235 /**
236  * @brief
237  * Basic time management functionality for unsteady (and steady) solvers (class Equation).
238  *
239  * <h2> Common features and unsteady time governor (TG) </h2>
240  *
241  * This class provides algorithm for selecting next time step, and information about current time step frame.
242  * Step estimating is constrained by several bounds (permanent maximal and minimal time step, upper
243  * and lower constraint of time step). The permanent constraints are set in the constructor from the input
244  * record so that user can set the time step constraints for the whole simulation.
245  * Function set_dt_limits() should be used only in very specific cases and possibly right after
246  * the constructor before using other functions of TG.
247  *
248  * Choice of the very next time step can be constrained using functions set_upper_constraint()
249  * and set_lower_constraint().
250  * Lower and upper constraints are set equal to permanent ones in the constructor and can only
251  * become stricter. If one tries to set these constraints outside the interval of the previous constraints,
252  * nothing is changed and a specified value is returned. Upper and lower constraints are reset in function
253  * next_time() to the permanent constraints.
254  *
255  * The later one can be called multiple times with various constraint values and we use the minimum of them.
256  * Function next_time() choose the next time step in such a way that it meets actual constraints and
257  * a uniform discrete time grid with this step hits the nearest fixed time in lowest possible number of steps.
258  *
259  * The fixed times are time marks of TimeMarks object passed at construction time with particular mask.
260  *
261  * There is just one set of time marks for the whole problem. Therefore TimeMarks object is static and is shared umong
262  * all the equations and time governors. Each equation creates its own specific time mark type.
263  *
264  * Information provided by TG includes:
265  * - actual time, last time, end time
266  * - actual time step
267  * - number of the time level
268  * - end of interval with fixed time step
269  * - time comparison
270  * - static pointer to time marks
271  *
272  * <h2> Steady time governor</h2>
273  *
274  * Steady TG can be constructed by default constructor (initial time is zero) or by
275  * constructor with initial time as parameter. End time and time step are set to infinity.
276  * One can check if the time governor is steady by calling is_steady().
277  * Calling estimate_dt() will return infinity.
278  *
279  * Setting constraints have no consequences. Calling fix_dt_until_mark() will only return zero
280  * and will not do anything.
281  *
282  * The steady TG works in two states. At first the time is set to initial and time level
283  * is equal zero. To use steady TG properly one should call next_time() after the computation
284  * of steady problem is done. Current time is then set to infinity, time level is set to 1 and
285  * calling estimate_dt() will return zero.
286  *
287  * Note: For example class TransportNothing (which computes really nothing) uses also steady TG but
288  * it calls next_time() immediately after TG's construction. This means that the 'computation'of transport
289  * is done.
290  *
291  *
292  */
293 
295 {
296 public:
297 
298  DECLARE_INPUT_EXCEPTION(ExcTimeGovernorMessage, << EI_Message::val);
299  TYPEDEF_ERR_INFO( EI_Index, int);
300  TYPEDEF_ERR_INFO( EI_BackIndex, unsigned int);
301  TYPEDEF_ERR_INFO( EI_HistorySize, unsigned int);
302  DECLARE_EXCEPTION(ExcMissingTimeStep,
303  << "Time step index: " << EI_Index::val
304  << ", history index: " << EI_BackIndex::val
305  << " out of history of size: " << EI_HistorySize::val);
306 
307  static const Input::Type::Record & get_input_type();
308 
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());
311 
312  /**
313  * Getter for time marks.
314  */
315  static inline TimeMarks &marks()
316  {return time_marks_;}
317 
318  /**
319  * @brief Constructor for unsteady solvers.
320  *
321  * @param input accessor to input data
322  * @param fixed_time_mask TimeMark mask used to select fixed time marks from all the time marks.
323  * @param timestep_output enable/forbid output of time steps to YAML file
324  * This value is bitwise added to the default one defined in TimeMarks::type_fixed_time().
325  *
326  */
327  TimeGovernor(const Input::Record &input,
328  TimeMark::Type fixed_time_mask = TimeMark::none_type,
329  bool timestep_output = true);
330 
331  /**
332  * @brief Default constructor - steady time governor.
333  *
334  * OBSOLETE.
335  *
336  * We can have "zero step" steady problem (no computation, e.g. EquationNothing) and one step steady problem
337  * (e.g. steady water flow).
338  *
339  * Time is set to zero, time step and end time to infinity.
340  *
341  * First call of next_time() pushes the actual time to infinity.
342  *
343  * However, you have to use full constructor for the "steady problem" that has time-variable input data.
344  *
345  * Has a private pointer to static TimeMarks and can access them by marks().
346  */
347  explicit TimeGovernor(double init_time=0.0,
348  TimeMark::Type fixed_time_mask = TimeMark::none_type);
349 
350  /**
351  * The aim of this constuctor is simple way to make a time governor without Input interface.
352  *
353  * TODO: Partially tested as part of field test. Needs its own unit test.
354  */
355  TimeGovernor(double init_time, double dt);
356 
357  /**
358  * Destructor.
359  */
360  ~TimeGovernor();
361 
362  /**
363  * Returns true if the time governor was set from default values
364  */
365  bool is_default() {
366  return (end_time_ == max_end_time)
367  && (max_time_step_ == end_time_ - init_time_);
368  }
369 
370  /**
371  * @brief Sets dt limits for time dependent DT limits in simulation.
372  *
373  * This function should not be normally used. These values are to be set in constructor
374  * from the input record or by default.
375  * @param min_dt is the minimal value allowed for time step
376  * @param max_dt is the maximal value allowed for time step
377  * @param dt_limits_list list of time dependent values of minimal and maximal value allowed for time step
378  */
379  void set_dt_limits( double min_dt, double max_dt, Input::Array dt_limits_list);
380 
381  /**
382  * @brief Sets upper constraint for the next time step estimating.
383  *
384  * This function can only make the constraint stricter. Upper constraint is reset to @p max_dt after the next_time() call.
385  * The return value mimics result of the comparison: current constraint compared to @param upper.
386  * @param message describes the origin of the constraint
387  * In particular the return values is:
388  * - -1: Current upper constraint is less then the @param upper. No change happen.
389  * - 0: Current constraint interval contains the @param upper. The upper constraint is set.
390  * - +1: Current lower constraint is greater then the @param upper. No change happen.
391  */
392  int set_upper_constraint(double upper, std::string message);
393 
394  /**
395  * @brief Sets lower constraint for the next time step estimating.
396  *
397  * This function can only make the constraint stricter. Lower constraint is reset to @p min_dt after the next_time() call.
398  * The return value mimics result of the comparison: current constraint compared to @param upper.
399  * In particular the return values is:
400  * - -1: Current upper constraint is less then the @param lower. No change happen.
401  * - 0: Current constraint interval contains the @param lower. The lower constraint is set.
402  * - +1: Current upper constraint is greater then the @param lower. No change happen.
403  */
404  /**
405  * @brief Sets lower constraint for the next time step estimating.
406  * @param lower is the lower constraint for time step
407  * @param message describes the origin of the constraint
408  * @return -1, 0 or 1 according to the success.
409  * @see set_upper_constrain().
410  */
411  int set_lower_constraint(double lower, std::string message);
412 
413  /**
414  * @brief Fixing time step until fixed time mark.
415  *
416  * Fix time step until first fixed time mark. When called inside an already fixed interval,
417  * it overwrites previous setting.
418  * @return actual end of fixed time step.
419  */
420  double fix_dt_until_mark();
421 
422  /**
423  * @brief Proceed to the next time according to current estimated time step.
424  *
425  * The timestep constraints are relaxed to the permanent constraints.
426  */
427  void next_time();
428 
429  /**
430  * @brief Force timestep reduction in particular in the case of failure of the non-linear solver.
431  *
432  * Calling this method also force immediate end of the fixed timestep interval.
433  * Returns true reduce factor used. It is larger then given factor if we hit the lower timestep constraint.
434  *
435  * TODO: How to keep constraints active for the last next_time call.
436  */
437  double reduce_timestep(double factor);
438 
439  /**
440  * Returns reference to required time step in the recent history.
441  * Without parameter the actual time step is returned.
442  * Use negative indices to get recent time steps: step(-1) the actual step, step(-2) the last one.
443  * Use positive index to get time step by its index: step(0) the first time step.
444  * However only limited number of last time steps is stored.
445  * If the time step is not accessible any more, we throw an exception ExcMissingTimeStep.
446  */
447  const TimeStep &step(int index=-1) const;
448 
449  /**
450  * Specific time mark of the equation owning the time governor.
451  */
453  { return eq_mark_type_;}
454 
455  /**
456  * Specific time mark of the fixed times of the equation owning the time governor.
457  */
459  { return eq_mark_type_ | marks().type_fixed_time(); }
460 
461  /**
462  * Add sequence of time marks starting from the initial time up to the end time with given @p step.
463  * Time marks type combines given mark_type (none by default) and native mark type of the time governor.
464  */
465  void add_time_marks_grid(double step, TimeMark::Type mark_type= TimeMark::none_type) const;
466 
467  /**
468  * Simpler interface to TimeMarks::is_current().
469  */
470  bool is_current(const TimeMark::Type &mask) const;
471 
472 
473  /**
474  * Simpler interface to TimeMarks::next().
475  */
476  inline TimeMarks::iterator next(const TimeMark::Type &mask) const
477  {return time_marks_.next(*this, mask);}
478 
479  /**
480  * Simpler interface to TimeMarks::last().
481  */
482  inline TimeMarks::iterator last(const TimeMark::Type &mask) const
483  {return time_marks_.last(*this, mask);}
484 
485  /**
486  * Getter for upper constrain.
487  */
488  inline double upper_constraint() const
489  {return upper_constraint_;}
490 
491  /**
492  * Returns lower constraint.
493  */
494  inline double lower_constraint() const
495  {return lower_constraint_;}
496 
497  /**
498  * End of interval with currently fixed time step. Can be changed by next call of method fix_dt_until_mark.
499  */
500  inline double end_of_fixed_dt() const
501  {return end_of_fixed_dt_interval_;}
502 
503  /**
504  * Getter for dt_changed. Returns whether the time step has been changed.
505  */
506  inline bool is_changed_dt() const
507  {return time_step_changed_;}
508 
509 
510  /**
511  * Initial time getter.
512  */
513  inline double init_time() const
514  {return this->init_time_;}
515 
516  /**
517  * End of actual time interval; i.e. where the solution is computed.
518  */
519  inline double t() const
520  {return step().end();}
521 
522  /**
523  * Previous time step.
524  */
525  inline double last_dt() const
526  {if (step().index() >0) return step(-2).length();
527  else return inf_time;
528  }
529 
530  /**
531  * Previous time.
532  */
533  inline double last_t() const
534  {if (step().index() >0) return step(-2).end();
535  else return step().end() - step().length();
536  }
537 
538 
539  /**
540  * Length of actual time interval; i.e. the actual time step.
541  */
542  inline double dt() const
543  {return step().length();}
544 
545  /**
546  * @brief Estimate choice of next time step according to actual setting of constraints.
547  *
548  * Precedence of constraints:
549  *
550  * -# meet next fixed time (always satisfied)
551  * -# permanent upper constraint (always satisfied)
552  * -# upper constraint (always satisfied)
553  * -# lower constraint (satisfied if not in conflict with 1.)
554  * -# permanent lower constraint (satisfied if 4.)
555  * -# else writes the difference between lower constraint and estimated time step
556  * -# If there are more then one step to the next fixed time, try to
557  * use the last time step if it is nearly the same.
558  */
559  double estimate_dt() const;
560 
561  /**
562  * Estimate next time.
563  */
564  inline double estimate_time() const
565  {return t()+estimate_dt();}
566 
567  /// End time.
568  inline double end_time() const
569  { return end_time_; }
570 
571  /// Returns true if the actual time is greater than or equal to the end time.
572  inline bool is_end() const
573  { return (this->step().ge(end_time_) || t() == inf_time); }
574 
575  /// Returns true if the time governor is used for steady problem.
576  inline bool is_steady() const
577  { return steady_; }
578 
579 
580 
581  /**
582  * Returns the time level.
583  */
584  inline int tlevel() const
585  {return step().index();}
586 
587  /**
588  * Prints output of TimeGovernor.
589  * @param name is the name of time governor that you want to show up in output (just for your convenience)
590  *
591  */
592  void view(const char *name="") const;
593 
594  /**
595  * Read and return time value multiplied by coefficient of given unit or global coefficient of equation
596  * stored in time_unit_conversion_. If time Tuple is not defined (e. g. Tuple is optional key) return
597  * default_time value.
598  */
599  double read_time(Input::Iterator<Input::Tuple> time_it, double default_time=std::numeric_limits<double>::quiet_NaN()) const;
600 
601  /**
602  * Read and return time unit coefficient given in unit_it or global coefficient of equation stored
603  * in time_unit_conversion_, if iterator is not defined.
604  */
605  double read_coef(Input::Iterator<std::string> unit_it) const;
606 
607  /**
608  * Return global time unit coefficient of equation stored in coeff_.
609  */
610  double get_coef() const;
611 
612  /**
613  * Return string representation of global time unit.
614  */
615  std::string get_unit_string() const;
616 
617  // Maximal tiem of simulation. More then age of the universe in seconds.
618  static const double max_end_time;
619 
620  /// Infinity time used for steady case.
621  static const double inf_time;
622 
623  /**
624  * Rounding precision for computing time_step.
625  * Used as technical lower bound for the time step.
626  */
627  static const double time_step_precision;
628 
629 private:
630 
631  /// Structure that stores one record of DT limit.
632  struct DtLimitRow {
633 
634  DtLimitRow(double t, double min, double max)
635  : time(t),
636  min_dt(min),
637  max_dt(max)
638  {};
639 
640  double time; ///< time of DT limits record
641  double min_dt; ///< min DT limit
642  double max_dt; ///< max DT limit
643  };
644 
645  /**
646  * \brief Common part of the constructors. Set most important parameters, check they are valid and set default values to other.
647  *
648  * Set main parameters to given values.
649  * Check they are correct.
650  * Set soft and permanent constrains to the same, the least restricting values.
651  * Set time marks for the start time and end time (if finite).
652  */
653  void init_common(double init_time, double end_time, TimeMark::Type type);
654 
655  /**
656  * \brief Sets permanent constraints for actual time step.
657  */
658  void set_permanent_constraint();
659 
660  /**
661  * Size of the time step buffer, i.e. recent_time_steps_.
662  */
663  static const unsigned int size_of_recent_steps_ = 3;
664 
665  /// Circular buffer of recent time steps. Implicit size is 3.
666  boost::circular_buffer<TimeStep> recent_steps_;
667  /// Initial time.
668  double init_time_;
669  /// End of interval if fixed time step.
671  /// End time of the simulation.
672  double end_time_;
673 
674  /// Next fixed time step.
676  /// Flag that is set when the fixed step is set (lasts only one time step).
678  /// Flag is set if the time step has been changed (lasts only one time step).
680 
681  /// Description of the upper constraint.
683  /// Description of the upper constraint.
685  /// Upper constraint for the choice of the next time step.
687  /// Lower constraint for the choice of the next time step.
689  /// Permanent upper limit for the time step.
691  /// Permanent lower limit for the time step.
693 
694  /// Upper constraint used for choice of current time.
696  /// Lower constraint used for choice of current time.
698 
699  /**
700  * When the next time is chosen we need only the lowest fix time. Therefore we use
701  * minimum priority queue of doubles based on the vector container.
702  * This is one global set of time marks for the whole problem and is shared among all equations.
703  * Therefore this object is static constant pointer.
704  */
706 
707  /// TimeMark type of the equation.
709 
710  /// True if the time governor is used for steady problem.
711  bool steady_;
712 
713  /// Conversion unit of all time values within the equation.
714  std::shared_ptr<TimeUnitConversion> time_unit_conversion_;
715 
716  /// Table of DT limits
718 
719  /// Index to actual position of DT limits
720  unsigned int dt_limits_pos_;
721 
722  /// File path for timesteps_output_ stream.
724 
725  /// Handle for file for output time steps to YAML format.
726  std::ofstream timesteps_output_;
727 
728  /// Store last printed time to YAML output, try multiplicity output of one time
730 
731  /// Special flag allows forbid output time steps during multiple initialization of TimeGovernor
733 
734  /// Allows add all times defined in dt_limits_table_ to list of TimeMarks
736 
737  friend TimeMarks;
738 };
739 
740 /**
741  * \brief Stream output operator for TimeGovernor.
742  *
743  * Currently for debugging purposes.
744  * In the future it should be customized for use in combination with
745  * streams for various log targets.
746  *
747  */
748 std::ostream& operator<<(std::ostream& out, const TimeGovernor& tg);
749 
750 
751 
752 #endif /* TIME_HH_ */
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).
Definition: time_marks.hh:351
Accessor to input data conforming to declared Array.
Definition: accessors.hh:567
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.
int tlevel() const
static TimeMarks time_marks_
bool lt(double other_time) const
std::ofstream timesteps_output_
Handle for file for output time steps to YAML format.
TYPEDEF_ERR_INFO(EI_KeyName, const string)
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
Abstract linear system class.
Definition: balance.hh:40
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
double t() const
Basic time management functionality for unsteady (and steady) solvers (class Equation).
static const Type none_type
Mark Type with all bits unset.
Definition: time_marks.hh:95
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).
double last_t() const
bool le(double other_time) const
double upper_constraint_
Upper constraint for the choice of the next time step.
double init_time() const
TimeMark::Type eq_mark_type_
TimeMark type of the equation.
Global macros to enhance readability and debugging, general constants.
double get_coef() const
bool ge(double other_time) const
static const double time_step_precision
TimeMark::Type equation_fixed_mark_type() const
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
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 length() 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.
double end() const
This class is a collection of time marks to manage various events occurring during simulation time...
Definition: time_marks.hh:206
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.
Definition: file_path.hh:54
double max_time_step_
Permanent upper limit for the time step.
Tuple type proxy class.
Definition: type_tuple.hh:45
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.
double dt() const
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
DECLARE_EXCEPTION(ExcWrongDefaultJSON,<< "Consistency Error: Not valid JSON of Default value "<< EI_DefaultStr::qval<< " of type "<< EI_TypeName::qval<< ";\n"<< "During declaration of the key: "<< EI_KeyName::qval)
std::ostream & operator<<(std::ostream &stream, const TypeBase &type)
For convenience we provide also redirection operator for output documentation of Input:Type classes...
Definition: type_base.cc:240
unsigned int index() const
Record type proxy class.
Definition: type_record.hh:182
std::string unit_string_
String representation of global unit of all time values within the equation.
double length_
double fixed_time_step_
Next fixed time step.
std::string get_unit_string() const
DECLARE_INPUT_EXCEPTION(ExcInputMessage,<< EI_Message::val)
Simple input exception that accepts just string message.
double last_upper_constraint_
Upper constraint used for choice of current time.
double last_dt() const
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.