-
Notifications
You must be signed in to change notification settings - Fork 3
/
butterfly_serial.cpp
79 lines (70 loc) · 2.22 KB
/
butterfly_serial.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
#include "butterfly.h"
#include "phasing.c"
#define N_C 11
#define N_S 1
int main(int argc, char** argv)
{
init_from_file(argv[1]);
FILE* setup = fopen(argv[2], "r");
if (!setup)
{
printf("No file opened\n");
exit(-1);
}
fscanf(setup, "%d%lf%lf", &rays_num, &focus, &PIES);
fclose(setup);
char ftemplate[100];
double c_rel = obstacles[0].c_rel;//, dc = 0.01;
//for (int c = 0; c < N_C; c++)
//{
obstacles[0].c_rel = c_rel;
for(int i=0; i<SENSORS; i++)
{
sensors[i].pos.y = Y*0.999;
sensors[i].pos.x = X/2 - DX_SENSORS * (SENSORS / 2 - i);
sensors[i].writing.clear();
}
init_from_file(argv[1]);
//for (int i=0; i<2; i++)
//{
//obstacles[0].c_rel = c_rel;
double shift = 0.0, ds = 10.0 / N_S;
for (int i=0; i<VERTICES; i++)
obstacles[0].pos[i].x += shift;
for (int s = 0; s < N_S; s++)
{
sprintf(ftemplate, "finfin_%s_shift_%.2lf_c_%.1lf", argv[1], shift, c_rel);
char fname[100];
for(int i=0; i<SENSORS; i++)
{
sprintf(fname, "%s_%03d.csv", ftemplate, i);
f_csv = fopen(fname, "w");
if (!f_csv)
{
printf("No file opened\n");
exit(-1);
}
init_explosion(X/2 - DX_SENSORS * (SENSORS / 2 - i), Y*0.999);
T_START = SENSORS*DX_SENSORS*1.0/C0;
T_FINISH = 1.8*Y/C0;
written = 0;
for(int i=0; i<SENSORS; i++)
sensors[i].writing.clear();
nonidiocy = 1;
while(T_FINISH > 0) calc_a_step();
fclose(f_csv);
printf("%3dth sensor of %d calculated\n", i, SENSORS);
finalize();
}
phasing(ftemplate, 0.0);
printf("c %lf shift %d of %d\n", c_rel, s, N_S);
for (int i=0; i<VERTICES; i++)
obstacles[0].pos[i].x += ds;
shift += ds;
}
//c_rel += 0.2;
//}
// c_rel += dc;
//}
return 0;
}