-
Notifications
You must be signed in to change notification settings - Fork 3
/
butterfly_csv.cpp
52 lines (42 loc) · 1.19 KB
/
butterfly_csv.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
#include "butterfly.h"
#include "phasing.c"
int main(int argc, char** argv)
{
init_from_file(argv[1]);
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();
}
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 fname[100];
for(int i=0; i<SENSORS; i++)
{
sprintf(fname, "%s_%s_%03d.csv", argv[1], argv[2], 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.2/C0;
T_FINISH = 2.2*Y/C0;
written = 0;
while(T_FINISH > 0) calc_a_step();
fclose(f_csv);
printf("%3dth sensor of %d calculated\n", i, SENSORS);
}
sprintf(fname, "%s_%s", argv[1], argv[2]);
phasing(fname, 0.0);
finalize();
return 0;
}