-
Notifications
You must be signed in to change notification settings - Fork 1
/
WAKE.m
3047 lines (2476 loc) · 138 KB
/
WAKE.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function varargout = WAKE(varargin)
% WAKE MATLAB code for WAKE.fig
%
% WAKE GUI v1.6
% Copyright (c) 2015-2020 by Dr. Hadar Ben-Gida, OpenPIV Group
%
% WAKE, by itself, creates a new WAKE or raises the existing
% singleton*.
%
% H = WAKE returns the handle to a new WAKE or the handle to
% the existing singleton*.
%
% WAKE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in WAKE.M with the given input arguments.
%
% WAKE('Property','Value',...) creates a new WAKE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before WAKE_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to WAKE_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help WAKE
% Last Modified by GUIDE v2.5 23-Jun-2020 21:07:25
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @WAKE_OpeningFcn, ...
'gui_OutputFcn', @WAKE_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% CLEAR ALL FUNCTION
function clearall()
clear all;
clc;
global MASK
global FPS
global LIFT_method
MASK = [1 11 0.5 1]; % masking parameters for the threshold [method, hsize, sigma, radius] method = 0 (gauss); method = 1 (regular)
FPS = 10; % Frames per second for the movie
LIFT_method = 3; % default computation method for calculating the cummulative circulatory lift coefficient
% --- Executes just before WAKE is made visible.
function WAKE_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to WAKE (see VARARGIN)
clearall(); % Clear all the workspace when the GUI starts
% Choose default command line output for WAKE
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
body_motion_type_index = get(handles.popupmenu_motion, 'Value'); % Body motion type name index
items = get(handles.popupmenu_motion, 'String');
body_motion_type_name = items{body_motion_type_index}; % Body motion type name
switch body_motion_type_name
case 'Stationary body'
set(handles.radiobutton_dsus, 'Enable', 'off');
set(handles.radiobutton_usds, 'Enable', 'off');
set(handles.pushbutton_set_kinematics, 'Enable', 'off');
set(handles.text_start_wingbeat, 'Enable', 'off');
set(handles.text_no_wingbeats_to_plot, 'Enable', 'off');
set(handles.edit_start_wingbeat, 'Enable', 'off');
set(handles.edit_no_wingbeats_to_plot, 'Enable', 'off');
case 'Flapping wing'
set(handles.radiobutton_dsus, 'Enable', 'on');
set(handles.radiobutton_usds, 'Enable', 'on');
set(handles.pushbutton_set_kinematics, 'Enable', 'on');
set(handles.text_start_wingbeat, 'Enable', 'on');
set(handles.text_no_wingbeats_to_plot, 'Enable', 'on');
set(handles.edit_start_wingbeat, 'Enable', 'on');
set(handles.edit_no_wingbeats_to_plot, 'Enable', 'on');
end
% UIWAIT makes WAKE wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% Finding the GUI vommand:
% findall(0, 'type', 'figure', 'tag', 'figure1')
% GUI tag: figure1
% --- Outputs from this function are returned to the command line.
function varargout = WAKE_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INPUTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on button press in push_load_mat_file.
function push_load_mat_file_Callback(hObject, eventdata, handles)
% hObject handle to push_load_mat_file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global MAT_file
[FileName,PathName] = uigetfile('*.mat','Select the flow data .mat file'); % Let the user select the .mat file
mat_file_name = fullfile(PathName, FileName); % Getting the .mat file name
% Print the selection of the user in the Command Window
if isequal(FileName,0)
disp('User selected Cancel')
return;
else
disp(['User selected ', mat_file_name])
end
set(handles.edit_mat_directory, 'String', mat_file_name); % Display the pathname of the .mat file in the GUI
h = waitbar(50/100, 'Loading .mat file...');
mat_file_name = get(handles.edit_mat_directory, 'String'); % Getting the .mat file name
disp('Loading .mat file...');
MAT_file = load(mat_file_name); % Load the .mat file into an array
close(h);
% Closing any new windows that might be open due to .MAT file loading
NEW_Figures = findall( 0, 'Type', 'Figure' , '-not' , 'Tag' , 'figure1'); % Finding the new figures, excluding the GUI, tagged as 'figure1'
NFigures = length(NEW_Figures);
for nFigures = 1 : NFigures
close(NEW_Figures(nFigures));
end
h = waitbar(100/100, 'Loading .mat file completed');
disp('Done!');
close(h);
function edit_laser_dt_Callback(hObject, eventdata, handles)
% hObject handle to edit_laser_dt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_laser_dt as text
% str2double(get(hObject,'String')) returns contents of edit_laser_dt as a double
% --- Executes during object creation, after setting all properties.
function edit_laser_dt_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_laser_dt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_dt_Callback(hObject, eventdata, handles)
% hObject handle to edit_dt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_dt as text
% str2double(get(hObject,'String')) returns contents of edit_dt as a double
% --- Executes during object creation, after setting all properties.
function edit_dt_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_dt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_chord_Callback(hObject, eventdata, handles)
% hObject handle to edit_chord (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_chord as text
% str2double(get(hObject,'String')) returns contents of edit_chord as a double
% --- Executes during object creation, after setting all properties.
function edit_chord_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_chord (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_b_Callback(hObject, eventdata, handles)
% hObject handle to edit_b (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_b as text
% str2double(get(hObject,'String')) returns contents of edit_b as a double
% --- Executes during object creation, after setting all properties.
function edit_b_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_b (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_bl_Callback(hObject, eventdata, handles)
% hObject handle to edit_bl (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_bl as text
% str2double(get(hObject,'String')) returns contents of edit_bl as a double
% --- Executes during object creation, after setting all properties.
function edit_bl_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_bl (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_bw_Callback(hObject, eventdata, handles)
% hObject handle to edit_bw (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_bw as text
% str2double(get(hObject,'String')) returns contents of edit_bw as a double
% --- Executes during object creation, after setting all properties.
function edit_bw_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_bw (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_w_Callback(hObject, eventdata, handles)
% hObject handle to edit_w (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_w as text
% str2double(get(hObject,'String')) returns contents of edit_w as a double
% --- Executes during object creation, after setting all properties.
function edit_w_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_w (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_Uinf_Callback(hObject, eventdata, handles)
% hObject handle to edit_Uinf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_Uinf as text
% str2double(get(hObject,'String')) returns contents of edit_Uinf as a double
% --- Executes during object creation, after setting all properties.
function edit_Uinf_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_Uinf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_density_Callback(hObject, eventdata, handles)
% hObject handle to edit_density (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_density as text
% str2double(get(hObject,'String')) returns contents of edit_density as a double
% --- Executes during object creation, after setting all properties.
function edit_density_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_density (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_viscosity_Callback(hObject, eventdata, handles)
% hObject handle to edit_viscosity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_viscosity as text
% str2double(get(hObject,'String')) returns contents of edit_viscosity as a double
% --- Executes during object creation, after setting all properties.
function edit_viscosity_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_viscosity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_dp_cm_Callback(hObject, eventdata, handles)
% hObject handle to edit_dp_cm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_dp_cm as text
% str2double(get(hObject,'String')) returns contents of edit_dp_cm as a double
% --- Executes during object creation, after setting all properties.
function edit_dp_cm_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_dp_cm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_h_cut_Callback(hObject, eventdata, handles)
% hObject handle to edit_h_cut (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_h_cut as text
% str2double(get(hObject,'String')) returns contents of edit_h_cut as a double
global MAT_file
edit_h = str2double(get(hObject,'String'));
[nRows,nColumns,nTime] = size(MAT_file.uf); % Getting the NEW velocity map size
if edit_h < 0 || edit_h > (nColumns-edit_h-1)
name = (['Please choose a correct range of horizontal cut! Should be from 1 to ', num2str(round(0.5*nColumns)-1), '...']);
msgbox(name, 'Error','error')
end
% --- Executes during object creation, after setting all properties.
function edit_h_cut_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_h_cut (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_ni_Callback(hObject, eventdata, handles)
% hObject handle to edit_ni (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_ni as text
% str2double(get(hObject,'String')) returns contents of edit_ni as a double
% --- Executes during object creation, after setting all properties.
function edit_ni_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_ni (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_nf_Callback(hObject, eventdata, handles)
% hObject handle to edit_nf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_nf as text
% str2double(get(hObject,'String')) returns contents of edit_nf as a double
% --- Executes during object creation, after setting all properties.
function edit_nf_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_nf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function plot_axes(handles, flag)
global chord
global Uinf
global X_c
global Y_c
global U
global V
global UF
global VF
global DUDX
global DUDY
global DVDX
global DVDY
global VORTICITY
global VORTICITY_NORM
global SWIRL
global MASK
tmp = isempty(VORTICITY); % check if vorticity is empty or not in order to display it
if tmp == 0
if flag == 1
cla(handles.axes1,'reset');
end
disp_vec = get(handles.radiobutton_dispvector,'Value'); % Radio button for displaying vectors in the map
vec_space = str2double(get(handles.edit_vector_spacing, 'string')); % Getting the vec spacing in axes1
vec_size = str2double(get(handles.edit_vec_size, 'string')); % Getting the vecotr scale size
contour_max = str2double(get(handles.edit_contour_max, 'string')); % Getting the maximum contour level
contour_min = str2double(get(handles.edit_contour_min, 'string')); % Getting the minimum contour level
scale_map = get(handles.radiobutton_scale,'Value'); % Radio button for scaling map
colormap_selection = str2double(getCurrentPopupString(handles.popupmenu_colormap)); % colormap selection
vort_thresh = str2double(get(handles.edit_vort_threshold, 'string')); % Vorticity threshold
% X fraction of the max VORTICITY_NORM will be eliminated
if vort_thresh < 0 || vort_thresh > 100
name = ('Please choose a correct range of vorticity threshold! Should be from 1 to 100...');
msgbox(name, 'Error','error')
return;
end
vort_thresh = vort_thresh/100; % precentage to ratio
thresh_criterion = getCurrentPopupString(handles.popupmenu_threshold);
VORTICITY_NORM = (chord/Uinf).*(vorticity_threshold(VORTICITY, SWIRL, thresh_criterion, vort_thresh, MASK)); % Thresholding on the vorticity
% Plot the final wake
if flag == 1
axes(handles.axes1); % Focusing on Figure 1
labelsize = 18; % fontsize of the labels
axessize = 14; % fontsize of the axes
elseif flag == 2 % open a figure
figure(1);
labelsize = 26; % fontsize of the labels
axessize = 21; % fontsize of the axes
end
fontname = 'Times New Roman'; % font name
x_axis1{1} = X_c; % x1 values
x_axis1{2} = '$x/c$'; % x1 label
y_axis{1} = Y_c; % y values
y_axis{2} = '$y/c$'; % y label
c_axis{1} = VORTICITY_NORM; % c values
c_axis{2} = '\omega_z\cdotc/U_\infty'; % c label
c_axis{3} = [contour_min contour_max]; % c limits
color_bar{1} = COLOR(colormap_selection)./256; % colormap
color_bar{2} = 5; % colorbar delta ticks
fonts{1} = labelsize; % labels font size
fonts{2} = fontname; % font name
fonts{3} = axessize; % axes font size
if disp_vec == 1
q_axis{1} = UF; % quiver u velocity
q_axis{2} = VF; % quiver v velocity
q_axis{3} = 0.2; % quiver LineWidth
q_axis{4} = vec_size; % quiver AutoScaleFactor
q_axis{5} = vec_space;
if scale_map == 1
contourxy(x_axis1, y_axis, c_axis, color_bar, fonts, q_axis);
else
contourxy_not_scaled(x_axis1, y_axis, c_axis, color_bar, fonts, q_axis);
end
else
if scale_map == 1
contourxy(x_axis1, y_axis, c_axis, color_bar, fonts, '');
else
contourxy_not_scaled(x_axis1, y_axis, c_axis, color_bar, fonts, '');
end
end
if flag == 2 % open a figure
set(gcf,'units','normalized','outerposition',[0 0 1 1]); % enlarging the figure to fullscreen
set(gcf, 'PaperType', 'B4', 'PaperPositionMode','auto'); % settings to prepare the figure for print in the right size
end
end
function edit_vort_threshold_Callback(hObject, eventdata, handles)
% hObject handle to edit_vort_threshold (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_vort_threshold as text
% str2double(get(hObject,'String')) returns contents of edit_vort_threshold as a double
% Hint: get(hObject,'Value') returns toggle state of radiobutton_dispvector
plot_axes(handles, 1)
% --- Executes during object creation, after setting all properties.
function edit_vort_threshold_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_vort_threshold (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_mat_directory_Callback(hObject, eventdata, handles)
% hObject handle to edit_mat_directory (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_mat_directory as text
% str2double(get(hObject,'String')) returns contents of edit_mat_directory as a double
% --- Executes during object creation, after setting all properties.
function edit_mat_directory_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_mat_directory (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton_wake_gen.
function pushbutton_wake_gen_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_wake_gen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global MAT_file
global chord
global Uinf
global X_c
global Y_c
global U
global V
global UF
global VF
global DUDX
global DUDY
global DVDX
global DVDY
global VORTICITY
global VORTICITY_NORM
global INPUTS
global SWIRL
global MASK
h = waitbar(0,'Please wait...');
cla(handles.axes1,'reset');
[nRows,nColumns,nTime] = size(MAT_file.uf); % Getting the NEW velocity map size
close(h);
h = waitbar(25/100,'Getting inputs...');
laser_dt = str2double(get(handles.edit_laser_dt, 'string')); % [sec] dt used by the laser between 2 PIV images
p_cm = str2double(get(handles.edit_dp_cm, 'string')); % [pixel/cm] pixel to cm ratio
dt = str2double(get(handles.edit_dt, 'string')); % [sec] dt between 2 velocity maps
chord = str2double(get(handles.edit_chord, 'string')); % [m] body's characteristic length
wingspan = str2double(get(handles.edit_b, 'string')); % [m] body's wingspan that includes the body width
body_l = str2double(get(handles.edit_bl, 'string')); % [m] body's length
body_w = str2double(get(handles.edit_bw, 'string')); % [m] body's width
weight = str2double(get(handles.edit_w, 'string')); % [kg] body's weight
Uinf = str2double(get(handles.edit_Uinf, 'string')); % [m/sec] Free stream velocity
density = str2double(get(handles.edit_density, 'string')); % [kg/m^3] Air density
viscosity = str2double(get(handles.edit_viscosity, 'string')); % [Pa*sec] Air viscosity
horizontal_cut = str2double(get(handles.edit_h_cut, 'string')); % Horizontal cut the user want to perform for the PIV velocity maps
vertical_cut = str2double(get(handles.edit_v_cut, 'string')); % Vertical cut the user want to perform for the PIV velocity maps
vort_thresh = str2double(get(handles.edit_vort_threshold, 'string')); % Vorticity threshold
ni = str2double(get(handles.edit_ni, 'string')); % Initial velocity map in the sequence
nf = str2double(get(handles.edit_nf, 'string')); % Final velocity map in the sequence
cross_parameter = getCurrentPopupString(handles.popupmenu_cross); % geting the paramter based on which the cross-correlation will be performed
disp_vec = get(handles.radiobutton_dispvector,'Value'); % Radio button for displaying vectors in the map
vec_space = str2double(get(handles.edit_vector_spacing, 'string')); % Getting the vec spacing in axes1
vec_size = str2double(get(handles.edit_vec_size, 'string')); % Getting the vecotr scale size
contour_max = str2double(get(handles.edit_contour_max, 'string')); % Getting the maximum contour level
contour_min = str2double(get(handles.edit_contour_min, 'string')); % Getting the minimum contour level
scale_map = get(handles.radiobutton_scale,'Value'); % Radio button for scaling map
colormap_selection = str2double(getCurrentPopupString(handles.popupmenu_colormap)); % colormap selection
body_motion_type_index = get(handles.popupmenu_motion, 'Value'); % Body motion type name index
close(h);
h = waitbar(50/100, 'Performing main calculation...');
if strcmp(get(handles.edit_nf, 'string'), 'end')==1
nf = nTime; % Final velocity map in the sequence
end
if strcmp(get(handles.edit_ni, 'string'), 'start')==1
ni = 1; % Initial velocity map in the sequence
end
if nTime<nf || ni<1 || nf<ni || strcmp(get(handles.edit_ni, 'string'), 'end')==1 || strcmp(get(handles.edit_nf, 'string'), 'start')==1 || ...
isnan(ni)==1 || isnan(nf)==1
name = (['Please choose a correct range of velocity maps! Should be from 1 to ', num2str(nTime), '...']);
msgbox(name, 'Error','error')
close(h);
else
INPUTS = [laser_dt, p_cm, dt, chord, wingspan, body_l, body_w, weight,...
Uinf, density, viscosity, horizontal_cut, vertical_cut,...
ni, nf, body_motion_type_index];
% Performing the main program
[X_c, Y_c, U, V, UF, VF, DUDX, DUDY, DVDX, DVDY, VORTICITY, SWIRL] = main(MAT_file, INPUTS, cross_parameter);
close(h);
h = waitbar(75/100, 'Displaying wake figure...');
% X fraction of the max VORTICITY_NORM will be eliminated
if vort_thresh < 0 || vort_thresh > 100
name = ('Please choose a correct range of vorticity threshold! Should be from 1 to 100...');
msgbox(name, 'Error','error')
return;
end
vort_thresh = vort_thresh/100; % precentage to ratio
thresh_criterion = getCurrentPopupString(handles.popupmenu_threshold);
VORTICITY_NORM = (chord/Uinf).*(vorticity_threshold(VORTICITY, SWIRL, thresh_criterion, vort_thresh, MASK)); % Thresholding on the vorticity
% Plot the final wake
axes(handles.axes1); % Focusing on Figure 1
labelsize = 18; % fontsize of the labels
fontname = 'Times New Roman'; % font name
axessize = 14; % fontsize of the axes
x_axis1{1} = X_c; % x1 values
x_axis1{2} = '$x/c$'; % x1 label
y_axis{1} = Y_c; % y values
y_axis{2} = '$y/c$'; % y label
c_axis{1} = VORTICITY_NORM; % c values
c_axis{2} = '\omega_z\cdotc/U_\infty'; % c label
c_axis{3} = [contour_min contour_max]; % c limits
color_bar{1} = COLOR(colormap_selection)./256; % colormap
color_bar{2} = 5; % colorbar delta ticks
fonts{1} = labelsize; % labels font size
fonts{2} = fontname; % font name
fonts{3} = axessize; % axes font size
if disp_vec == 1
q_axis{1} = UF; % quiver u velocity
q_axis{2} = VF; % quiver v velocity
q_axis{3} = 0.2; % quiver LineWidth
q_axis{4} = vec_size; % quiver AutoScaleFactor
q_axis{5} = vec_space;
if scale_map == 1
contourxy(x_axis1, y_axis, c_axis, color_bar, fonts, q_axis);
else
contourxy_not_scaled(x_axis1, y_axis, c_axis, color_bar, fonts, q_axis);
end
else
if scale_map == 1
contourxy(x_axis1, y_axis, c_axis, color_bar, fonts, '');
else
contourxy_not_scaled(x_axis1, y_axis, c_axis, color_bar, fonts, '');
end
end
close(h);
h = waitbar(100/100, 'Finished!');
close(h);
end
function edit_v_cut_Callback(hObject, eventdata, handles)
% hObject handle to edit_v_cut (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_v_cut as text
% str2double(get(hObject,'String')) returns contents of edit_v_cut as a double
global MAT_file
edit_v = str2double(get(hObject,'String'));
[nRows,nColumns,nTime] = size(MAT_file.uf); % Getting the NEW velocity map size
if edit_v < 0 || edit_v > (nRows-edit_v-1)
name = (['Please choose a correct range of vertical cut! Should be from 1 to ', num2str(round(0.5*nRows)-1), '...']);
msgbox(name, 'Error','error')
end
% --- Executes during object creation, after setting all properties.
function edit_v_cut_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_v_cut (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu_cross.
function popupmenu_cross_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_cross (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_cross contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_cross
% --- Executes during object creation, after setting all properties.
function popupmenu_cross_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_cross (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% Get the current popup string chosen by the user
function str = getCurrentPopupString(hh)
% returns the currently selected string in the popupmenu with handle hh
% Test input
if ~ishandle(hh) || strcmp(get(hh,'Type'),'popupmenu')
error('getCurrentPopupString needs a handle to a popupmenu as input')
end
% get the string
list = get(hh,'String'); % getting the list of items in the popup menu
val = get(hh,'Value'); % getting the current value
if iscell(list)
str = list{val}; % Finding the current string chosen by the user
else
str = list(val,:);
end
function edit_vector_spacing_Callback(hObject, eventdata, handles)
% hObject handle to edit_vector_spacing (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_vector_spacing as text
% str2double(get(hObject,'String')) returns contents of edit_vector_spacing as a double
plot_axes(handles, 1)
% --- Executes during object creation, after setting all properties.
function edit_vector_spacing_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_vector_spacing (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_vec_size_Callback(hObject, eventdata, handles)
% hObject handle to edit_vec_size (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_vec_size as text
% str2double(get(hObject,'String')) returns contents of edit_vec_size as a double
plot_axes(handles, 1)
% --- Executes during object creation, after setting all properties.
function edit_vec_size_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_vec_size (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in radiobutton_dispvector.
function radiobutton_dispvector_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton_dispvector (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton_dispvector
plot_axes(handles, 1)
function edit_contour_max_Callback(hObject, eventdata, handles)
% hObject handle to edit_contour_max (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_contour_max as text
% str2double(get(hObject,'String')) returns contents of edit_contour_max as a double
plot_axes(handles, 1)
% --- Executes during object creation, after setting all properties.
function edit_contour_max_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_contour_max (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_contour_min_Callback(hObject, eventdata, handles)
% hObject handle to edit_contour_min (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_contour_min as text
% str2double(get(hObject,'String')) returns contents of edit_contour_min as a double
plot_axes(handles, 1)
% --- Executes during object creation, after setting all properties.
function edit_contour_min_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_contour_min (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in radiobutton_scale.
function radiobutton_scale_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton_scale (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton_scale
plot_axes(handles, 1)
% --------------------------------------------------------------------
function Inputs_Callback(hObject, eventdata, handles)
% hObject handle to Inputs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function save_inputs_Callback(hObject, eventdata, handles)
% hObject handle to save_inputs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% getting inputs
laser_dt = str2double(get(handles.edit_laser_dt, 'string')); % [sec] dt used by the laser between 2 PIV images
p_cm = str2double(get(handles.edit_dp_cm, 'string')); % [pixel/cm] pixel to cm ratio
dt = str2double(get(handles.edit_dt, 'string')); % [sec] dt between 2 velocity maps
chord = str2double(get(handles.edit_chord, 'string')); % [m] body's characteristic length
wingspan = str2double(get(handles.edit_b, 'string')); % [m] body's wingspan that includes the body width
body_l = str2double(get(handles.edit_bl, 'string')); % [m] body's length
body_w = str2double(get(handles.edit_bw, 'string')); % [m] body's width
weight = str2double(get(handles.edit_w, 'string')); % [kg] body's weight
body_motion_type_index = get(handles.popupmenu_motion, 'Value'); % Body motion type name index
items = get(handles.popupmenu_motion, 'String');
body_motion_type_name = items{body_motion_type_index}; % Body motion type name
Uinf = str2double(get(handles.edit_Uinf, 'string')); % [m/sec] Free stream velocity
density = str2double(get(handles.edit_density, 'string')); % [kg/m^3] Air density
viscosity = str2double(get(handles.edit_viscosity, 'string')); % [Pa*sec] Air viscosity
% Defining .mat file with all the inputs
INPUTS = [];
INPUTS.laser_dt = laser_dt;
INPUTS.p_cm = p_cm;