-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtxt_data.c
97 lines (82 loc) · 1.84 KB
/
txt_data.c
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
#include "header/txt_data.h"
#include "header/ui.h"
#include "header/phi.h"
#include "header/tortoise.h"
#include <stdio.h>
void
txt_data_wave(void)
{
FILE *fp;
fp = fopen("wave.txt", "w");
double x = ui_get_a();
double h = ui_get_h_forward();
double* phiRea = phi_get_rea();
double* phiImg = phi_get_img();
double* phiV = phi_get_v();
int i;
for (i = 0; i < NODES; i++)
{
fprintf(fp, "%.32f\t%.32f\t%.32f\t%.32f\n", x, phiRea[i], phiImg[i], phiV[i]);
x += h;
}
fclose(fp);
}
/**
@brief Compare the calculated value to the analytical one
*/
void
txt_data_turtle()
{
FILE *fp;
fp = fopen("turtle.txt", "w");
/* Calculated value */
GArray *xy = tortoise_get_xy();
/* Calculated value. We must invert it to be xy in gnuplot */
TPoint2D *yx = tortoise_get_yx();
/* Analytical value */
tortoise_xy_analytical();
double *xyAnalytical = tortoise_get_xy_analytical();
int i;
for (i = 0; i < NODES; i++)
{
fprintf(fp, "%.32f\t%.32f\t%.32f\t%.32f\n", point2D_get_x(g_array_index(xy, TPoint2D, i)), point2D_get_y(g_array_index(xy, TPoint2D, i)), xyAnalytical[i], point2D_get_y(yx[i]));
}
fclose(fp);
}
void
txt_data_rt()
{
FILE *fp;
fp = fopen("coefficients.txt", "w");
int nW = ui_get_nW();
double wMin = ui_get_wMin();
double hW = ui_get_hW();
double *R = phi_get_R();
double *T = phi_get_T();
double w;
int i;
for (i = 0; i < nW; i++)
{
w = wMin + hW*i;
fprintf(fp, "%.32f\t%.32f\t%.32f\t%.32f\n", w, R[i], T[i], R[i] + T[i]);
}
fclose(fp);
}
void
txt_data_sigma()
{
FILE *fp;
fp = fopen("sigma-l.txt", "w");
double wMin = ui_get_wMin();
int nW = ui_get_nW();
double hW = ui_get_hW();
double *deltaL = phi_get_deltaL();
double w;
int i;
for (i = 0; i < nW; i++)
{
w = wMin + hW*i;
fprintf(fp, "%.32f\t%.32f\n", w, deltaL[i]);
}
fclose(fp);
}