-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDynamics.hh
53 lines (51 loc) · 1.37 KB
/
Dynamics.hh
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
#ifndef DYNAMICS
#define DYNAMICS
#include "TileVariable.hh"
template<int order>
class Dynamics{
typedef TileVariable<order/2> Tile;
protected:
FiniteDifference<1> diff;
float dx, dy, f;
public:
Dynamics(){
dx = 1.;
dy = 1.;
f = 2.;
}
inline void advection(
const Tile &uwind,
const Tile &vwind,
Tile &result) const{
result.main_t() += (
diff.x(uwind.main() * result.mainx(), dx)
+ diff.y(vwind.main() * result.mainy(), dy)
);
}
inline void self_advection(
Tile &uwind,
Tile &vwind) const{
uwind.main_t() += (
diff.x(uwind.mainx() * uwind.mainx(), dx)
+ diff.y(uwind.mainy() * vwind.mainx(), dy)
);
vwind.main_t() += (
diff.y(vwind.mainy() * vwind.mainy(), dy)
+ diff.x(uwind.mainy() * vwind.mainx(), dx)
);
}
inline void coriolis(
Tile &uwind,
Tile &vwind) const{
uwind.main_t() += f * vwind.v_to_u();
vwind.main_t() += - f * uwind.u_to_v();
}
inline void gradient(
const Tile &phi,
Tile &vx,
Tile &vy) const{
vx.main_t() += diff.x(phi.extendx(), dx);
vy.main_t() += diff.y(phi.extendy(), dy);
}
};
#endif