-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecl-RK.h
More file actions
216 lines (187 loc) · 7.76 KB
/
decl-RK.h
File metadata and controls
216 lines (187 loc) · 7.76 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
///////////////////////////////////////////////////////////
//
// This header file contains the declerations for the
// Runge-Kutta methods: RK4, RK3, RK2.
//
// These methods are derived from an abstract interface
// called "Explicit_Method". The idea is that standard
// Runge-Kutta can be used in explicit solvers. Nevertheless,
// an implicit solver may employ parts of this algorithm.
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#ifndef DECLERATION_RUNG_KUT_H
#define DECLERATION_RUNG_KUT_H
#include "decl-export.h"
#include "decl-parallel.h"
//--------------------------------------------------------------
class Explicit_Method {
//--------------------------------------------------------------
// Abstract interface class
//--------------------------------------------------------------
public:
virtual Explicit_Method& advance_p1() = 0; // "covariant" return
virtual Explicit_Method& advance_p2() = 0; // "covariant" return
virtual Explicit_Method& advance_IEx() = 0; // "covariant" return
virtual Explicit_Method& advance_IEy() = 0; // "covariant" return
virtual Explicit_Method& advance_IEz() = 0; // "covariant" return
virtual double& tout() = 0;
virtual double time() const = 0;
virtual size_t numh() const = 0;
virtual ~Explicit_Method() = 0;
};
//--------------------------------------------------------------
//**************************************************************
//**************************************************************
// Decleration for the standard RK4 class
//**************************************************************
//**************************************************************
//--------------------------------------------------------------
class Runge_Kutta_4 : public Explicit_Method {
//--------------------------------------------------------------
// Decleration of the 4rth order Runge-Kutta Class
//--------------------------------------------------------------
public:
// Constructor
Runge_Kutta_4(Stat& Yin, int tout_start, Stat& Yin_e, Parallel_Environment& PE);
// Main function
Runge_Kutta_4& advance_p1();
Runge_Kutta_4& advance_p2();
Runge_Kutta_4& advance_IEx();
Runge_Kutta_4& advance_IEy();
Runge_Kutta_4& advance_IEz();
// Access
double& tout();
double time() const;
size_t numh() const;
private:
// Helper functions
Stat& F(Stat& Yslope);
// Variables
Stat& Y, Ye;
Stat Y0, Y1, Yh;
Actions Act;
// --- e-i
E_Actions E_Act;
Parallel_Environment& CX;
size_t num_h;
double h, t, Tout;
};
//--------------------------------------------------------------
//**************************************************************
//**************************************************************
// Decleration for RK3 (Osher&Shu Method) class
//**************************************************************
//**************************************************************
//--------------------------------------------------------------
class Runge_Kutta_3 : public Explicit_Method {
//--------------------------------------------------------------
// Decleration of the 3rd order Runge-Kutta Class
//--------------------------------------------------------------
public:
// Constructor
Runge_Kutta_3(Stat& Yin, int tout_start, Stat& Yin_e, Parallel_Environment& PE);
// Main function
Runge_Kutta_3& advance_p1();
Runge_Kutta_3& advance_p2();
Runge_Kutta_3& advance_IEx();
Runge_Kutta_3& advance_IEy();
Runge_Kutta_3& advance_IEz();
// Access
double& tout();
double time() const;
size_t numh() const;
private:
// Helper functions
Stat& F(Stat& Yslope);
// Variables
Stat& Y, Ye;
Stat Y0, Yh;
Actions Act;
// --- e-i
E_Actions E_Act;
Parallel_Environment& CX;
size_t num_h;
double h, t, Tout;
};
//--------------------------------------------------------------
//**************************************************************
//**************************************************************
// Definition for RK2 (Heun's method) class
//**************************************************************
//**************************************************************
//--------------------------------------------------------------
class Runge_Kutta_2 : public Explicit_Method {
//--------------------------------------------------------------
// Decleration of the 2nd order Runge-Kutta Class
//--------------------------------------------------------------
public:
// Constructors
Runge_Kutta_2(Stat& Yin, int tout_start, Stat& Yin_e,Parallel_Environment& PE);
// Main function
Runge_Kutta_2& advance_p1();
Runge_Kutta_2& advance_p2();
Runge_Kutta_2& advance_IEx();
Runge_Kutta_2& advance_IEy();
Runge_Kutta_2& advance_IEz();
// Access
double& tout();
double time() const;
size_t numh() const;
private:
// Helper functions
Stat& F(Stat& Yslope);
// Variables
Stat& Y, Ye;
Stat Y0, Yh;
Actions Act;
// --- e-i
E_Actions E_Act;
Parallel_Environment& CX;
size_t num_h;
double h, t, Tout;
};
//--------------------------------------------------------------
//**************************************************************
//**************************************************************
// Definition for RK2 (Heun's method) class for implicit E
//**************************************************************
//**************************************************************
//--------------------------------------------------------------
class Runge_Kutta_2_Imp : public Explicit_Method {
//--------------------------------------------------------------
// Decleration of the 2nd order Runge-Kutta Class
//--------------------------------------------------------------
public:
// Constructors
Runge_Kutta_2_Imp(Stat& Yin, int tout_start, Stat& Ye, Parallel_Environment& PE);
// Main function
Runge_Kutta_2_Imp& advance_p1();
Runge_Kutta_2_Imp& advance_p2();
Runge_Kutta_2_Imp& advance_IEx();
Runge_Kutta_2_Imp& advance_IEy();
Runge_Kutta_2_Imp& advance_IEz();
// Access
double& tout();
double time() const;
size_t numh() const;
private:
// Helper functions
Stat& F1(Stat& Yslope);
Stat& F2(Stat& Yslope);
Stat& ImpEx(Stat& Yslope);
Stat& ImpEy(Stat& Yslope);
Stat& ImpEz(Stat& Yslope);
// Variables
Stat& Y, Ye;
Stat Y0, Yh;
Implicit_Actions Act;
size_t num_h; //WHY- num_h&h are CLF related
double h, t, Tout;
// --- e-i
E_Actions E_Act;
Parallel_Environment& CX;
};
//--------------------------------------------------------------
//**************************************************************
#endif