-
Notifications
You must be signed in to change notification settings - Fork 2
/
project2_Delaunoy_Crasset_IO.h
163 lines (149 loc) · 3.9 KB
/
project2_Delaunoy_Crasset_IO.h
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
#ifndef IO_H_
#define IO_H_
#define MAX_FILENAME_SIZE 500
/**
* Structure representing the parameters with which
* to make the computations
*/
typedef struct Parameters {
const char* filename;
double g;
double gamma;
double deltaX;
double deltaY;
double deltaT;
double TMax;
double A;
double f;
unsigned int S;
unsigned int s;
double r_threshold;
} Parameters;
/**
* Structure representing a map
*/
typedef struct Map {
double a;
double b;
int X;
int Y;
double dx;
double dy;
double** grid;
} Map;
/**
* Compute the value of the map at a given point using bilinear interpolation
*
* Parameters:
* map: The map used
* x: The x coordinate at which to evaluate the map
* y: The y coordinate at which to evaluate the map
*
* Returns:
* The evaluation of map a point x, y
*/
double bilinearInterpolation(Map* map, double x, double y);
/**
* Compute the value of the map at a given point
*
* Parameters:
* map: The map used
* x: The x coordinate at which to evaluate the map
* y: The y coordinate at which to evaluate the map
*
* Returns:
* The evaluation of map a point x, y
*/
double getGridValueAtDomainCoordinates(Map* map, double x, double y);
/**
* Allocate a double matrix
*
* Parameters:
* x: The first index size
* y: The second index size
*
* Returns:
* The allocated matrix
*/
double** allocateDoubleMatrix(int x, int y);
/**
* Free a double matrix
*
* Parameters:
* matrix: The matrix to free
* x: The first index size
*/
void freeDoubleMatrix(double** matrix, int x);
/**
* Tansform a matrix to a 1d flattenned array
*
* Parameters:
* matrix: The matrix to flatten
* x: The first index size
* y: The second index size
*
* Returns:
* The flattenned array
*/
double* transformMatrixToArray(double** matrix, int x, int y);
/**
* Read a map file and load it in a Map structure
*
* Parameters:
* filename: The name of the file to load
*
* Returns:
* A pointer to a Map structure containing the info in the file
*/
Map* readMapFile(const char* filename);
/**
* Read a parameter file and load it in a Parameters structure
*
* Parameters:
* filename: The name of the file to load
*
* Returns:
* A pointer to a Parameters structure containing the info in the file
*/
Parameters* readParameterFile(const char* filename);
/**
* Write an array into a file
*
* Parameters:
* filename: The name of the file in which to write the array
* xsize: The size of the discretization along the x axis
* ysize: The size of the discretization along the y axis
* array: The array to write in the file
*/
void writeResultArray(char* filename, int xsize, int ysize,double* array);
/**
* Build file names for each variable to save
*
* Parameters:
* etaName: A pointer to char that will be set to the name of eta
* uName: A pointer to char that will be set to the name of u
* vName: A pointer to char that will be set to the name of v
* dir_name: A string containg the name of the directory to include in the filename
* iteration: The iteration at which to make the save
*/
void getFileNames(char* etaName, char* uName, char* vName, char* dir_name, unsigned int iteration);
/**
* Save system state to disk
*
* Parameters:
* etaTotal: An array containing the values of eta
* uTotal: An array containing the values of u
* vTotal: An array containing the values of v
* xSize: The size of the discretization along the x axis
* ySize: The size of the discretization along the y axis
* iteration: The iteration at which the save is performed
* params: The parameters of the run
* nbproc: The number of processes
* nbthreads: The number of threads
*
* Returns:
* A pointer to a Map structure containing the info in the file
*/
void saveToDisk(double* etaTotal, double* uTotal, double* vTotal, unsigned int xSize,
unsigned int ySize, unsigned int iteration, Parameters* params, int nbproc, int nbthreads);
#endif // IO_H_