Rythmos - Transient Integration for Differential Equations
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Rythmos_TimeRange_decl.hpp
1
//@HEADER
2
// ***********************************************************************
3
//
4
// Rythmos Package
5
// Copyright (2006) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// This library is free software; you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as
12
// published by the Free Software Foundation; either version 2.1 of the
13
// License, or (at your option) any later version.
14
//
15
// This library is distributed in the hope that it will be useful, but
16
// WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
// Lesser General Public License for more details.
19
//
20
// You should have received a copy of the GNU Lesser General Public
21
// License along with this library; if not, write to the Free Software
22
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23
// USA
24
// Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
25
//
26
// ***********************************************************************
27
//@HEADER
28
29
#ifndef RYTHMOS_TIME_RANGE_DECL_H
30
#define RYTHMOS_TIME_RANGE_DECL_H
31
32
#include "Rythmos_ConfigDefs.h"
33
34
namespace
Rythmos {
35
36
61
template
<
class
TimeType>
62
int
compareTimeValues
(
const
TimeType &t1,
const
TimeType &t2 );
63
71
template
<
class
TimeType>
72
class
TimeRange
73
{
74
public
:
76
TimeRange
()
77
: lower_(0.0), upper_(-1.0)
78
{}
79
80
TimeRange
(
const
TimeType &my_lower,
const
TimeType &my_upper )
81
: lower_(my_lower), upper_(my_upper)
82
{
83
}
84
85
TimeRange
(
const
TimeRange<TimeType>
& tr )
86
: lower_(tr.
lower
()), upper_(tr.
upper
())
87
{
88
}
89
90
virtual
~TimeRange
() {}
92
bool
isValid
()
const
{
return
(lower_ <= upper_); }
94
TimeType
lower
()
const
{
return
lower_; }
96
TimeType
upper
()
const
{
return
upper_; }
98
TimeType
length
()
const
{
return
(upper_ - lower_); }
100
virtual
bool
isInRange
(
const
TimeType &t )
const
101
{
102
return
(
103
compareTimeValues
(t,lower_) >= 0
104
&&
compareTimeValues
(t,upper_) <= 0
105
);
106
}
107
108
TimeRange<TimeType>
copyAndScale
(
const
TimeType &scale )
const
109
{
110
TimeRange<TimeType>
newRange = *
this
;
111
if
(!newRange.
isValid
())
112
return
newRange;
113
newRange.lower_ *= scale;
114
newRange.upper_ *= scale;
115
return
newRange;
116
}
117
118
private
:
119
TimeType lower_;
120
TimeType upper_;
121
};
122
127
template
<
class
TimeType>
128
TimeRange<TimeType>
timeRange
(
const
TimeType my_lower,
const
TimeType my_upper);
129
130
135
template
<
class
TimeType>
136
TimeRange<TimeType>
invalidTimeRange
();
137
138
143
template
<
class
TimeType>
144
std::ostream&
operator<<
( std::ostream& out,
const
TimeRange<TimeType>
& range );
145
146
150
template
<
class
TimeType>
151
void
asssertInTimeRange(
const
TimeRange<TimeType>
&
timeRange
,
152
const
TimeType &time );
153
154
161
template
<
class
TimeType>
162
bool
isInRange_cc
(
const
TimeRange<TimeType>
&tr,
const
TimeType &p);
163
164
171
template
<
class
TimeType>
172
bool
isInRange_oc
(
const
TimeRange<TimeType>
&tr,
const
TimeType &p);
173
174
181
template
<
class
TimeType>
182
bool
isInRange_co
(
const
TimeRange<TimeType>
&tr,
const
TimeType &p);
183
184
191
template
<
class
TimeType>
192
bool
isInRange_oo
(
const
TimeRange<TimeType>
&tr,
const
TimeType &p);
193
194
template
<
class
TimeType>
195
class
TimeRange_cc :
virtual
public
TimeRange
<TimeType>
196
{
197
public
:
198
TimeRange_cc(
const
TimeRange<TimeType>
& tr)
199
:
TimeRange
<TimeType>(tr)
200
{
201
}
202
TimeRange_cc(
const
TimeType &my_lower,
const
TimeType &my_upper )
203
:
TimeRange
<TimeType>(my_lower,my_upper)
204
{
205
}
206
bool
isInRange (
const
TimeType &t )
const
207
{
208
return
(
isInRange_cc<TimeType>
(*
this
,t) );
209
}
210
};
211
212
template
<
class
TimeType>
213
class
TimeRange_co :
virtual
public
TimeRange
<TimeType>
214
{
215
public
:
216
TimeRange_co(
const
TimeRange<TimeType>
& tr)
217
:
TimeRange
<TimeType>(tr)
218
{
219
}
220
TimeRange_co(
const
TimeType &my_lower,
const
TimeType &my_upper )
221
:
TimeRange
<TimeType>(my_lower,my_upper)
222
{
223
}
224
bool
isInRange (
const
TimeType &t )
const
225
{
226
return
(
isInRange_co<TimeType>
(*
this
,t) );
227
}
228
};
229
230
template
<
class
TimeType>
231
class
TimeRange_oo :
virtual
public
TimeRange
<TimeType>
232
{
233
public
:
234
TimeRange_oo(
const
TimeRange<TimeType>
& tr)
235
:
TimeRange
<TimeType>(tr)
236
{
237
}
238
TimeRange_oo(
const
TimeType &my_lower,
const
TimeType &my_upper )
239
:
TimeRange
<TimeType>(my_lower,my_upper)
240
{
241
}
242
bool
isInRange (
const
TimeType &t )
const
243
{
244
return
(
isInRange_oo<TimeType>
(*
this
,t) );
245
}
246
};
247
248
template
<
class
TimeType>
249
class
TimeRange_oc :
virtual
public
TimeRange
<TimeType>
250
{
251
public
:
252
TimeRange_oc(
const
TimeRange<TimeType>
& tr)
253
:
TimeRange
<TimeType>(tr)
254
{
255
}
256
TimeRange_oc(
const
TimeType &my_lower,
const
TimeType &my_upper )
257
:
TimeRange
<TimeType>(my_lower,my_upper)
258
{
259
}
260
bool
isInRange (
const
TimeType &t )
const
261
{
262
return
(
isInRange_oc<TimeType>
(*
this
,t) );
263
}
264
};
265
266
267
}
// namespace Rythmos
268
269
270
#endif
//RYTHMOS_TIME_RANGE_DECL_H
Rythmos::TimeRange
Represent a time range.
Definition
Rythmos_TimeRange_decl.hpp:73
Rythmos::TimeRange::TimeRange
TimeRange(const TimeRange< TimeType > &tr)
Copy constructor.
Definition
Rythmos_TimeRange_decl.hpp:85
Rythmos::TimeRange::isInRange_cc
bool isInRange_cc(const TimeRange< TimeType > &tr, const TimeType &p)
Nonmember isInRange function [closed, closed].
Definition
Rythmos_TimeRange_def.hpp:97
Rythmos::TimeRange::isInRange_oo
bool isInRange_oo(const TimeRange< TimeType > &tr, const TimeType &p)
Nonmember isInRange function (open, open).
Definition
Rythmos_TimeRange_def.hpp:127
Rythmos::TimeRange::~TimeRange
virtual ~TimeRange()
Definition
Rythmos_TimeRange_decl.hpp:90
Rythmos::TimeRange::invalidTimeRange
TimeRange< TimeType > invalidTimeRange()
Nonmember constructor.
Rythmos::TimeRange::copyAndScale
TimeRange< TimeType > copyAndScale(const TimeType &scale) const
Definition
Rythmos_TimeRange_decl.hpp:108
Rythmos::TimeRange::isInRange
virtual bool isInRange(const TimeType &t) const
Definition
Rythmos_TimeRange_decl.hpp:100
Rythmos::TimeRange::TimeRange
TimeRange(const TimeType &my_lower, const TimeType &my_upper)
Construct a valid range.
Definition
Rythmos_TimeRange_decl.hpp:80
Rythmos::TimeRange::isValid
bool isValid() const
Definition
Rythmos_TimeRange_decl.hpp:92
Rythmos::TimeRange::lower
TimeType lower() const
Definition
Rythmos_TimeRange_decl.hpp:94
Rythmos::TimeRange::operator<<
std::ostream & operator<<(std::ostream &out, const TimeRange< TimeType > &range)
Output operator.
Definition
Rythmos_TimeRange_def.hpp:71
Rythmos::TimeRange::length
TimeType length() const
Definition
Rythmos_TimeRange_decl.hpp:98
Rythmos::TimeRange::compareTimeValues
int compareTimeValues(const TimeType &t1, const TimeType &t2)
Compare two times taking into account floating point errors.
Definition
Rythmos_TimeRange_def.hpp:38
Rythmos::TimeRange::isInRange_oc
bool isInRange_oc(const TimeRange< TimeType > &tr, const TimeType &p)
Nonmember isInRange function (open, closed].
Definition
Rythmos_TimeRange_def.hpp:107
Rythmos::TimeRange::isInRange_co
bool isInRange_co(const TimeRange< TimeType > &tr, const TimeType &p)
Nonmember isInRange function [closed, open).
Definition
Rythmos_TimeRange_def.hpp:117
Rythmos::TimeRange::TimeRange
TimeRange()
Construct an invalid range.
Definition
Rythmos_TimeRange_decl.hpp:76
Rythmos::TimeRange::timeRange
TimeRange< TimeType > timeRange(const TimeType my_lower, const TimeType my_upper)
Nonmember constructor.
Rythmos::TimeRange::upper
TimeType upper() const
Definition
Rythmos_TimeRange_decl.hpp:96
Generated by
1.17.0