-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.cpp
200 lines (190 loc) · 10.8 KB
/
debug.cpp
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
#include "debug.h"
void debug_projectile_par(int i_sn, int j, double borderP,
double newRho, double newVx, double newE, double newP,
double final_psi, double x_sn)
{
std::cout << std::endl <<
"i_sn = " << i_sn << std::endl <<
"x_sn = " << x_sn << std::endl <<
"j = " << j << std::endl <<
"borderP = " << borderP << std::endl <<
"newRho = " << newRho << std::endl <<
"newVx = " << newVx << std::endl <<
"newE = " << newE << std::endl <<
"newP = " << newP << std::endl <<
"Final_psi = " << final_psi << std::endl << std::endl;
}
void debug_type1_cell(int i, int j, double sin_a, double cos_a,
double xbegin, double ybegin, double xend, double yend,
double r_1, double r_2,
double center_d, double center_dx, double center_dy,
Point2D vertices[4])
{
std::cout << "i = " << i << std::endl <<
"j = " << j << std::endl <<
"cos_a = " << cos_a << std::endl <<
"sin_a = " << sin_a << std::endl <<
"r_1 = " << r_1 << std::endl <<
"r_2 = " << r_2 << std::endl <<
"xbegin = " << xbegin << std::endl <<
"ybegin = " << ybegin << std::endl <<
"xend = " << xend << std::endl <<
"yend = " << yend << std::endl <<
"point 0 = " << vertices[0].x << ":" << vertices[0].y << std::endl <<
"point 1 = " << vertices[1].x << ":" << vertices[1].y << std::endl <<
"point 2 = " << vertices[2].x << ":" << vertices[2].y << std::endl <<
"point 3 = " << vertices[3].x << ":" << vertices[3].y << std::endl <<
"center_d = " << center_d << std::endl <<
"center_dx = " << center_dx << std::endl <<
"center_dy = " << center_dy << std::endl;
std::cout << std::endl;
}
void debug_weights(int i, int j, double P, std::vector < WeightPart > weightVector)
{
std::cout << "i = " << i << ", j = " << j << ", P[0] = " << P << std::endl;
std::cout << "Weights: " << std::endl;
for (unsigned int idx2 = 0; idx2 < weightVector.size(); idx2++) {
std::cout << "Weight: i = " << weightVector[idx2].i << ", j = " << weightVector[idx2].j << ", weight = " << weightVector[idx2].weight << std::endl;
}
std::cout << std::endl;
}
void debug_equality_Vx_e(int i_sn, int max_j, int n, cell2d & cell)
{
for (int i = 1; i < i_sn; i++) {
for (int j = 1; j < max_j-3; j++) {
if (cell.at(n).at(i).at(j).type != 18) {
if (cell.at(n+1).at(i).at(j).e != cell.at(n+1).at(i).at(j+1).e) {
std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(16) << "E is different" << std::endl <<
"i = " << i << std::endl <<
"j = " << j << std::endl <<
"bar_E = " << cell.at(n).at(i).at(j).bar_e << std::endl <<
"lower bar_E = " << cell.at(n).at(i).at(j-1).bar_e << std::endl <<
"upper bar_E = " << cell.at(n).at(i).at(j+1).bar_e << std::endl <<
"E = " << cell.at(n+1).at(i).at(j).e << std::endl <<
"lower E = " << cell.at(n+1).at(i).at(j-1).e << std::endl <<
"upper E = " << cell.at(n+1).at(i).at(j+1).e << std::endl <<
"P = " << cell.at(n+1).at(i).at(j).P[0] << std::endl <<
"lower P = " << cell.at(n+1).at(i).at(j-1).P[0] << std::endl <<
"upper P = " << cell.at(n+1).at(i).at(j+1).P[0] << std::endl <<
"bar_Vx = " << cell.at(n).at(i).at(j).bar_Vx[0] << std::endl <<
"lower bar_Vx = " << cell.at(n).at(i).at(j-1).bar_Vx[0] << std::endl <<
"upper bar_Vx = " << cell.at(n).at(i).at(j+1).bar_Vx[0] << std::endl <<
"Vx = " << cell.at(n+1).at(i).at(j).Vx[0] << std::endl <<
"lower Vx = " << cell.at(n+1).at(i).at(j-1).Vx[0] << std::endl <<
"upper Vx = " << cell.at(n+1).at(i).at(j+1).Vx[0] << std::endl <<
"rho = " << cell.at(n+1).at(i).at(j).rho << std::endl <<
"lower rho = " << cell.at(n+1).at(i).at(j-1).rho << std::endl <<
"upper rho = " << cell.at(n+1).at(i).at(j+1).rho << std::endl <<
"prev rho = " << cell.at(n).at(i).at(j).rho << std::endl <<
"lower prev rho = " << cell.at(n).at(i).at(j-1).rho << std::endl <<
"upper prev rho = " << cell.at(n).at(i).at(j+1).rho << std::endl <<
"dM = {" << cell.at(n).at(i).at(j).dM[1] << ", " << cell.at(n).at(i).at(j).dM[2] << ", " << cell.at(n).at(i).at(j).dM[3] << ", " << cell.at(n).at(i).at(j).dM[4] << "} " << std::endl <<
"lower dM = {" << cell.at(n).at(i).at(j-1).dM[1] << ", " << cell.at(n).at(i).at(j-1).dM[2] << ", " << cell.at(n).at(i).at(j-1).dM[3] << ", " << cell.at(n).at(i).at(j-1).dM[4] << "} " << std::endl <<
"upper dM = {" << cell.at(n).at(i).at(j+1).dM[1] << ", " << cell.at(n).at(i).at(j+1).dM[2] << ", " << cell.at(n).at(i).at(j+1).dM[3] << ", " << cell.at(n).at(i).at(j+1).dM[4] << "} " << std::endl << std::endl;
for (int k = 1; k < 5; k++)
if (cell.at(n).at(i).at(j).dM[k] != 0)
std::cout << "dM[" << k << "] != 0" << std::endl;
if (cell.at(n+1).at(i).at(j).rho != cell.at(n+1).at(i).at(j+1).rho)
std::cout << "rho(j) != rho(j+1)" << std::endl;
if (cell.at(n).at(i).at(j).bar_e != cell.at(n).at(i).at(j+1).bar_e)
std::cout << "bar_e(j) != bar_e(j+1)" << std::endl;
getchar();
}
if (cell.at(n+1).at(i).at(j).Vx[0] != cell.at(n+1).at(i).at(j+1).Vx[0]) {
std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(16) << "Vx is different" << std::endl <<
"i = " << i << std::endl <<
"j = " << j << std::endl <<
"bar_E = " << cell.at(n).at(i).at(j).bar_e << std::endl <<
"lower bar_E = " << cell.at(n).at(i).at(j-1).bar_e << std::endl <<
"upper bar_E = " << cell.at(n).at(i).at(j+1).bar_e << std::endl <<
"E = " << cell.at(n+1).at(i).at(j).e << std::endl <<
"lower E = " << cell.at(n+1).at(i).at(j-1).e << std::endl <<
"upper E = " << cell.at(n+1).at(i).at(j+1).e << std::endl <<
"P = " << cell.at(n+1).at(i).at(j).P[0] << std::endl <<
"lower P = " << cell.at(n+1).at(i).at(j-1).P[0] << std::endl <<
"upper P = " << cell.at(n+1).at(i).at(j+1).P[0] << std::endl <<
"bar_Vx = " << cell.at(n).at(i).at(j).bar_Vx[0] << std::endl <<
"lower bar_Vx = " << cell.at(n).at(i).at(j-1).bar_Vx[0] << std::endl <<
"upper bar_Vx = " << cell.at(n).at(i).at(j+1).bar_Vx[0] << std::endl <<
"Vx = " << cell.at(n+1).at(i).at(j).Vx[0] << std::endl <<
"lower Vx = " << cell.at(n+1).at(i).at(j-1).Vx[0] << std::endl <<
"upper Vx = " << cell.at(n+1).at(i).at(j+1).Vx[0] << std::endl <<
"rho = " << cell.at(n+1).at(i).at(j).rho << std::endl <<
"lower rho = " << cell.at(n+1).at(i).at(j-1).rho << std::endl <<
"upper rho = " << cell.at(n+1).at(i).at(j+1).rho << std::endl <<
"prev rho = " << cell.at(n).at(i).at(j).rho << std::endl <<
"lower prev rho = " << cell.at(n).at(i).at(j-1).rho << std::endl <<
"upper prev rho = " << cell.at(n).at(i).at(j+1).rho << std::endl <<
"dM = {" << cell.at(n).at(i).at(j).dM[1] << ", " << cell.at(n).at(i).at(j).dM[2] << ", " << cell.at(n).at(i).at(j).dM[3] << ", " << cell.at(n).at(i).at(j).dM[4] << "} " << std::endl <<
"lower dM = {" << cell.at(n).at(i).at(j-1).dM[1] << ", " << cell.at(n).at(i).at(j-1).dM[2] << ", " << cell.at(n).at(i).at(j-1).dM[3] << ", " << cell.at(n).at(i).at(j-1).dM[4] << "} " << std::endl <<
"upper dM = {" << cell.at(n).at(i).at(j+1).dM[1] << ", " << cell.at(n).at(i).at(j+1).dM[2] << ", " << cell.at(n).at(i).at(j+1).dM[3] << ", " << cell.at(n).at(i).at(j+1).dM[4] << "} " << std::endl << std::endl;
for (int k = 1; k < 5; k++)
if (cell.at(n).at(i).at(j).dM[k] != 0)
std::cout << "dM[" << k << "] != 0" << std::endl;
if (cell.at(n+1).at(i).at(j).rho != cell.at(n+1).at(i).at(j+1).rho)
std::cout << "rho(j) != rho(j+1)" << std::endl;
if (cell.at(n).at(i).at(j).bar_e != cell.at(n).at(i).at(j+1).bar_e)
std::cout << "bar_e(j) != bar_e(j+1)" << std::endl;
getchar();
}
}
}
}
}
void debug_p_output(int n, int nArray, int *i, int *j, cell2d & cell)
{
for (int iter = 0; iter < nArray; iter++) {
std::cout << "For i = " << i[iter] << ", j = " << j[iter] << ", P[0] = " << cell.at(n+1).at(i[iter]).at(j[iter]).P[0] << std::endl;
}
std::cout << std::endl;
}
void debug_dM_rho_output(int n, int nArray, int *i, int *j, cell2d & cell)
{
for (int iter = 0; iter < nArray; iter++) {
std::cout << "For i = " << i[iter] << ", j = " << j[iter] << ", dM = {" << cell.at(n).at(i[iter]).at(j[iter]).dM[1] << ", " << cell.at(n).at(i[iter]).at(j[iter]).dM[2] << ", " << cell.at(n).at(i[iter]).at(j[iter]).dM[3] << ", " << cell.at(n).at(i[iter]).at(j[iter]).dM[4] << "}" << std::endl <<
"rho = " << std::setiosflags(std::ios::fixed) << std::setprecision(16) << cell.at(n+1).at(i[iter]).at(j[iter]).rho << std::endl;
}
std::cout << std::endl;
}
void debug_Vx_Vr_P_A_barVx_output(int n, int nArray, int *i, int *j, cell2d & cell)
{
for (int iter = 0; iter < nArray; iter++) {
gasCell * curCell = &cell.at(n+1).at(i[iter]).at(j[iter]);
gasCell * prevCell = &cell.at(n).at(i[iter]).at(j[iter]);
std::cout << "For i = " << i[iter] << ", j = " << j[iter] << std::endl <<
"Vx = " << curCell->Vx[0] << std::endl <<
"Vr = " << curCell->Vr[0] << std::endl <<
"P = {" << curCell->P[0] << ", " << curCell->P[1] << ", " << curCell->P[2] << ", " << curCell->P[3] << ", " << curCell->P[4] << "}" << std::endl <<
"A = {" << curCell->A[1] << ", " << curCell->A[2] << ", " << curCell->A[3] << ", " << curCell->A[4] << "}" << std::endl <<
"bar_Vx = " << prevCell->bar_Vx[0] << ", bar_Vr = " << prevCell->bar_Vr[0] << ", bar_e = " << prevCell->bar_e << std::endl << std::endl;
}
std::cout << std::endl;
}
void debug_final_output(int n, int nArray, int *i, int *j, cell2d & cell) {
for (int iter = 0; iter < nArray; iter++) {
printf("E at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n+1).at(i[iter]).at(j[iter]).e);
printf("rho at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n+1).at(i[iter]).at(j[iter]).rho);
printf("dM[1] at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n).at(i[iter]).at(j[iter]).dM[1]);
printf("dM[2] at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n).at(i[iter]).at(j[iter]).dM[2]);
printf("dM[3] at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n).at(i[iter]).at(j[iter]).dM[3]);
printf("dM[4] at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n).at(i[iter]).at(j[iter]).dM[4]);
printf("barVx at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n).at(i[iter]).at(j[iter]).bar_Vx[0]);
printf("barVr at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n).at(i[iter]).at(j[iter]).bar_Vr[0]);
printf("Vx at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n+1).at(i[iter]).at(j[iter]).Vx[0]);
printf("Vr at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n+1).at(i[iter]).at(j[iter]).Vr[0]);
printf("Final_psi at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n+1).at(i[iter]).at(j[iter]).final_psi);
printf("Final_z at %d:%d = %16.16f\n",
i[iter],j[iter],cell.at(n+1).at(i[iter]).at(j[iter]).final_z);
}
}