Flow123d
last_with_con_2.0.0-4-g42e6930
|
This class is a collection of time marks to manage various events occurring during simulation time. More...
#include <time_marks.hh>
Public Types | |
typedef TimeMarksIterator | iterator |
Iterator class for iteration over time marks of particular type. This is always const_iterator. More... | |
Private Attributes | |
TimeMark::Type | next_mark_type_ |
MarkType that will be used at next new_time_mark() call. More... | |
std::vector< TimeMark > | marks_ |
TimeMarks list sorted according to the their time. More... | |
TimeMark::Type | type_fixed_time_ |
Predefined type for fixed time. More... | |
TimeMark::Type | type_output_ |
Predefined type for output. More... | |
TimeMark::Type | type_input_ |
Predefined type for change of boundary condition. More... | |
TimeMark::Type | type_balance_output_ |
Predefined type for balance output. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const TimeMarks &marks) |
Friend output operator. More... | |
This class is a collection of time marks to manage various events occurring during simulation time.
TimeMark and their types
One TimeMark consists of time and type (TimeMark::Type), see the constructor TimeMark::TimeMark. The type of mark is bitmap where individual bits corresponds to some base event types like changing a BC, output solution, coupling time with another equation and so on. Base types can be combined by bitwise or (operator|).
Special types are predefined in TimeMarks class. These are returned by their getters:
TimeMarks collection
TimeMarks collect marks of various types and provides methods for iterating over stored marks. You can selectively access only marks matching given type mask. See TimeMark::match_mask.
You can add one new mark through method add or add evenly spaced marks of same type by TimeMarks::add_time_marks.
You can allocate new TimeMark::Type in the context of one TimeMarks object by TimeMarks::new_mark_type.
For a given TimeGovernor (not necessarily connected one) you can ask about existence of mark in current time interval (TimeMarks::is_current) and see TimeMarks close to the current time (TimeMarks::next and TimeMarks::last). The current time interval is left-open and right-closed: (t,t+dt]. Repeatedly used TimeMarks::next always returns the same TimeMark if the time of the TimeGovernor is not changed.
In most cases there will be only one TimeMarks object for the whole solved problem and used by TimeGovernors of individual equations. However this is not necessary.
Definition at line 163 of file time_marks.hh.
typedef TimeMarksIterator TimeMarks::iterator |
Iterator class for iteration over time marks of particular type. This is always const_iterator.
Definition at line 167 of file time_marks.hh.
TimeMarks::TimeMarks | ( | ) |
Default constructor.
Definition at line 45 of file time_marks.cc.
Basic method for inserting TimeMarks.
mark | Reference to TimeMark object. |
Definition at line 76 of file time_marks.cc.
void TimeMarks::add_time_marks | ( | double | time, |
double | dt, | ||
double | end_time, | ||
TimeMark::Type | type | ||
) |
Method for creating and inserting equally spaced TimeMarks.
time | Time of the first TimeMark. |
dt | Lenght of interval between equally spaced TimeMarks. |
end_time | No marks after the end_time. |
type | Type of inserted TimeMarks or their combinations. |
Current lazy implementation have complexity O(m*n) where m is number of inserted time marks and n number of time marks in the array. TODO: O(n+m) implementation
Definition at line 100 of file time_marks.cc.
void TimeMarks::add_to_type_all | ( | TimeMark::Type | filter_type, |
TimeMark::Type | add_type | ||
) |
Apply TimeMark::add_to_type (|=) to all time marks matching the filter type.
Definition at line 112 of file time_marks.cc.
TimeMarks::iterator TimeMarks::begin | ( | TimeMark::Type | mask = TimeMark::every_type | ) | const |
Iterator for the begin mimics container-like of TimeMarks.
Definition at line 176 of file time_marks.cc.
TimeMarks::iterator TimeMarks::current | ( | const TimeStep & | time_step, |
const TimeMark::Type & | mask | ||
) | const |
Definition at line 131 of file time_marks.cc.
TimeMarks::iterator TimeMarks::end | ( | TimeMark::Type | mask = TimeMark::every_type | ) | const |
Iterator for the end mimics container-like of TimeMarks.
Definition at line 183 of file time_marks.cc.
TimeMarks::iterator TimeMarks::last | ( | const TimeStep & | time_step, |
const TimeMark::Type & | mask | ||
) | const |
Return the last TimeMark with time less or equal to tg.time() that match the mask. The time governor tg is used also for time comparisons.
tg | the time governor |
mask | mask of marks to iterate on |
Definition at line 150 of file time_marks.cc.
TimeMarks::iterator TimeMarks::last | ( | const TimeGovernor & | tg, |
const TimeMark::Type & | mask | ||
) | const |
Definition at line 161 of file time_marks.cc.
TimeMarks::iterator TimeMarks::last | ( | const TimeMark::Type & | mask | ) | const |
Returns iterator to the last time mark matching given mask
.
Definition at line 167 of file time_marks.cc.
TimeMark::Type TimeMarks::new_mark_type | ( | ) |
Add a new base mark within the context of the particular TimeMarks instance. User should keep the returned value (MarkType is basically a bitmap) for further queries and TimeMark insertions. ATTENTION: You can not use the TimeMark::Type with other TimeMarks instance! Types are added as they are prepared in next_mark_type_. Next mark type is updated by (left) bit shifting operator.
Definition at line 68 of file time_marks.cc.
TimeMarks::iterator TimeMarks::next | ( | const TimeGovernor & | tg, |
const TimeMark::Type & | mask | ||
) | const |
Return the first TimeMark with time strictly greater then tg.time() that match the mask. The time governor tg is used also for time comparisons.
tg | the time governor |
mask | mask of marks to iterate on |
TODO: have also method which accepts double (time) instead of the whole TimeGovernor. and compare without safety.
Definition at line 139 of file time_marks.cc.
void TimeMarks::reinit | ( | ) |
Reset state after construction (through default constructor). Useful for unit tests.
Definition at line 52 of file time_marks.cc.
|
inline |
Predefined base TimeMark type for times of balnace output. Is defined by constructor as 0x08.
Definition at line 206 of file time_marks.hh.
|
inline |
Predefined base TimeMark type that is taken into account by the TimeGovernor. Is defined by constructor as 0x01.
Definition at line 191 of file time_marks.hh.
|
inline |
Predefined base TimeMark type for times when the boundary condition is changed. Is defined by constructor as 0x04.
Definition at line 201 of file time_marks.hh.
|
inline |
Predefined base TimeMark type for output times. Is defined by constructor as 0x02.
Definition at line 196 of file time_marks.hh.
|
friend |
Friend output operator.
|
private |
TimeMarks list sorted according to the their time.
Definition at line 282 of file time_marks.hh.
|
private |
MarkType that will be used at next new_time_mark() call.
Definition at line 279 of file time_marks.hh.
|
private |
Predefined type for balance output.
Definition at line 291 of file time_marks.hh.
|
private |
Predefined type for fixed time.
Definition at line 285 of file time_marks.hh.
|
private |
Predefined type for change of boundary condition.
Definition at line 289 of file time_marks.hh.
|
private |
Predefined type for output.
Definition at line 287 of file time_marks.hh.