-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDNSUTA_extractOA.f95
1858 lines (1330 loc) · 57.8 KB
/
DNSUTA_extractOA.f95
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
program DNSUTA_extract
!-------------------------------------------------------------------------------
! Email: [email protected], [email protected]
! Email: [email protected]
! Department of Mathematics, University of Texas at Arlington,
! Arlington, Texas, USA
! Fall 2021
!-------------------------------------------------------------------------------
implicit none
integer :: imax, jmax, kmax
integer :: imax_local, jmax_local, kmax_local
integer :: istart, iend
integer :: jstart, jend
integer :: kstart, kend
real(8), dimension(:,:,:), allocatable :: x
real(8), dimension(:,:,:), allocatable :: y
real(8), dimension(:,:,:), allocatable :: z
real(8), dimension(:,:,:), allocatable :: u
real(8), dimension(:,:,:), allocatable :: v
real(8), dimension(:,:,:), allocatable :: w
real(8), dimension(:,:,:,:), allocatable :: f
real(8), dimension(:,:,:), allocatable :: dudx, dudy, dudz
real(8), dimension(:,:,:), allocatable :: dvdx, dvdy, dvdz
real(8), dimension(:,:,:), allocatable :: dwdx, dwdy, dwdz
real(8) :: rdudx,rdudy,rdudz,rdvdx,rdvdy,rdvdz,rdwdx
real(8) :: rdwdy,rdwdz,rvort_x,rvort_y,rvort_z
real(8), dimension(:,:,:), allocatable :: vorticity_x
real(8), dimension(:,:,:), allocatable :: vorticity_y
real(8), dimension(:,:,:), allocatable :: vorticity_z
real(8), dimension(:,:,:), allocatable :: vorticity_mag
real(8), dimension(:,:,:), allocatable :: omega,localOmega,Qmethod,QGlob
real(8), dimension(:,:,:), allocatable :: omg_x,omg_y,omg_z, omgGradXRortex
real(8), dimension(:,:,:), allocatable :: omgLoc_x,omgLoc_y,omgLoc_z,QLoc_x,QLoc_y,QLoc_z
real(8), dimension(:,:,:), allocatable :: omg_xx,omg_xy,omg_xz
real(8), dimension(:,:,:), allocatable :: omg_yx,omg_yy,omg_yz
real(8), dimension(:,:,:), allocatable :: omg_zx,omg_zy,omg_zz
real(8), dimension(:,:,:), allocatable :: rortex_x
real(8), dimension(:,:,:), allocatable :: rortex_y
real(8), dimension(:,:,:), allocatable :: rortex_z
real(8), dimension(:,:,:), allocatable :: isLocExtrOmg
real(8), dimension(:,:,:), allocatable :: rortexEigr
real(8), dimension(:,:,:), allocatable :: rortex_mag, lamb_ci,rortexGlob_mag
real(8),dimension (:,:,:), allocatable :: rortex_mag_x,rortex_mag_y, rortex_mag_z
real(8) :: vor(3),vrtmp(3), rorMag,normljm,normljm2,ljmtmp,ljmtmp2
character(100) :: gridfilename, funcfilename, outputfilename
character(100) :: outputfilename1
character(100) :: outputfilename2
integer :: skip
integer :: f_start
integer :: f_end
integer :: iii
integer :: i, j, k, nx
integer :: ii, jj, kk
integer, parameter :: fin1 = 10
integer, parameter :: fin2 = 11
integer, parameter :: fout = 12
logical :: lexist
integer :: ios
character(100) :: msg
integer :: nvar
real(8) :: aaa
real(8) :: bbb
real(8) :: thljm, qljm,rljm,pi
real(8) :: omega_eps
real(8) :: vort_2
real(8) :: u_xi, u_eta, u_zeta, u_xiR, u_etaR,u_zetaR
real(8) :: v_xi, v_eta, v_zeta, u_xiQ, u_etaQ,u_zetaQ
real(8) :: w_xi, w_eta, w_zeta
real(8) :: x_xi, x_eta, x_zeta
real(8) :: y_xi, y_eta, y_zeta
real(8) :: z_xi, z_eta, z_zeta
real(8) :: xi_x, xi_y, xi_z
real(8) :: eta_x, eta_y, eta_z
real(8) :: zeta_x, zeta_y, zeta_z
real(8) :: det
real(8) :: a(3,3), Aljm(3,3), Matljm(3,3)
real(8) :: t1, t2, t3, t4, t5, t6
real(8) :: aa, bb, cc
real(8) :: delta
real(8) :: tt(3, 3)
complex(8) :: eig1c, eig2c
real(8) :: eig3r
real(8) :: qq, rr, root11,root22,root33
real(8) :: aaaa, bbbb
real(8) :: vr(3)
real(8) :: temp
real(8) :: vg(3,3)
real(8) :: alpha, beta
! Modified Omega Liutex variables
real(8), dimension(:,:,:), allocatable :: omega_l
real(8), dimension(:,:,:), allocatable :: lambda_cr, lambda_r
real(8) :: maxbeta_alpha, omega_l_eps
real(8), dimension(:,:,:), allocatable :: o_alpha, o_beta
real(8), parameter :: z0(3) = (/0.0, 0.0, 1.0/)
real(8) :: rm
real(8) :: qqq(3,3)
real(8) :: delta1, delta2, delta3
character(6) :: chars
continue
! the default epsilon value for Omega method
omega_eps = 1.0e-4
pi = 4.0*atan(1.0)
! inquire whether the input file exists
inquire(file='input.txt', exist=lexist)
if(.not. lexist) then
write(*,*) 'ERROR: no file input.txt'
stop
end if
! read input file
open(fin1, file='input.txt', form='formatted', action='read')
read(fin1, *) f_start
read(fin1, *) f_end
read(fin1, *) skip
read(fin1, *) istart, iend
read(fin1, *) jstart, jend
read(fin1, *) kstart, kend
read(fin1, *) omega_eps
read(fin1, *) outputfilename
close(fin1)
imax_local = iend - istart + 1
jmax_local = jend - jstart + 1
kmax_local = kend - kstart + 1
omega_l_eps = omega_eps
gridfilename = 'data/plate.xyz'
! check if the grid file exists
inquire(file=trim(gridfilename), exist=lexist)
if(.not. lexist) then
write(*,*) 'ERROR: no grid file ', trim(gridfilename)
stop
end if
write(*,*)
write(*,*) 'reading ', trim(gridfilename)
! open grid file
open(fin1, file=trim(gridfilename), form='unformatted', action='read', &
iostat=ios, iomsg=msg)
if(ios /= 0) then
write(*,*) 'ERROR: ', msg
stop
end if
read(fin1, iostat=ios, iomsg=msg) imax, jmax, kmax
if(ios /= 0) then
write(*,*) 'ERROR: ', msg
stop
end if
allocate(x(imax, jmax, kmax))
allocate(y(imax, jmax, kmax))
allocate(z(imax, jmax, kmax))
write(*,*)
write(*,*) 'imax = ', imax, ' jmax = ', jmax, ' kmax = ', kmax
! read coordinates
read(fin1, iostat=ios, iomsg=msg) &
(((x(i, j, k), i=1,imax), j=1,jmax), k=1,kmax), &
(((y(i, j, k), i=1,imax), j=1,jmax), k=1,kmax), &
(((z(i, j, k), i=1,imax), j=1,jmax), k=1,kmax)
close(fin1)
do iii = f_start, f_end, skip
write(*,*) 'imax_local, jmax_local, kmax_local'
write(*,*) imax_local, jmax_local, kmax_local
call itoa6(iii, chars)
funcfilename = 'data/plate_'//chars//'.fun'
! check if the data file exists
inquire(file=trim(funcfilename), exist=lexist)
if(.not. lexist) then
write(*,*) 'ERROR: no data file ', funcfilename
stop
end if
write(*,*)
write(*,*) 'reading ', trim(funcfilename)
! open data file
open(fin2, file=trim(funcfilename), form='unformatted', action='read', &
iostat=ios, iomsg=msg)
if(ios /= 0) then
write(*,*) 'ERROR: ', msg
stop
end if
read(fin2, iostat=ios, iomsg=msg) imax, jmax, kmax, nvar
if(ios /= 0) then
write(*,*) 'ERROR: ', msg
stop
end if
allocate(f(imax, jmax, kmax, nvar))
! read data
!---------------------------------------------------------------------------
! f(1): density
! f(2): u velocity
! f(3): v velocity
! f(4): w velocity
! f(5): pressure
!---------------------------------------------------------------------------
read(fin2, iostat=ios, iomsg=msg) ((((f(i, j, k, nx), i=1,imax), j=1,jmax),&
k=1,kmax), nx=1,nvar)
if(ios /= 0) then
write(*,*) 'ERROR: ', msg
stop
end if
close(fin2)
allocate(dudx(imax_local, jmax_local, kmax_local))
allocate(dudy(imax_local, jmax_local, kmax_local))
allocate(dudz(imax_local, jmax_local, kmax_local))
allocate(dvdx(imax_local, jmax_local, kmax_local))
allocate(dvdy(imax_local, jmax_local, kmax_local))
allocate(dvdz(imax_local, jmax_local, kmax_local))
allocate(dwdx(imax_local, jmax_local, kmax_local))
allocate(dwdy(imax_local, jmax_local, kmax_local))
allocate(dwdz(imax_local, jmax_local, kmax_local))
allocate(vorticity_x(imax_local,jmax_local,kmax_local))
allocate(vorticity_y(imax_local,jmax_local,kmax_local))
allocate(vorticity_z(imax_local,jmax_local,kmax_local))
allocate(vorticity_mag(imax_local,jmax_local,kmax_local))
allocate(localOmega(imax_local, jmax_local, kmax_local))
allocate(omega(imax, jmax, kmax))
allocate(QGlob(imax, jmax, kmax))
allocate(Qmethod(imax_local, jmax_local, kmax_local))
allocate(QLoc_x(imax_local, jmax_local, kmax_local))
allocate(QLoc_y(imax_local, jmax_local, kmax_local))
allocate(QLoc_z(imax_local, jmax_local, kmax_local))
allocate(omg_x(imax, jmax, kmax))
allocate(omgGradXRortex(imax_local, jmax_local, kmax_local))
allocate(omgLoc_x(imax_local, jmax_local, kmax_local))
allocate(omgLoc_y(imax_local, jmax_local, kmax_local))
allocate(omgLoc_z(imax_local, jmax_local, kmax_local))
allocate(omg_xx(imax_local, jmax_local, kmax_local))
allocate(omg_xy(imax_local, jmax_local, kmax_local))
allocate(omg_xz(imax_local, jmax_local, kmax_local))
allocate(omg_y(imax, jmax, kmax))
allocate(omg_yx(imax_local, jmax_local, kmax_local))
allocate(omg_yy(imax_local, jmax_local, kmax_local))
allocate(omg_yz(imax_local, jmax_local, kmax_local))
allocate(omg_z(imax, jmax, kmax))
allocate(omg_zx(imax_local, jmax_local, kmax_local))
allocate(omg_zy(imax_local, jmax_local, kmax_local))
allocate(omg_zz(imax_local, jmax_local, kmax_local))
allocate(isLocExtrOmg(imax_local, jmax_local, kmax_local))
allocate(u(imax_local, jmax_local, kmax_local))
allocate(v(imax_local, jmax_local, kmax_local))
allocate(w(imax_local, jmax_local, kmax_local))
allocate(rortex_x(imax_local, jmax_local, kmax_local))
allocate(rortex_y(imax_local, jmax_local, kmax_local))
allocate(rortex_z(imax_local, jmax_local, kmax_local))
allocate(rortexEigr(imax_local, jmax_local, kmax_local))
allocate(rortex_mag(imax_local, jmax_local, kmax_local))
allocate(rortex_mag_x(imax_local, jmax_local, kmax_local))
allocate(rortex_mag_y(imax_local, jmax_local, kmax_local))
allocate(rortex_mag_z(imax_local, jmax_local, kmax_local))
allocate(lamb_ci(imax_local, jmax_local, kmax_local))
allocate(rortexGlob_mag(imax, jmax, kmax))
isLocExtrOmg = 0.0
omgGradXRortex = 0.0
rortexEigr = 0.0
dudx = 0.0
dudy = 0.0
dudz = 0.0
dvdx = 0.0
dvdy = 0.0
dvdz = 0.0
dwdx = 0.0
dwdy = 0.0
dwdz = 0.0
omega = 0.0
localOmega = 0.0
Qmethod = 0.0
!---------------------------------------------------------------------------
! calculate:
! (1) velocity gradient tensor
! (2) vorticity
! (3) Omega
! (4) Q
! For coordinate transformation, refer to CFL3D User's Manual Appendix F
!---------------------------------------------------------------------------
write(*,*)
write(*,*) 'Calculating velocity gradient tensor'
call cpu_time(t1)
do k = kstart, kend
do j = jstart, jend
do i = istart, iend
if(i == 1) then
! forward difference
u_xi = f(2, j, k, 2) - f(1, j, k, 2)
v_xi = f(2, j, k, 3) - f(1, j, k, 3)
w_xi = f(2, j, k, 4) - f(1, j, k, 4)
x_xi = x(2, j, k) - x(1, j, k)
y_xi = y(2, j, k) - y(1, j, k)
z_xi = z(2, j, k) - z(1, j, k)
else if(i == imax) then
! backward difference
u_xi = f(imax, j, k, 2)-f(imax-1, j, k, 2)
v_xi = f(imax, j, k, 3)-f(imax-1, j, k, 3)
w_xi = f(imax, j, k, 4)-f(imax-1, j, k, 4)
x_xi = x(imax, j, k)-x(imax-1, j, k)
y_xi = y(imax, j, k)-y(imax-1, j, k)
z_xi = z(imax, j, k)-z(imax-1, j, k)
else
! central difference
u_xi = 0.5*(f(i+1, j, k, 2) - f(i-1, j, k, 2))
v_xi = 0.5*(f(i+1, j, k, 3) - f(i-1, j, k, 3))
w_xi = 0.5*(f(i+1, j, k, 4) - f(i-1, j, k, 4))
x_xi = 0.5*(x(i+1, j, k) - x(i-1, j, k))
y_xi = 0.5*(y(i+1, j, k) - y(i-1, j, k))
z_xi = 0.5*(z(i+1, j, k) - z(i-1, j, k))
end if
if(j == 1) then
! forward difference
u_eta = f(i, 2, k, 2) - f(i, 1, k, 2)
v_eta = f(i, 2, k, 3) - f(i, 1, k, 3)
w_eta = f(i, 2, k, 4) - f(i, 1, k, 4)
x_eta = x(i, 2, k) - x(i, 1, k)
y_eta = y(i, 2, k) - y(i, 1, k)
z_eta = z(i, 2, k) - z(i, 1, k)
else if(j == jmax) then
! backward difference
u_eta = f(i, jmax, k, 2) - f(i, jmax-1, k, 2)
v_eta = f(i, jmax, k, 3) - f(i, jmax-1, k, 3)
w_eta = f(i, jmax, k, 4) - f(i, jmax-1, k, 4)
x_eta = x(i, jmax, k) - x(i, jmax-1, k)
y_eta = y(i, jmax, k) - y(i, jmax-1, k)
z_eta = z(i, jmax, k) - z(i, jmax-1, k)
else
! central difference
u_eta = 0.5*(f(i, j+1, k, 2) - f(i, j-1, k, 2))
v_eta = 0.5*(f(i, j+1, k, 3) - f(i, j-1, k, 3))
w_eta = 0.5*(f(i, j+1, k, 4) - f(i, j-1, k, 4))
x_eta = 0.5*(x(i, j+1, k) - x(i, j-1, k))
y_eta = 0.5*(y(i, j+1, k) - y(i, j-1, k))
z_eta = 0.5*(z(i, j+1, k) - z(i, j-1, k))
end if
if(k == 1) then
! forward difference
u_zeta = f(i, j, 2, 2)-f(i, j, 1, 2)
v_zeta = f(i, j, 2, 3)-f(i, j, 1, 3)
w_zeta = f(i, j, 2, 4)-f(i, j, 1, 4)
x_zeta = x(i, j, 2) - x(i, j, 1)
y_zeta = y(i, j, 2) - y(i, j, 1)
z_zeta = z(i, j, 2) - z(i, j, 1)
else if(k == kmax) then
! backward difference
u_zeta = f(i, j, kmax, 2)-f(i, j, kmax-1, 2)
v_zeta = f(i, j, kmax, 3)-f(i, j, kmax-1, 3)
w_zeta = f(i, j, kmax, 4)-f(i, j, kmax-1, 4)
x_zeta = x(i, j, kmax) - x(i, j, kmax-1)
y_zeta = y(i, j, kmax) - y(i, j, kmax-1)
z_zeta = z(i, j, kmax) - z(i, j, kmax-1)
else
! central difference
u_zeta = 0.5*(f(i, j, k+1, 2) - f(i, j, k-1, 2))
v_zeta = 0.5*(f(i, j, k+1, 3) - f(i, j, k-1, 3))
w_zeta = 0.5*(f(i, j, k+1, 4) - f(i, j, k-1, 4))
x_zeta = 0.5*(x(i, j, k+1) - x(i, j, k-1))
y_zeta = 0.5*(y(i, j, k+1) - y(i, j, k-1))
z_zeta = 0.5*(z(i, j, k+1) - z(i, j, k-1))
end if
! determinant of Jacobian
det = x_xi*(y_eta*z_zeta-y_zeta*z_eta) &
- x_eta*(y_xi*z_zeta-y_zeta*z_xi) &
+ x_zeta*(y_xi*z_eta-y_eta*z_xi)
det = 1.0/det
xi_x = det*(y_eta*z_zeta - y_zeta*z_eta)
xi_y = det*(x_zeta*z_eta - x_eta*z_zeta)
xi_z = det*(x_eta*y_zeta - x_zeta*y_eta)
eta_x = det*(y_zeta*z_xi - y_xi*z_zeta)
eta_y = det*(x_xi*z_zeta - x_zeta*z_xi)
eta_z = det*(x_zeta*y_xi - x_xi*y_zeta)
zeta_x = det*(y_xi*z_eta - y_eta*z_xi)
zeta_y = det*(x_eta*z_xi - x_xi*z_eta)
zeta_z = det*(x_xi*y_eta - x_eta*y_xi)
ii = i-istart+1
jj = j-jstart+1
kk = k-kstart+1
! velocity gradient
dudx(ii, jj, kk) = u_xi*xi_x + u_eta*eta_x + u_zeta*zeta_x
dudy(ii, jj, kk) = u_xi*xi_y + u_eta*eta_y + u_zeta*zeta_y
dudz(ii, jj, kk) = u_xi*xi_z + u_eta*eta_z + u_zeta*zeta_z
dvdx(ii, jj, kk) = v_xi*xi_x + v_eta*eta_x + v_zeta*zeta_x
dvdy(ii, jj, kk) = v_xi*xi_y + v_eta*eta_y + v_zeta*zeta_y
dvdz(ii, jj, kk) = v_xi*xi_z + v_eta*eta_z + v_zeta*zeta_z
dwdx(ii, jj, kk) = w_xi*xi_x + w_eta*eta_x + w_zeta*zeta_x
dwdy(ii, jj, kk) = w_xi*xi_y + w_eta*eta_y + w_zeta*zeta_y
dwdz(ii, jj, kk) = w_xi*xi_z + w_eta*eta_z + w_zeta*zeta_z
aaa = dudx(ii, jj, kk)**2+dvdy(ii, jj, kk)**2+dwdz(ii, jj, kk)**2 + &
0.5*((dudy(ii, jj, kk)+dvdx(ii, jj, kk))**2 + &
(dudz(ii, jj, kk)+dwdx(ii, jj, kk))**2 + &
(dvdz(ii, jj, kk)+dwdy(ii, jj, kk))**2)
! vorticity
vorticity_x(ii,jj,kk) = dwdy(ii, jj, kk)-dvdz(ii, jj, kk)
vorticity_y(ii,jj,kk) = dudz(ii, jj, kk)-dwdx(ii, jj, kk)
vorticity_z(ii,jj,kk) = dvdx(ii, jj, kk)-dudy(ii, jj, kk)
vort_2 = vorticity_x(ii,jj,kk)**2 &
+vorticity_y(ii,jj,kk)**2 &
+vorticity_z(ii,jj,kk)**2
vorticity_mag(ii,jj,kk) = sqrt(vort_2)
bbb = 0.5*vort_2
localOmega(ii, jj, kk) = bbb/(aaa+bbb+omega_eps)
Qmethod(ii, jj, kk) = (bbb-aaa)/2.0
u(ii, jj, kk) = f(i, j, k, 2)
v(ii, jj, kk) = f(i, j, k, 3)
w(ii, jj, kk) = f(i ,j, k, 4)
end do
end do
end do
!--------
do k = 1, kmax
do j = 1, jmax
do i = 1, imax
if(i == 1) then
! forward difference
u_xi = f(2, j, k, 2) - f(1, j, k, 2)
v_xi = f(2, j, k, 3) - f(1, j, k, 3)
w_xi = f(2, j, k, 4) - f(1, j, k, 4)
x_xi = x(2, j, k) - x(1, j, k)
y_xi = y(2, j, k) - y(1, j, k)
z_xi = z(2, j, k) - z(1, j, k)
else if(i == imax) then
! backward difference
u_xi = f(imax, j, k, 2)-f(imax-1, j, k, 2)
v_xi = f(imax, j, k, 3)-f(imax-1, j, k, 3)
w_xi = f(imax, j, k, 4)-f(imax-1, j, k, 4)
x_xi = x(imax, j, k)-x(imax-1, j, k)
y_xi = y(imax, j, k)-y(imax-1, j, k)
z_xi = z(imax, j, k)-z(imax-1, j, k)
else
! central difference
u_xi = 0.5*(f(i+1, j, k, 2) - f(i-1, j, k, 2))
v_xi = 0.5*(f(i+1, j, k, 3) - f(i-1, j, k, 3))
w_xi = 0.5*(f(i+1, j, k, 4) - f(i-1, j, k, 4))
x_xi = 0.5*(x(i+1, j, k) - x(i-1, j, k))
y_xi = 0.5*(y(i+1, j, k) - y(i-1, j, k))
z_xi = 0.5*(z(i+1, j, k) - z(i-1, j, k))
end if
if(j == 1) then
! forward difference
u_eta = f(i, 2, k, 2) - f(i, 1, k, 2)
v_eta = f(i, 2, k, 3) - f(i, 1, k, 3)
w_eta = f(i, 2, k, 4) - f(i, 1, k, 4)
x_eta = x(i, 2, k) - x(i, 1, k)
y_eta = y(i, 2, k) - y(i, 1, k)
z_eta = z(i, 2, k) - z(i, 1, k)
else if(j == jmax) then
! backward difference
u_eta = f(i, jmax, k, 2) - f(i, jmax-1, k, 2)
v_eta = f(i, jmax, k, 3) - f(i, jmax-1, k, 3)
w_eta = f(i, jmax, k, 4) - f(i, jmax-1, k, 4)
x_eta = x(i, jmax, k) - x(i, jmax-1, k)
y_eta = y(i, jmax, k) - y(i, jmax-1, k)
z_eta = z(i, jmax, k) - z(i, jmax-1, k)
else
! central difference
u_eta = 0.5*(f(i, j+1, k, 2) - f(i, j-1, k, 2))
v_eta = 0.5*(f(i, j+1, k, 3) - f(i, j-1, k, 3))
w_eta = 0.5*(f(i, j+1, k, 4) - f(i, j-1, k, 4))
x_eta = 0.5*(x(i, j+1, k) - x(i, j-1, k))
y_eta = 0.5*(y(i, j+1, k) - y(i, j-1, k))
z_eta = 0.5*(z(i, j+1, k) - z(i, j-1, k))
end if
if(k == 1) then
! forward difference
u_zeta = f(i, j, 2, 2)-f(i, j, 1, 2)
v_zeta = f(i, j, 2, 3)-f(i, j, 1, 3)
w_zeta = f(i, j, 2, 4)-f(i, j, 1, 4)
x_zeta = x(i, j, 2) - x(i, j, 1)
y_zeta = y(i, j, 2) - y(i, j, 1)
z_zeta = z(i, j, 2) - z(i, j, 1)
else if(k == kmax) then
! backward difference
u_zeta = f(i, j, kmax, 2)-f(i, j, kmax-1, 2)
v_zeta = f(i, j, kmax, 3)-f(i, j, kmax-1, 3)
w_zeta = f(i, j, kmax, 4)-f(i, j, kmax-1, 4)
x_zeta = x(i, j, kmax) - x(i, j, kmax-1)
y_zeta = y(i, j, kmax) - y(i, j, kmax-1)
z_zeta = z(i, j, kmax) - z(i, j, kmax-1)
else
! central difference
u_zeta = 0.5*(f(i, j, k+1, 2) - f(i, j, k-1, 2))
v_zeta = 0.5*(f(i, j, k+1, 3) - f(i, j, k-1, 3))
w_zeta = 0.5*(f(i, j, k+1, 4) - f(i, j, k-1, 4))
x_zeta = 0.5*(x(i, j, k+1) - x(i, j, k-1))
y_zeta = 0.5*(y(i, j, k+1) - y(i, j, k-1))
z_zeta = 0.5*(z(i, j, k+1) - z(i, j, k-1))
end if
! determinant of Jacobian
det = x_xi*(y_eta*z_zeta-y_zeta*z_eta) &
- x_eta*(y_xi*z_zeta-y_zeta*z_xi) &
+ x_zeta*(y_xi*z_eta-y_eta*z_xi)
det = 1.0/det
xi_x = det*(y_eta*z_zeta - y_zeta*z_eta)
xi_y = det*(x_zeta*z_eta - x_eta*z_zeta)
xi_z = det*(x_eta*y_zeta - x_zeta*y_eta)
eta_x = det*(y_zeta*z_xi - y_xi*z_zeta)
eta_y = det*(x_xi*z_zeta - x_zeta*z_xi)
eta_z = det*(x_zeta*y_xi - x_xi*y_zeta)
zeta_x = det*(y_xi*z_eta - y_eta*z_xi)
zeta_y = det*(x_eta*z_xi - x_xi*z_eta)
zeta_z = det*(x_xi*y_eta - x_eta*y_xi)
! velocity gradient
rdudx = u_xi*xi_x + u_eta*eta_x + u_zeta*zeta_x
rdudy = u_xi*xi_y + u_eta*eta_y + u_zeta*zeta_y
rdudz = u_xi*xi_z + u_eta*eta_z + u_zeta*zeta_z
rdvdx = v_xi*xi_x + v_eta*eta_x + v_zeta*zeta_x
rdvdy = v_xi*xi_y + v_eta*eta_y + v_zeta*zeta_y
rdvdz = v_xi*xi_z + v_eta*eta_z + v_zeta*zeta_z
rdwdx = w_xi*xi_x + w_eta*eta_x + w_zeta*zeta_x
rdwdy = w_xi*xi_y + w_eta*eta_y + w_zeta*zeta_y
rdwdz = w_xi*xi_z + w_eta*eta_z + w_zeta*zeta_z
aaa = rdudx**2+rdvdy**2+rdwdz**2 + &
0.5*((rdudy+rdvdx)**2 + &
(rdudz+rdwdx)**2 + &
(rdvdz+rdwdy)**2)
! vorticity
rvort_x = rdwdy-rdvdz
rvort_y = rdudz-rdwdx
rvort_z = rdvdx-rdudy
vor(1)=rvort_x
vor(2)=rvort_y
vor(3)=rvort_z
vort_2 = rvort_x**2 &
+rvort_y**2 &
+rvort_z**2
bbb = 0.5*vort_2
omega(i, j, k) = bbb/(aaa+bbb+omega_eps)
a(1,1)=rdudx
a(1,2)=rdudy
a(1,3)=rdudz
a(2,1)=rdvdx
a(2,2)=rdvdy
a(2,3)=rdvdz
a(3,1)=rdwdx
a(3,2)=rdwdy
a(3,3)=rdwdz
call cal_rortex(a, vor, vrtmp,rorMag)
rortexGlob_mag(i,j,k)=rorMag
QGlob(i,j,k)=0.5*(bbb-aaa)
end do
end do
end do
!+++++++
call cpu_time(t2)
write(*,*) 'calculation time: ', t2-t1
! calculate hessain matrix of the omega
! fist step to calculate the first order dirivative of the omega
do k = 1,kmax
do j = 1, jmax
do i = 1, imax
if(i == 1) then
! forward difference
u_xi = omega(2, j, k) - omega(1, j, k)
u_xiR =rortexGlob_mag(2, j, k) - rortexGlob_mag(1, j, k)
u_xiQ =QGlob(2, j, k) - QGlob(1, j, k)
x_xi = x(2, j, k) - x(1, j, k)
y_xi = y(2, j, k) - y(1, j, k)
z_xi = z(2, j, k) - z(1, j, k)
else if(i == imax) then
! backward difference
u_xi = omega(imax, j, k)-omega(imax-1, j, k)
u_xiR = rortexGlob_mag(imax, j, k)-rortexGlob_mag(imax-1, j, k)
u_xiQ = QGlob(imax, j, k)-QGlob(imax-1, j, k)
x_xi = x(imax, j, k)-x(imax-1, j, k)
y_xi = y(imax, j, k)-y(imax-1, j, k)
z_xi = z(imax, j, k)-z(imax-1, j, k)
else
! central difference
u_xi = 0.5*(omega(i+1, j, k) - omega(i-1, j, k))
u_xiR = 0.5*(rortexGlob_mag(i+1, j, k) -rortexGlob_mag(i-1, j, k))
u_xiQ = 0.5*(QGlob(i+1, j, k) -QGlob(i-1, j, k))
x_xi = 0.5*(x(i+1, j, k) - x(i-1, j, k))
y_xi = 0.5*(y(i+1, j, k) - y(i-1, j, k))
z_xi = 0.5*(z(i+1, j, k) - z(i-1, j, k))
end if
if(j == 1) then
! forward difference
u_eta = omega(i, 2, k) - omega(i, 1, k)
u_etaR = rortexGlob_mag(i, 2, k) - rortexGlob_mag(i, 1, k)
u_etaQ = QGlob(i, 2, k) - QGlob(i, 1, k)
x_eta = x(i, 2, k) - x(i, 1, k)
y_eta = y(i, 2, k) - y(i, 1, k)
z_eta = z(i, 2, k) - z(i, 1, k)
else if(j == jmax) then
! backward difference
u_eta = omega(i, jmax, k) - omega(i, jmax-1, k)
u_etaR = rortexGlob_mag(i, jmax, k) - rortexGlob_mag(i, jmax-1, k)
u_etaQ = QGlob(i, jmax, k) - QGlob(i, jmax-1, k)
x_eta = x(i, jmax, k) - x(i, jmax-1, k)
y_eta = y(i, jmax, k) - y(i, jmax-1, k)
z_eta = z(i, jmax, k) - z(i, jmax-1, k)
else
! central difference
u_eta = 0.5*(omega(i, j+1, k) - omega(i, j-1, k))
u_etaR = 0.5*(rortexGlob_mag(i, j+1, k) - rortexGlob_mag(i, j-1, k))
u_etaQ = 0.5*(QGlob(i, j+1, k) - QGlob(i, j-1, k))
x_eta = 0.5*(x(i, j+1, k) - x(i, j-1, k))
y_eta = 0.5*(y(i, j+1, k) - y(i, j-1, k))
z_eta = 0.5*(z(i, j+1, k) - z(i, j-1, k))
end if
if(k == 1) then
! forward difference
u_zeta = omega(i, j, 2)-omega(i, j, 1)
u_zetaR = rortexGlob_mag(i, j, 2)-rortexGlob_mag(i, j, 1)
u_zetaQ = QGlob(i, j, 2)-QGlob(i, j, 1)
x_zeta = x(i, j, 2) - x(i, j, 1)
y_zeta = y(i, j, 2) - y(i, j, 1)
z_zeta = z(i, j, 2) - z(i, j, 1)
else if(k == kmax) then
! backward difference
u_zeta = omega(i, j, kmax)-omega(i, j, kmax-1)
u_zetaR = rortexGlob_mag(i, j, kmax)-rortexGlob_mag(i, j, kmax-1)
u_zetaQ = QGlob(i, j, kmax)-QGlob(i, j, kmax-1)
x_zeta = x(i, j, kmax) - x(i, j, kmax-1)
y_zeta = y(i, j, kmax) - y(i, j, kmax-1)
z_zeta = z(i, j, kmax) - z(i, j, kmax-1)
else
! central difference
u_zeta = 0.5*(omega(i, j, k+1) - omega(i, j, k-1))
u_zetaR = 0.5*(rortexGlob_mag(i, j, k+1) - rortexGlob_mag(i, j, k-1))
u_zetaQ = 0.5*(QGlob(i, j, k+1) - QGlob(i, j, k-1))
x_zeta = 0.5*(x(i, j, k+1) - x(i, j, k-1))
y_zeta = 0.5*(y(i, j, k+1) - y(i, j, k-1))
z_zeta = 0.5*(z(i, j, k+1) - z(i, j, k-1))
end if
! determinant of Jacobian
det = x_xi*(y_eta*z_zeta-y_zeta*z_eta) &
- x_eta*(y_xi*z_zeta-y_zeta*z_xi) &
+ x_zeta*(y_xi*z_eta-y_eta*z_xi)
det = 1.0/det
xi_x = det*(y_eta*z_zeta - y_zeta*z_eta)
xi_y = det*(x_zeta*z_eta - x_eta*z_zeta)
xi_z = det*(x_eta*y_zeta - x_zeta*y_eta)
eta_x = det*(y_zeta*z_xi - y_xi*z_zeta)
eta_y = det*(x_xi*z_zeta - x_zeta*z_xi)
eta_z = det*(x_zeta*y_xi - x_xi*y_zeta)
zeta_x = det*(y_xi*z_eta - y_eta*z_xi)
zeta_y = det*(x_eta*z_xi - x_xi*z_eta)
zeta_z = det*(x_xi*y_eta - x_eta*y_xi)
ii = i-istart+1
jj = j-jstart+1
kk = k-kstart+1
! velocity gradient
omg_x(i, j, k) = u_xi*xi_x + u_eta*eta_x + u_zeta*zeta_x
omg_y(i, j, k) = u_xi*xi_y + u_eta*eta_y + u_zeta*zeta_y
omg_z(i, j, k) = u_xi*xi_z + u_eta*eta_z + u_zeta*zeta_z
if(i>=istart .and. i <=iend .and. j>=jstart .and. j<= jend .and. k>=kstart .and. k<= kend ) then
omgLoc_x(ii, jj, kk) = u_xi*xi_x + u_eta*eta_x + u_zeta*zeta_x
omgLoc_y(ii, jj, kk) = u_xi*xi_y + u_eta*eta_y + u_zeta*zeta_y
omgLoc_z(ii, jj, kk) = u_xi*xi_z + u_eta*eta_z + u_zeta*zeta_z
rortex_mag_x(ii, jj, kk) = u_xiR*xi_x + u_etaR*eta_x + u_zetaR*zeta_x
rortex_mag_y(ii, jj, kk) = u_xiR*xi_y + u_etaR*eta_y + u_zetaR*zeta_y
rortex_mag_z(ii, jj, kk) = u_xiR*xi_z + u_etaR*eta_z + u_zetaR*zeta_z
QLoc_x(ii, jj, kk) = u_xiQ*xi_x + u_etaQ*eta_x + u_zetaQ*zeta_x
QLoc_y(ii, jj, kk) = u_xiQ*xi_y + u_etaQ*eta_y + u_zetaQ*zeta_y
QLoc_z(ii, jj, kk) = u_xiQ*xi_z + u_etaQ*eta_z + u_zetaQ*zeta_z
end if
end do
end do
end do
! end of the first step of hessain matrix computation
do k = kstart, kend
do j = jstart, jend
do i = istart, iend
if(i == 1) then
! forward difference
u_xi = omg_x(2, j, k) - omg_x(1, j, k)
v_xi = omg_y(2, j, k) - omg_y(1, j, k)
w_xi = omg_z(2, j, k) - omg_z(1, j, k)
x_xi = x(2, j, k) - x(1, j, k)
y_xi = y(2, j, k) - y(1, j, k)
z_xi = z(2, j, k) - z(1, j, k)
else if(i == imax) then
! backward difference
u_xi = omg_x(imax, j, k)-omg_x(imax-1, j, k)
v_xi = omg_y(imax, j, k)-omg_y(imax-1, j, k)
w_xi = omg_z(imax, j, k)-omg_z(imax-1, j, k)
x_xi = x(imax, j, k)-x(imax-1, j, k)
y_xi = y(imax, j, k)-y(imax-1, j, k)
z_xi = z(imax, j, k)-z(imax-1, j, k)
else
! central difference
u_xi = 0.5d0*(omg_x(i+1, j, k) - omg_x(i-1, j, k))
v_xi = 0.5d0*(omg_y(i+1, j, k) - omg_y(i-1, j, k))
w_xi = 0.5d0*(omg_z(i+1, j, k) - omg_z(i-1, j, k))
x_xi = 0.5d0*(x(i+1, j, k) - x(i-1, j, k))
y_xi = 0.5d0*(y(i+1, j, k) - y(i-1, j, k))
z_xi = 0.5d0*(z(i+1, j, k) - z(i-1, j, k))
end if
if(j == 1) then
! forward difference
u_eta = omg_x(i, 2, k) - omg_x(i, 1, k)
v_eta = omg_y(i, 2, k) - omg_y(i, 1, k)
w_eta = omg_z(i, 2, k) - omg_z(i, 1, k)
x_eta = x(i, 2, k) - x(i, 1, k)
y_eta = y(i, 2, k) - y(i, 1, k)
z_eta = z(i, 2, k) - z(i, 1, k)
else if(j == jmax) then
! backward difference
u_eta = omg_x(i, jmax, k) - omg_x(i, jmax-1, k)
v_eta = omg_y(i, jmax, k) - omg_y(i, jmax-1, k)
w_eta = omg_z(i, jmax, k) - omg_z(i, jmax-1, k)
x_eta = x(i, jmax, k) - x(i, jmax-1, k)
y_eta = y(i, jmax, k) - y(i, jmax-1, k)
z_eta = z(i, jmax, k) - z(i, jmax-1, k)
else
! central difference
u_eta = 0.5d0*(omg_x(i, j+1, k) - omg_x(i, j-1, k))
v_eta = 0.5d0*(omg_y(i, j+1, k) - omg_y(i, j-1, k))
w_eta = 0.5d0*(omg_z(i, j+1, k) - omg_z(i, j-1, k))
x_eta = 0.5d0*(x(i, j+1, k) - x(i, j-1, k))
y_eta = 0.5d0*(y(i, j+1, k) - y(i, j-1, k))
z_eta = 0.5d0*(z(i, j+1, k) - z(i, j-1, k))
end if
if(k == 1) then
! forward difference
u_zeta = omg_x(i, j, 2)-omg_x(i, j, 1)
v_zeta = omg_y(i, j, 2)-omg_y(i, j, 1)
w_zeta = omg_z(i, j, 2)-omg_z(i, j, 1)