-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmoving_window.cuh
57 lines (46 loc) · 993 Bytes
/
moving_window.cuh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef __MOVING_WINDOW__
#define __MOVING_WINDOW__
class MovingWindow {
private:
double dx_;
bool active_;
unsigned int n_move_;
public:
MovingWindow() : active_(false), n_move_(0), dx_(0) {};
/**
* @brief Turns moving window on
*
*/
void init( float const dx ) {
active_ = true;
n_move_ = 0;
dx_ = dx;
}
bool active() const {
return active_;
}
unsigned int n_move() const {
return n_move_;
}
/**
* @brief Advances the window
*
* @return int Total number of cells moved
*/
int advance() {
if ( active_ ) n_move_++;
return n_move_;
}
/**
* @brief Total length moved
*
* @return double Total length moved by the window
*/
double motion( ) const {
return n_move_ * dx_;
}
bool needs_move( double const t ) const {
return active_ && (t > dx_*(n_move_+1));
}
};
#endif