-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parallel_Statistics_OLD.m
274 lines (234 loc) · 9.54 KB
/
Parallel_Statistics_OLD.m
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
% Parallel_Statistics
% Function to compute the all Single Point Statistics
%
% Author: Julio Barros - UIUC 2011
% version: 2.2
clear all
close all
clc
%%%%%%%%%%%%%
% USER INPUTS
%%%%%%%%%%%%%
%ext = input('Type, the extention of the files to be processed (eg: *.vec): ','s');
type = input('Type if it is 2D, Stereo, 3D: ','s');
if strcmp(type,'2D') == 1
ext = '*.vec';
elseif strcmp(type,'Stereo') == 1
ext = '*.v3d';
elseif strcmp(type,'3D') == 1
ext = '*.v3v';
else
disp('You did not choose the correct option')
break
end
% Dealing with slash on all OS
if ispc == 1
slash = '\';
else
slash = '/';
end
pathDir = uigetdir('','Select the dir which has the files to be processed');
files = dir(strcat(pathDir,slash,ext));
if isempty(files) == 1
ext = '*.dat';
files = dir(strcat(pathDir,slash,ext));
end
ResultsFol = strcat(pathDir,slash,'Results',slash);
%%%%%%%%%%%%%%%%%%%%%%
%files = files(1:100); %DEBUG PURPOSE
%%%%%%%%%%%%%%%%%%%%%%
disp('Do you want to specify a Region of interest?');
ROI = input('y , n?: ','s');
if strcmp(ROI,'y')==1 || strcmp(ROI,'Y')==1
disp('Format: [left right bottom top]')
crop = input('Type the ROI: ');
else
crop = [1 1 1 1];
end
disp('Do you want to save the Fluctuation files?')
flucask = input('y or n?: ','s');
disp('Which direction do you want to caculate the line average?')
disp('1. Horizintal (across rows)')
disp('2. Vertical (across columns)')
direction = input(':? ');
% Close if there is any open pool
if matlabpool('size') > 0;
matlabpool close force local
end
% Start the Parallel pools
matlabpool open
cores = matlabpool('size'); % Number of cores availabe in the computer
tstart_p = tic; % Start computing Time
% Split the list of the files into the number of cores
[CompVecList] = DistVecContent(cores,files);
disp('Calculating the Ensemble Average')
[AxisCell,Ucell,Lciavg,Omega_avg,CHCavg] = ensembleAverage(CompVecList,cores,crop,pathDir);
disp('')
disp('Calculating the Reynolds Stresses')
[uiujCell,lci,omega] = ReynoldsStress(CompVecList,cores,Ucell,Lciavg,Omega_avg,crop,pathDir,flucask);
% Determine the size of the final variables
[J,I] = size(Ucell{1});
N = length(Ucell);
% Putting all the variables in a Tecplot form
vel = mixingCell_Stat(I,J,AxisCell,Ucell,uiujCell,Lciavg,Omega_avg,lci,omega,CHCavg);
vel = dealNaN(vel);
vel = sortrows(vel, [2 , 1]);
if N == 2
TecplotHeader = ['VARIABLES="x", "y",'...
'"<math>a</math>U<math>q</math>", '...
'"<math>a</math>V<math>q</math>", '...
'"<math>a</math>u<sup>2</sup><math>q</math>", '...
'"<math>a</math>uv<math>q</math>", '...
'"<math>a</math>v<sup>2</sup><math>q</math>", '...
'"<math>a</math>Lci<math>q</math>", '...
'"<math>a</math>Omega<math>q</math>", '...
'"<math>a</math>lci<sub>rms</sub><math>q</math>", '...
'"<math>a</math>omega<sub>rms</sub><math>q</math>", '...
'"CHC" ' ...
'ZONE I=' num2str(I) ', J=' num2str(J) ', K=1, F=POINT'];
elseif N == 3
TecplotHeader = ['VARIABLES="x", "y", "z",'...
'"<math>a</math>U<math>q</math>", '...
'"<math>a</math>V<math>q</math>", '...
'"<math>a</math>W<math>q</math>", '...
'"<math>a</math>u<sup>2</sup><math>q</math>", '...
'"<math>a</math>uv<math>q</math>", '...
'"<math>a</math>uw<math>q</math>", '...
'"<math>a</math>v<sup>2</sup><math>q</math>", '...
'"<math>a</math>vw<math>q</math>", '...
'"<math>a</math>w<sup>2</sup><math>q</math>", '...
'"<math>a</math>Lci<math>q</math>", '...
'"<math>a</math>Omega<math>q</math>", '...
'"<math>a</math>lci<sub>rms</sub><math>q</math>", '...
'"<math>a</math>omega<sub>rms</sub><math>q</math>", '...
'"CHC" ' ...
'ZONE I=' num2str(I) ', J=' num2str(J) ', K=1, F=POINT'];
end
saver(ResultsFol,'EnsembleAverage_v2_2.dat',TecplotHeader,vel);
% Calculates the Line Average
if direction == 1
if N == 2
x = AxisCell{1}(1,:);
U = nanmean(Ucell{1},direction);
V = nanmean(Ucell{2},direction);
uu = nanmean(uiujCell{1},direction);
uv = nanmean(uiujCell{2},direction);
vv = nanmean(uiujCell{3},direction);
Lcil = nanmean(Lciavg,direction);
Omegal = nanmean(Omega_avg,direction);
lcil = nanmean(lci,direction);
omegal = nanmean(omega,direction);
tj = I;
TecplotHeader2 = ['VARIABLES="x",'...
'"<math>a</math>U<math>q</math>", '...
'"<math>a</math>V<math>q</math>", '...
'"<math>a</math>u<sup>2</sup><math>q</math>", '...
'"<math>a</math>uv<math>q</math>", '...
'"<math>a</math>v<sup>2</sup><math>q</math>", '...
'"<math>a</math>Lci<math>q</math>", '...
'"<math>a</math>Omega<math>q</math>", '...
'"<math>a</math>lci<sub>rms</sub><math>q</math>", '...
'"<math>a</math>omega<sub>rms</sub><math>q</math>", '...
'ZONE I=1, J=' num2str(tj) ', K=1, F=POINT'];
vel_l = [x' U' V' uu' uv' vv' Lcil' Omegal' lcil' omegal'];
elseif N == 3
x = AxisCell{1}(1,:);
U = nanmean(Ucell{1},direction);
V = nanmean(Ucell{2},direction);
W = nanmean(Ucell{3},direction);
uu = nanmean(uiujCell{1},direction);
uv = nanmean(uiujCell{2},direction);
uw = nanmean(uiujCell{3},direction);
vv = nanmean(uiujCell{4},direction);
vw = nanmean(uiujCell{5},direction);
ww = nanmean(uiujCell{6},direction);
Lcil = nanmean(Lciavg,direction);
Omegal = nanmean(Omega_avg,direction);
lcil = nanmean(lci,direction);
omegal = nanmean(omega,direction);
tj = I;
TecplotHeader2 = ['VARIABLES="y", '...
'"<math>a</math>U<math>q</math>", '...
'"<math>a</math>V<math>q</math>", '...
'"<math>a</math>W<math>q</math>", '...
'"<math>a</math>u<sup>2</sup><math>q</math>", '...
'"<math>a</math>uv<math>q</math>", '...
'"<math>a</math>uw<math>q</math>", '...
'"<math>a</math>v<sup>2</sup><math>q</math>", '...
'"<math>a</math>vw<math>q</math>", '...
'"<math>a</math>w<sup>2</sup><math>q</math>", '...
'"<math>a</math>Lci<math>q</math>", '...
'"<math>a</math>Omega<math>q</math>", '...
'"<math>a</math>lci<sub>rms</sub><math>q</math>", '...
'"<math>a</math>omega<sub>rms</sub><math>q</math>", '...
'ZONE I=1, J=' num2str(J) ', K=1, F=POINT'];
vel_l = [x' U' V' W' uu' uv' uw' vv' vw' ww' Lcil' Omegal' lcil' omegal'];
end
elseif direction == 2
if N == 2
y = AxisCell{2}(:,1);
U = nanmean(Ucell{1},direction);
V = nanmean(Ucell{2},direction);
uu = nanmean(uiujCell{1},direction);
uv = nanmean(uiujCell{2},direction);
vv = nanmean(uiujCell{3},direction);
Lcil = nanmean(Lciavg,direction);
Omegal = nanmean(Omega_avg,direction);
lcil = nanmean(lci,direction);
omegal = nanmean(omega,direction);
tj = J;
TecplotHeader2 = ['VARIABLES="y",'...
'"<math>a</math>U<math>q</math>", '...
'"<math>a</math>V<math>q</math>", '...
'"<math>a</math>u<sup>2</sup><math>q</math>", '...
'"<math>a</math>uv<math>q</math>", '...
'"<math>a</math>v<sup>2</sup><math>q</math>", '...
'"<math>a</math>Lci<math>q</math>", '...
'"<math>a</math>Omega<math>q</math>", '...
'"<math>a</math>lci<sub>rms</sub><math>q</math>", '...
'"<math>a</math>omega<sub>rms</sub><math>q</math>", '...
'ZONE I=1, J=' num2str(J) ', K=1, F=POINT'];
vel_l = [y U V uu uv vv Lcil Omegal lcil omegal];
elseif N == 3
y = AxisCell{2}(:,1);
U = nanmean(Ucell{1},direction);
V = nanmean(Ucell{2},direction);
W = nanmean(Ucell{3},direction);
uu = nanmean(uiujCell{1},direction);
uv = nanmean(uiujCell{2},direction);
uw = nanmean(uiujCell{3},direction);
vv = nanmean(uiujCell{4},direction);
vw = nanmean(uiujCell{5},direction);
ww = nanmean(uiujCell{6},direction);
Lcil = nanmean(Lciavg,direction);
Omegal = nanmean(Omega_avg,direction);
lcil = nanmean(lci,direction);
omegal = nanmean(omega,direction);
tj = J;
TecplotHeader2 = ['VARIABLES="y" '...
'"<math>a</math>U<math>q</math>", '...
'"<math>a</math>V<math>q</math>", '...
'"<math>a</math>W<math>q</math>", '...
'"<math>a</math>u<sup>2</sup><math>q</math>", '...
'"<math>a</math>uv<math>q</math>", '...
'"<math>a</math>uw<math>q</math>", '...
'"<math>a</math>v<sup>2</sup><math>q</math>", '...
'"<math>a</math>vw<math>q</math>", '...
'"<math>a</math>w<sup>2</sup><math>q</math>", '...
'"<math>a</math>Lci<math>q</math>", '...
'"<math>a</math>Omega<math>q</math>", '...
'"<math>a</math>lci<sub>rms</sub><math>q</math>", '...
'"<math>a</math>omega<sub>rms</sub><math>q</math>", '...
'ZONE I=1, J=' num2str(J) ', K=1, F=POINT'];
vel_l = [y U V W uu uv uw vv vw ww Lcil Omegal lcil omegal];
end
end
vel_l = dealNaN(vel_l);
vel_l = sortrows(vel_l,1);
% Save the file
saver(ResultsFol,'Line_Average_V2_2.dat',TecplotHeader2,vel_l);
tstop_p = toc(tstart_p);
disp('DONE')
disp([num2str(tstop_p/60) ' minutes taken'])
% Close Matlab Pool
matlabpool close