-
Notifications
You must be signed in to change notification settings - Fork 6
/
PP_Vorticity.m
131 lines (121 loc) · 8.29 KB
/
PP_Vorticity.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% POST-PROCESSING %
% VORTICITY %
% %
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%
% %
% Giuseppe Di Labbio %
% Department of Mechanical, Industrial & Aerospace Engineering %
% Concordia University Montréal, Canada %
% %
% Last Update: October 3rd, 2018 by Giuseppe Di Labbio %
% %
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%
% %
% Copyright (C) 2018 Giuseppe Di Labbio %
% %
% This program 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. %
% %
% This program 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 this program. If not, see <https://www.gnu.org/licenses/>. %
% %
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%
% %
% SYNTAX %
% %
% VRT = PP_Vorticity(VGT); %
% %
% DESCRIPTION %
% %
% This function computes the vorticity of a velocity field given its %
% velocity gradient tensor. The function detects if the calculation is %
% two or three dimensional. %
% %
% References: %
% N/A %
% %
% ----------------------------------------------------------------------- %
% Variables: %
% ----------------------------------------------------------------------- %
% 'VGT' - STRUCT %
% - Velocity gradient tensor containing the four components %
% 'UX', 'UY', 'VX' and 'VY' in 2D or the nine components %
% 'UX', 'UY', 'UZ', 'VX', 'VY', 'VZ', 'WX', 'WY' and 'WZ' %
% in 3D. %
% ----------------------------------------------------------------------- %
% 'VRT' - 2D DOUBLE ARRAY OR STRUCT %
% - Vorticity vector either containing a single component in %
% 2D (in which case it will no be a struct) or three %
% components in 3D. %
% ----------------------------------------------------------------------- %
% %
% EXAMPLE %
% %
% Calculate the vorticity of a time-dependent double gyre on the domain %
% (x,y) = [0,2]x[0,1] with a constant grid spacing of 0.01 over the time %
% interval [0,20] with time-step size 0.1. Use A = 0.1, epsilon = 0.25, %
% and omega = 2*pi/10. %
% %
% >> x = linspace(0, 2, 201).'; %
% >> y = linspace(0, 1, 101).'; %
% >> t = linspace(0, 20, 21).'; %
% >> A = 0.1; %
% >> epsn = 0.25; %
% >> omga = 2*pi/10; %
% >> [VEC, VGT] = GEN_DoubleGyre(x, y, t, A, epsn, omga); %
% >> VRT = cell(length(t),1); %
% >> for k = 1:length(t) %
% VRT{k} = PP_Vorticity(VGT{k}); %
% end %
% >> for k = 1:length(t) %
% contourf(VEC{k}.X, VEC{k}.Y, VRT{k}, 'EdgeColor', 'None'); %
% colormap jet; %
% hold on; %
% quiver(VEC{k}.X(1:4:end,1:4:end), VEC{k}.Y(1:4:end,1:4:end), ... %
% VEC{k}.U(1:4:end,1:4:end), VEC{k}.V(1:4:end,1:4:end), 'k'); %
% hold off; %
% pause(0.25); %
% end %
% >> clear k; %
% %
% DEPENDENCIES %
% %
% Requires: %
% N/A %
% %
% Called in: %
% N/A %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% PP_Vorticity
function [VRT] = PP_Vorticity(VGT)
if length(fieldnames(VGT)) == 4
VRT = VGT.VX - VGT.UY;
elseif length(fieldnames(VGT)) == 9
VRT = struct('X', 0, 'Y', 0, 'Z', 0);
VRT.x = VGT.WY - VGT.VZ;
VRT.y = VGT.UZ - VGT.WX;
VRT.z = VGT.VX - VGT.UY;
end
%% %%%%%%%%%%%%%%%%%%%%%%%%% SUPPRESS MESSAGES %%%%%%%%%%%%%%%%%%%%%%%%% %%
%#ok<*N/A>
% Line(s) N/A
% Message(s)
% * N/A
% Reason(s)
% * N/A
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NOTES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%
% %
% Line(s) N/A %
% * N/A. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%