-
Notifications
You must be signed in to change notification settings - Fork 6
/
DEMO_channelm.m
228 lines (192 loc) · 8.9 KB
/
DEMO_channelm.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
%
% Turbmat - a Matlab library for the JHU Turbulence Database Cluster
%
% Sample code, part of Turbmat
%
%
% Written by:
%
% Perry Johnson
% The Johns Hopkins University
% Department of Mechanical Engineering
%
% 2017: Modified by Zhao Wu and Rohit Ravoori, adding getInvariant
% 2019: Modified by Zhao Wu for getThreshold function
%
% This file is part of Turbmat.
%
% Turbmat is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your option)
% any later version.
%
% Turbmat is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
% more details.
%
% You should have received a copy of the GNU General Public License along
% with Turbmat. If not, see <http://www.gnu.org/licenses/>.
%
clear all;
close all;
authkey = 'edu.jhu.pha.turbulence.testing-201406';
dataset = 'channel';
% ---- Temporal Interpolation Options ----
NoTInt = 'None' ; % No temporal interpolation
PCHIPInt = 'PCHIP'; % Piecewise cubic Hermit interpolation in time
% ---- Spatial Interpolation Flags for getVelocity & getVelocityAndPressure ----
NoSInt = 'None'; % No spatial interpolation
Lag4 = 'Lag4'; % 4th order Lagrangian interpolation in space
Lag6 = 'Lag6'; % 6th order Lagrangian interpolation in space
Lag8 = 'Lag8'; % 8th order Lagrangian interpolation in space
% ---- Spatial Differentiation & Interpolation Flags for getVelocityGradient & getPressureGradient ----
FD4NoInt = 'None_Fd4' ; % 4th order finite differential scheme for grid values, no spatial interpolation
FD6NoInt = 'None_Fd6' ; % 6th order finite differential scheme for grid values, no spatial interpolation
FD8NoInt = 'None_Fd8' ; % 8th order finite differential scheme for grid values, no spatial interpolation
FD4Lag4 = 'Fd4Lag4' ; % 4th order finite differential scheme for grid values, 4th order Lagrangian interpolation in space
% ---- Spline interpolation and differentiation Flags for getVelocity,
% getPressure, getVelocityGradient, getPressureGradient,
% getVelocityHessian, getPressureHessian
M1Q4 = 'M1Q4'; % Splines with smoothness 1 (3rd order) over 4 data points. Not applicable for Hessian.
M2Q8 = 'M2Q8'; % Splines with smoothness 2 (5th order) over 8 data points.
M2Q14 = 'M2Q14'; % Splines with smoothness 2 (5th order) over 14 data points.
% Set time step to sample
time = 0.364;
% getPosition integration settings
startTime=0.364;
endTime=0.429;
lagDt=0.0065;
% for thresholding
threshold_field = 'vorticity';
threshold = 130.0;
x_start = int32(1);
y_start = int32(1);
z_start = int32(1);
x_end = int32(16);
y_end = int32(16);
z_end = int32(16);
npoints = 10;
points = zeros(3,npoints);
result1 = zeros(npoints);
result2 = zeros(2,npoints);
result3 = zeros(3,npoints);
result4 = zeros(4,npoints);
result6 = zeros(6,npoints);
result9 = zeros(9,npoints);
result18 = zeros(18,npoints);
% Set spatial locations to sample
for p = 1:npoints
points(1,p) = 0.20 * p;
points(2,p) = -1;0.05 * p;
points(3,p) = 0.15 * p;
end
fprintf('\nCoordinates of 10 points where variables are requested:\n');
for p = 1:npoints
fprintf(1,'%3i: %13.6e, %13.6e, %13.6e\n', p, points(1,p), points(2,p), points(3,p));
end
fprintf('\nRequesting velocity at %i points...\n',npoints);
result3 = getVelocity (authkey, dataset, time, Lag6, NoTInt, npoints, points);
for p = 1:npoints
fprintf(1,'%3i: %13.6e, %13.6e, %13.6e\n', p, result3(1,p), result3(2,p), result3(3,p));
end
fprintf('\nRequesting velocity and pressure at %i points...\n',npoints);
result4 = getVelocityAndPressure (authkey, dataset, time, Lag6, NoTInt, npoints, points);
for p = 1:npoints
fprintf(1,'%3i: %13.6e, %13.6e, %13.6e, %13.6e\n', p, result4(1,p), result4(2,p), result4(3,p), result4(4,p));
end
fprintf('\nRequesting velocity gradient at %i points...\n',npoints);
result9 = getVelocityGradient (authkey, dataset, time, FD4Lag4, NoTInt, npoints, points);
for p = 1:npoints
fprintf(1,'%3i: duxdx=%13.6e, duxdy=%13.6e, duxdz=%13.6e, ', p, result9(1,p), result9(2,p), result9(3,p));
fprintf(1,'duydx=%13.6e, duydy=%13.6e, duydz=%13.6e, ', result9(4,p), result9(5,p), result9(6,p));
fprintf(1,'duzdx=%13.6e, duzdy=%13.6e, duzdz=%13.6e\n', result9(7,p), result9(8,p), result9(9,p));
end
fprintf('\nRequesting velocity hessian at %i points...\n',npoints);
result18 = getVelocityHessian (authkey, dataset, time, FD4Lag4, NoTInt, npoints, points);
for p = 1:npoints
fprintf(1,'%3i: d2uxdxdx=%13.6e, d2uxdxdy=%13.6e, d2uxdxdz=%13.6e, ', p, result18(1,p), result18(2,p), result18(3,p));
fprintf(1,'d2uxdydy=%13.6e, d2uxdydz=%13.6e, d2uxdzdz=%13.6e, ', result18(4,p), result18(5,p), result18(6,p));
fprintf(1,'d2uydxdx=%13.6e, d2uydxdy=%13.6e, d2uydxdz=%13.6e, ', result18(7,p), result18(8,p), result18(9,p));
fprintf(1,'d2uydydy=%13.6e, d2uydydz=%13.6e, d2uydzdz=%13.6e, ', result18(10,p), result18(11,p), result18(12,p));
fprintf(1,'d2uzdxdx=%13.6e, d2uzdxdy=%13.6e, d2uzdxdz=%13.6e, ', result18(13,p), result18(14,p), result18(15,p));
fprintf(1,'d2uzdydy=%13.6e, d2uzdydz=%13.6e, d2uzdzdz=%13.6e\n', result18(16,p), result18(17,p), result18(18,p));
end
fprintf('\nRequesting velocity laplacian at %i points...\n',npoints);
result3 = getVelocityLaplacian (authkey, dataset, time, FD4Lag4, NoTInt, npoints, points);
for p = 1:npoints
fprintf(1,'%3i: grad2ux=%13.6e, grad2uy=%13.6e, grad2uz=%13.6e\n', p, result3(1,p), result3(2,p), result3(3,p));
end
fprintf('\nRequesting pressure at %i points...\n',npoints);
result1 = getPressure (authkey, dataset, time, Lag6, NoTInt, npoints, points);
for p = 1:npoints
fprintf(1,'%3i: %13.6e\n', p, result1(p));
end
fprintf('\nRequesting pressure gradient at %i points...\n',npoints);
result3 = getPressureGradient (authkey, dataset, time, FD4Lag4, NoTInt, npoints, points);
for p = 1:npoints
fprintf(1,'%3i: dpdx=%13.6e, dpdy=%13.6e, dpdz=%13.6e\n', p, result3(1,p), result3(2,p), result3(3,p));
end
fprintf('\nRequesting pressure hessian at %i points...\n',npoints);
result6 = getPressureHessian (authkey, dataset, time, FD4Lag4, NoTInt, npoints, points);
for p = 1:npoints
fprintf(1,'%3i: d2pdxdx=%13.6e, d2pdxdy=%13.6e, d2pdxdz=%13.6e, ', p, result6(1,p), result6(2,p), result6(3,p));
fprintf(1,'d2pdydy=%13.6e, d2pdydz=%13.6e, d2pdzdz=%13.6e\n', result6(4,p), result6(5,p), result6(6,p));
end
fprintf('\nRequesting position at %i points, starting at time %f and ending at time %f...\n',npoints,startTime,endTime);
result3 = getPosition(authkey, dataset, startTime, endTime, lagDt, Lag6, npoints, points);
fprintf('\nCoordinates of 10 points at startTime:\n');
for p = 1:npoints
fprintf(1,'%3i: %13.6e, %13.6e, %13.6e\n', p, points(1,p), points(2,p), points(3,p));
end
fprintf('\nCoordinates of 10 points at endTime:\n');
for p = 1:npoints
fprintf(1,'%3i: %13.6e, %13.6e, %13.6e\n', p, result3(1,p), result3(2,p), result3(3,p));
end
fprintf('\nRequesting vorticity threshold...\n');
threshold_array = getThreshold (authkey, dataset, threshold_field, time, threshold, FD4NoInt, x_start, y_start, z_start, x_end, y_end, z_end);
for p = 1:length(threshold_array)
fprintf(1,'(%3i, %3i, %3i): %13.6e\n', threshold_array(1,p), threshold_array(2,p), threshold_array(3,p), threshold_array(4,p));
end
fprintf('\nRequesting invariant at %i points...\n',npoints);
result2 = getInvariant (authkey, dataset, time, FD4Lag4, NoTInt, npoints, points);
for p = 1:npoints
fprintf(1,'%3i: S2=%13.6e, O2=%13.6e\n', p, result2(1,p), result2(2,p));
end
% ///////////////////////////////////////////////////////////
% ////////////// GENERATE A SIMPLE CONTOUR PLOT /////////////
%////////////////////////////////////////////////////////////
% Chose a random time step
time = 0.002 * randi(1024,1);
spacing = 3.0*pi/1536; % z-spacing = 1/2 x-spacing
% Set domain size and position
nx = 128;
nz = 32;
xoff = 2*spacing*randi([0,2048-nx]);
yoff = -0.99; % y+ = 10
zoff = spacing*randi([0,1536-nz]);
npoints = nx*nz;
clear points;
% Create surface
x = linspace(0, (nx-1)*spacing, nx) + xoff;
z = linspace(0, (nz-1)*spacing, nz) + zoff;
[X Z] = meshgrid(x, z);
points(1,:) = X(:)';
points(3,:) = Z(:)';
points(2,:) = yoff;
% Get the velocity at each point
fprintf('\nRequesting velocity at (%ix%i) points for velocity contour plot...\n',nx,nz);
result3 = getVelocity(authkey, dataset, time, Lag4, NoTInt, npoints, points);
% Calculate x-velocity
y = result3(1,:);
Y = reshape(y, nz, nx);
% Plot x-velocity contours
contourf(X, Z, Y, 30, 'LineStyle', 'none');
set(gca, 'FontSize', 11)
title('x-velocity', 'FontSize', 13, 'FontWeight', 'bold');
xlabel('x', 'FontSize', 12, 'FontWeight', 'bold');
ylabel('z', 'FontSize', 12, 'FontWeight', 'bold');
colorbar('FontSize', 12);
axis([xoff max(x) zoff max(z)]);
set(gca, 'TickDir', 'out', 'TickLength', [.02 .02],'XMinorTick', 'on', 'YMinorTick', 'on');