Flow123d
jenkins-Flow123d-windows-release-multijob-285
|
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... | |
Public Member Functions | |
TimeMarks () | |
void | reinit () |
TimeMark::Type | new_mark_type () |
TimeMark::Type | type_fixed_time () |
TimeMark::Type | type_output () |
TimeMark::Type | type_input () |
void | add (const TimeMark &mark) |
void | add_time_marks (double time, double dt, double end_time, TimeMark::Type type) |
bool | is_current (const TimeGovernor &tg, const TimeMark::Type &mask) const |
TimeMarks::iterator | next (const TimeGovernor &tg, const TimeMark::Type &mask) const |
TimeMarks::iterator | last (const TimeGovernor &tg, const TimeMark::Type &mask) const |
TimeMarks::iterator | last (const TimeMark::Type &mask) const |
TimeMarks::iterator | begin (TimeMark::Type mask=TimeMark::every_type) const |
Iterator for the begin mimics container-like of TimeMarks. More... | |
TimeMarks::iterator | end (TimeMark::Type mask=TimeMark::every_type) const |
Iterator for the end mimics container-like of TimeMarks. 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... | |
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 170 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 174 of file time_marks.hh.
TimeMarks::TimeMarks | ( | ) |
Default constructor.
Definition at line 58 of file time_marks.cc.
void TimeMarks::add | ( | const TimeMark & | mark | ) |
Basic method for inserting TimeMarks.
mark | Reference to TimeMark object. |
Definition at line 88 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 111 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 163 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 170 of file time_marks.cc.
bool TimeMarks::is_current | ( | const TimeGovernor & | tg, |
const TimeMark::Type & | mask | ||
) | const |
Find the last time mark matching given mask, and returns true if it is in the time interval of current time step.
Definition at line 122 of file time_marks.cc.
TimeMarks::iterator TimeMarks::last | ( | const TimeGovernor & | tg, |
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 141 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 154 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 80 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 130 of file time_marks.cc.
void TimeMarks::reinit | ( | ) |
Reset state after construction (through default constructor). Useful for unit tests.
Definition at line 65 of file time_marks.cc.
|
inline |
Predefined base TimeMark type that is taken into account by the TimeGovernor. Is defined by constructor as 0x01.
Definition at line 198 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 208 of file time_marks.hh.
|
inline |
Predefined base TimeMark type for output times. Is defined by constructor as 0x02.
Definition at line 203 of file time_marks.hh.
|
friend |
Friend output operator.
|
private |
TimeMarks list sorted according to the their time.
Definition at line 276 of file time_marks.hh.
|
private |
MarkType that will be used at next new_time_mark() call.
Definition at line 273 of file time_marks.hh.
|
private |
Predefined type for fixed time.
Definition at line 279 of file time_marks.hh.
|
private |
Predefined type for change of boundary condition.
Definition at line 283 of file time_marks.hh.
|
private |
Predefined type for output.
Definition at line 281 of file time_marks.hh.