29 #ifndef RYTHMOS_TIME_RANGE_DEF_H
30 #define RYTHMOS_TIME_RANGE_DEF_H
32 #include "Rythmos_TimeRange_decl.hpp"
33 #include "Teuchos_Assert.hpp"
34 #include "Teuchos_ScalarTraits.hpp"
37 template<
class TimeType>
38 int Rythmos::compareTimeValues(
const TimeType &t1,
const TimeType &t2 )
41 const TimeType epsMore = 10.0*std::numeric_limits<TimeType>::epsilon();
42 const TimeType t1Mag = Teuchos::ScalarTraits<TimeType>::magnitude(t1);
43 const TimeType t1Tol = t1Mag*epsMore;
44 if ( t2 - t1Tol <= t1 && t1 <= t2 + t1Tol )
46 else if ( t1 > t2 + t1Tol )
53 template<
class TimeType>
55 Rythmos::timeRange(
const TimeType lower,
const TimeType upper)
57 return TimeRange<TimeType>(lower,upper);
61 template<
class TimeType>
63 Rythmos::invalidTimeRange()
65 return TimeRange<TimeType>();
69 template<
class TimeType>
71 Rythmos::operator<<( std::ostream& out, const TimeRange<TimeType>& range )
74 if (range.isValid()) {
75 out << range.
lower() <<
"," << range.upper();
85 template<
class TimeType>
86 void Rythmos::asssertInTimeRange(
const TimeRange<TimeType> &
timeRange,
87 const TimeType &time )
89 TEUCHOS_TEST_FOR_EXCEPTION( !timeRange.isInRange(time), std::out_of_range,
90 "Error, the time = " << time
91 <<
" is out of the range = " << timeRange <<
"!"
96 template<
class TimeType>
97 bool Rythmos::isInRange_cc(
const TimeRange<TimeType> &tr,
const TimeType &p)
106 template<
class TimeType>
107 bool Rythmos::isInRange_oc(
const TimeRange<TimeType> &tr,
const TimeType &p)
116 template<
class TimeType>
117 bool Rythmos::isInRange_co(
const TimeRange<TimeType> &tr,
const TimeType &p)
126 template<
class TimeType>
127 bool Rythmos::isInRange_oo(
const TimeRange<TimeType> &tr,
const TimeType &p)
136 #define RYTHMOS_TIME_RANGE_INSTANT(SCALAR) \
138 template class TimeRange< SCALAR >; \
140 template int compareTimeValues( const SCALAR &t1, const SCALAR &t2 ); \
141 template TimeRange< SCALAR > timeRange(const SCALAR lower, const SCALAR upper); \
142 template TimeRange< SCALAR > invalidTimeRange(); \
143 template std::ostream& operator<<( std::ostream& out, const TimeRange< SCALAR >& range ); \
144 template void asssertInTimeRange( const TimeRange<SCALAR > &timeRange, const SCALAR &time ); \
145 template bool isInRange_cc(const TimeRange< SCALAR > &tr, const SCALAR &p); \
146 template bool isInRange_oc(const TimeRange< SCALAR > &tr, const SCALAR &p); \
147 template bool isInRange_co(const TimeRange< SCALAR > &tr, const SCALAR &p); \
148 template bool isInRange_oo(const TimeRange< SCALAR > &tr, const SCALAR &p); \
149 template class TimeRange_cc< SCALAR >; \
150 template class TimeRange_co< SCALAR >; \
151 template class TimeRange_oo< SCALAR >; \
152 template class TimeRange_oc< SCALAR >;
155 #endif //RYTHMOS_TIME_RANGE_DEF_H
TimeRange< TimeType > timeRange(const TimeType my_lower, const TimeType my_upper)
Nonmember constructor.
int compareTimeValues(const TimeType &t1, const TimeType &t2)
Compare two times taking into account floating point errors.