-
Notifications
You must be signed in to change notification settings - Fork 6
/
PP_StrainRate.m
143 lines (132 loc) · 8.62 KB
/
PP_StrainRate.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% POST-PROCESSING %
% STRAIN RATE %
% %
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%
% %
% 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 %
% %
% SR = PP_StrainRate(VGT); %
% %
% DESCRIPTION %
% %
% This function computes the strain rate tensor (or spin tensor) of a %
% velocity field given its velocity gradient tensor. The function detects %
% if the calculation is two or three dimensional. %
% %
% References: %
% N/A %
% %
% ----------------------------------------------------------------------- %
% Variables: %
% ----------------------------------------------------------------------- %
% 'SR' - STRUCT %
% - Strain rate tensor containing the four components 'xx', %
% 'xy', 'yx' and 'yy' in 2D or the nine components 'xx', %
% 'xy', 'xz', 'yx', 'yy', 'yz', 'zx', 'zy' and 'zz' in 3D. %
% ----------------------------------------------------------------------- %
% '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. %
% ----------------------------------------------------------------------- %
% %
% EXAMPLE %
% %
% Calculate the strain rate tensor 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); %
% >> SR = cell(length(t),1); %
% >> for k = 1:length(t) %
% SR{k} = PP_StrainRate(VGT{k}); %
% end %
% >> for k = 1:length(t) %
% contourf(VEC{k}.X, VEC{k}.Y, SR{k},yx, '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_StrainRate
function [SR] = PP_StrainRate(VGT)
if length(fieldnames(VGT)) == 4
SR = struct('xx', 0, 'xy', 0, 'yx', 0, 'yy', 0);
SR.xx = VGT.UX;
SR.xy = 0.5*(VGT.UY + VGT.VX);
SR.yx = SR.xy;
SR.yy = VGT.VY;
elseif length(fieldnames(VGT)) == 9
SR = struct('xx', 0, 'xy', 0, 'xz', 0, 'yx', 0, 'yy', 0, 'yz', 0, ...
'zx', 0, 'zy', 0, 'zz', 0);
SR.xx = VGT.UX;
SR.xy = 0.5*(VGT.UY + VGT.VX);
SR.xz = 0.5*(VGT.UZ + VGT.WX);
SR.yx = SR.xy;
SR.yy = VGT.VY;
SR.yz = 0.5*(VGT.VZ + VGT.WY);
SR.zx = SR.xz;
SR.zy = SR.yz;
SR.zz = VGT.WZ;
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. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%