-
Notifications
You must be signed in to change notification settings - Fork 0
/
spatial.f90
1182 lines (881 loc) · 35.6 KB
/
spatial.f90
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
!==============================================================================
subroutine spatial(name, ind)
!==============================================================================
!
! Driver for spatial parallel stability solver with curvature
! This is the Chebyshev Collocation version.
!
! I have both IMSL and LAPACK routines. Currently using LAPACK
!
! Revised: 10-3-96
!==============================================================================
use stuff
use material
implicit none
integer i, j, k, ix, ier, ind
integer i0, idof, j0, jdof
character(80) name
real vm(ny,ndof,nx)
real eta(ny), y(ny), deta(ny), d2eta(ny)
real D1(ny,ny), D2(ny,ny), Dt1(ny,ny), Dt2(ny,ny)
real A(ny,ndof,ndof), B(ny,ndof,ndof), C(ny,ndof,ndof)
real D(ny,ndof,ndof), G(ny,ndof,ndof)
real Vxx(ny,ndof,ndof), Vxy(ny,ndof,ndof), Vyy(ny,ndof,ndof)
real Vxz(ny,ndof,ndof), Vyz(ny,ndof,ndof), Vzz(ny,ndof,ndof)
real g1vm(ny,ndof), g2vm(ny,ndof), g3vm(ny,ndof)
real g11vm(ny,ndof), g12vm(ny,ndof), g13vm(ny,ndof)
real g22vm(ny,ndof), g23vm(ny,ndof), g33vm(ny,ndof)
real gum(ny,nsd,nsd), grhom(ny,nsd), gtm(ny,nsd), gpm(ny,nsd)
real divum(ny), g1divum(ny), g2divum(ny), g3divum(ny)
real rhom(ny), u1m(ny), u2m(ny), u3m(ny), tm(ny), pm(ny)
real rmu(ny), dmu(ny), d2mu(ny)
real rlm(ny), dlm(ny), d2lm(ny)
real con(ny), dcon(ny), d2con(ny)
real g1mu(ny), g2mu(ny), g3mu(ny)
real g1lm(ny), g2lm(ny), g3lm(ny)
real g1con(ny), g2con(ny), g3con(ny)
real g1dmu(ny), g2dmu(ny), g3dmu(ny)
real g1dlm(ny), g2dlm(ny), g3dlm(ny)
real g1dcon(ny), g2dcon(ny), g3dcon(ny)
real S1jj(ny), S2jj(ny), S3jj(ny), S(ny,nsd,nsd), Lapt(ny)
real fact
complex Dh(ny,ndof,ndof), Ah(ny,ndof,ndof), Bh(ny,ndof,ndof)
complex :: scale
complex A0(2*ndof*ny,2*ndof*ny), B0(2*ndof*ny,2*ndof*ny)
complex C0(ndof*ny,ndof*ny), C1(ndof*ny,ndof*ny), C2(ndof*ny,ndof*ny)
complex evec(2*ndof*ny,2*ndof*ny), alp(2*ndof*ny), bet(2*ndof*ny)
complex omg(2*ndof*ny), cs(2*ndof*ny)
real temp1(2*ndof*ny), temp2(2*ndof*ny)
integer index(2*ndof*ny)
!.... stuff for LAPACK eigensolver
integer info, lwork
complex, allocatable :: work(:)
real, allocatable :: rwork(:)
!.... stuff for IMSL LU factorization
integer, allocatable :: ipvt(:)
real :: rcond
!.... some parameters
real, parameter :: big = 1.0e98
!.... metrics for the curved wall
real :: h(ny), dhds(ny), dhdr(ny), dhdsr(ny), dhdrr(ny)
!==============================================================================
if (verbose) write(*,*) "Starting Spatial eigenproblem"
!.... determine if inviscid
if (Re.ge.big .or. Re.eq.zero) then
write(*,*) 'A T T E N T I O N: Inviscid flow'
Navier = .false.
end if
!.... make the grid
call sgengrid(y, eta, deta, d2eta)
!.... read the mean field
if (ider) then
call getmean(vm, y, eta, ny, ind)
else
call getmean2(vm, y, eta, g2vm, g22vm, ny, ind)
end if
if (verbose) write(*,*) "Finished mean flow"
!.... Initialize the metric terms for curvature
if (curve.eq.1) then
call calch( x, ny, y, h, dhds, dhdr, dhdsr, dhdrr )
else if (curve.eq.2) then
! h = x + y ! note that x is the radius here
! dhds = zero
! dhdr = one
! dhdsr = zero
! dhdrr = zero
call circh( x, ny, y, h, dhds, dhdr, dhdsr, dhdrr )
else
h = one
dhds = zero
dhdr = zero
dhdsr = zero
dhdrr = zero
end if
!.... loop over the streamwise stations (obsolete)
do ix = 1, nx
!.... initialize
G = zero
A = zero
B = zero
C = zero
D = zero
Vxx = zero
Vxy = zero
Vyy = zero
Vxz = zero
Vyz = zero
Vzz = zero
!.... setup parallel flow
rhom = vm(:,1,ix)
u1m = vm(:,2,ix)
u2m = zero
u3m = vm(:,4,ix)
tm = vm(:,5,ix)
pm = one / (gamma * Ma**2) * rhom * tm
!.... Compute the Chebyshev derivative matrices
call chebyd(D1, ny-1) ! use ny-1 since this routine uses 0:ny
D2 = matmul(D1, D1) ! compute the second derivative
if (wallt.eq.2) then
Dt1 = D1 ! Derivative operator for temperature
Dt1(ny,:) = zero ! adiabatic wall
Dt2 = matmul(D1, Dt1) ! Second Derivative operator for temperature
else
Dt1 = D1
Dt2 = D2
end if
!.... Compute derivatives of mean field using the appropriate difference scheme
g1vm = zero
if (ider) then
do idof = 1, ndof
g2vm(:,idof) = matmul(D1,vm(:,idof,ix))
end do
end if
g3vm = zero
g11vm = zero
g12vm = zero
g13vm = zero
if (ider) then
do idof = 1, ndof
g22vm(:,idof) = matmul(D2,vm(:,idof,ix))
end do
end if
g23vm = zero
g33vm = zero
!.... transform the gradients to physical space
if (ider) then
do k = 1, ndof
g22vm(:,k) = g22vm(:,k) * deta**2 + g2vm(:,k) * d2eta
g2vm(:,k) = g2vm(:,k) * deta
end do
end if
!.... write out the mean field and its gradients
if (.true.) then
open(10,file='rho.out')
do j = 1, ny
write (10,13) y(j), vm(j,1,ix), g2vm(j,1), g22vm(j,1)
end do
close(10)
open(10,file='u.out')
do j = ny, 1, -1
write (10,13) y(j), vm(j,2,ix), g2vm(j,2), g22vm(j,2)
end do
close(10)
open(10,file='w.out')
do j = 1, ny
write (10,13) y(j), vm(j,4,ix), g2vm(j,4), g22vm(j,4)
end do
close(10)
open(10,file='t.out')
do j = 1, ny
write (10,13) y(j), vm(j,5,ix), g2vm(j,5), g22vm(j,5)
end do
close(10)
13 format(4(1pe20.13,1x))
end if
!.... initialize gradient of mean velocity
gum(:,1,1) = g1vm(:,2)
gum(:,1,2) = g2vm(:,2)
gum(:,1,3) = g3vm(:,2)
gum(:,2,1) = g1vm(:,3)
gum(:,2,2) = g2vm(:,3)
gum(:,2,3) = g3vm(:,3)
gum(:,3,1) = g1vm(:,4)
gum(:,3,2) = g2vm(:,4)
gum(:,3,3) = g3vm(:,4)
!.... compute the divergence (curve*)
divum = ( gum(:,1,1) + u2m * dhdr ) / h + gum(:,2,2) + gum(:,3,3)
!.... initialize gradient of rho and T in the mean
grhom(:,1) = g1vm(:,1)
grhom(:,2) = g2vm(:,1)
grhom(:,3) = g3vm(:,1)
gtm(:,1) = g1vm(:,5)
gtm(:,2) = g2vm(:,5)
gtm(:,3) = g3vm(:,5)
fact = one / (gamma * Ma**2)
gpm(:,1) = fact * ( grhom(:,1) * tm + rhom * gtm(:,1) )
gpm(:,2) = fact * ( grhom(:,2) * tm + rhom * gtm(:,2) )
gpm(:,3) = fact * ( grhom(:,3) * tm + rhom * gtm(:,3) )
!.... compute the gradient of the divergence of um (curve*)
g1divum = -dhds / h**3 * ( gum(:,1,1) + u2m * dhdr ) + &
one / h**2 * ( g11vm(:,2) + gum(:,2,1) * dhdr + &
u2m * dhdsr ) + one / h * ( g12vm(:,3) + g13vm(:,4) )
g2divum = -dhdr / h**2 * ( gum(:,1,1) + u2m * dhdr ) + &
one / h * ( g12vm(:,2) + gum(:,2,2) * dhdr + &
u2m * dhdrr ) + ( g22vm(:,3) + g23vm(:,4) )
g3divum = one / h * ( g13vm(:,2) + gum(:,2,3) * dhdr ) + &
g23vm(:,3) + g33vm(:,4)
!.... compute some stuff that is useful for the viscous terms (curve*)
S(:,1,1) = ( gum(:,1,1) + u2m * dhdr ) / h
S(:,1,2) = pt5 * ( ( gum(:,2,1) - u1m * dhdr ) / h + gum(:,1,2) )
S(:,1,3) = pt5 * ( gum(:,3,1) / h + gum(:,1,3) )
S(:,2,1) = S(:,1,2)
S(:,2,2) = gum(:,2,2)
S(:,2,3) = pt5 * ( gum(:,3,2) + gum(:,2,3) )
S(:,3,1) = S(:,1,3)
S(:,3,2) = S(:,2,3)
S(:,3,3) = gum(:,3,3)
S1jj = -pt5 * ( dhdr**2 + dhdrr * h ) / h**2 * u1m + &
pt5 * dhdr * gum(:,1,2) / h + pt5 * g22vm(:,2) - &
dhds * gum(:,1,1) / h**3 + g11vm(:,2) / h**2 + &
pt5 * g33vm(:,2) + ( h * dhdsr - dhdr * dhds ) / h**3 * u2m + &
3.0 * dhdr * gum(:,2,1) / (two * h**2) + &
pt5 * g12vm(:,3) / h + pt5 * g13vm(:,4) / h
S2jj = pt5 * ( dhdr * dhds - h * dhdsr ) / h**3 * u1m - &
3.0 * dhdr * gum(:,1,1) / (two * h**2) + &
pt5 * g12vm(:,2) / h - dhdr**2 * u2m / h**2 + &
dhdr * gum(:,2,2) / h + g22vm(:,3) - &
pt5 * dhds * gum(:,2,1) / h**3 + pt5 * g11vm(:,3) / h**2 + &
pt5 * g33vm(:,3) + pt5 * g23vm(:,4)
S3jj = pt5 * g13vm(:,2) / h + pt5 * g23vm(:,3) + &
pt5 * dhdr * gum(:,2,3) / h + pt5 * dhdr * gum(:,3,2) / h + &
pt5 * g22vm(:,4) + pt5 * g11vm(:,4) / h**2 + g33vm(:,4) - &
pt5 * dhds * gum(:,3,1) / h**3
!.... Laplacian of Tm (curve*)
LapT = one/h * ( -dhds/h**2 * gtm(:,1) + one/h * g11vm(:,5) + &
h * g22vm(:,5) + gtm(:,2) * dhdr + h * g33vm(:,5) )
!.... compute mean material properties
call getmat(tm*te, rmu, rlm, con, dmu, d2mu, &
dlm, d2lm, dcon, d2con)
!.... nondimensionalize
rmu = rmu / rmue
dmu = dmu * Te / rmue
d2mu = d2mu * Te**2 / rmue
con = con / cone
dcon = dcon * Te / cone
d2con = d2con * Te**2 / cone
rlm = rlm / rlme
dlm = dlm * Te / rlme
d2lm = d2lm * Te**2 / rlme
!.... compute gradients of viscosity using chain-rule
g1mu = dmu * gtm(:,1)
g2mu = dmu * gtm(:,2)
g3mu = dmu * gtm(:,3)
g1dmu = d2mu * gtm(:,1)
g2dmu = d2mu * gtm(:,2)
g3dmu = d2mu * gtm(:,3)
!.... compute gradients of conductivity using chain-rule
g1con = dcon * gtm(:,1)
g2con = dcon * gtm(:,2)
g3con = dcon * gtm(:,3)
g1dcon = d2con * gtm(:,1)
g2dcon = d2con * gtm(:,2)
g3dcon = d2con * gtm(:,3)
!.... compute gradients of bulk viscosity using chain-rule
g1lm = dlm * gtm(:,1)
g2lm = dlm * gtm(:,2)
g3lm = dlm * gtm(:,3)
g1dlm = d2lm * gtm(:,1)
g2dlm = d2lm * gtm(:,2)
g3dlm = d2lm * gtm(:,3)
!==============================================================================
!.... Continuity equation (curve*)
G(:,1,1) = one
A(:,1,1) = u1m / h
A(:,1,2) = rhom / h
B(:,1,1) = u2m
B(:,1,3) = rhom
C(:,1,1) = u3m
C(:,1,4) = rhom
D(:,1,1) = divum
D(:,1,2) = grhom(:,1) / h
D(:,1,3) = grhom(:,2) + rhom * dhdr / h
D(:,1,4) = grhom(:,3)
!.... Momentum equation -- x_1 (convective + pressure) (curve*)
G(:,2,2) = rhom
A(:,2,1) = tm/(h * gamma * Ma**2)
A(:,2,2) = rhom * u1m / h
A(:,2,5) = rhom/(h * gamma * Ma**2)
B(:,2,2) = rhom * u2m
C(:,2,2) = rhom * u3m
D(:,2,1) = u1m / h * ( gum(:,1,1) + u2m * dhdr ) + &
u2m * gum(:,1,2) + u3m * gum(:,1,3) &
+ gtm(:,1) / (h * gamma * Ma**2)
D(:,2,2) = rhom * ( gum(:,1,1) + u2m * dhdr ) / h
D(:,2,3) = rhom * ( gum(:,1,2) + u1m * dhdr / h )
D(:,2,4) = rhom * gum(:,1,3)
D(:,2,5) = grhom(:,1) / (h * gamma * Ma**2)
!.... (viscous lambda) (curve*)
if (Navier) then
fact = rlme / (rmue * Re)
A(:,2,2) = A(:,2,2) - fact * ( g1lm / h**2 - rlm / h**3 * dhds )
A(:,2,3) = A(:,2,3) - fact * rlm / h**2 * dhdr
A(:,2,5) = A(:,2,5) - fact * dlm * divum / h
B(:,2,3) = B(:,2,3) - fact * ( g1lm / h )
C(:,2,4) = C(:,2,4) - fact * ( g1lm / h )
D(:,2,3) = D(:,2,3) - fact * ( g1lm * dhdr / h**2 - &
rlm / h**3 * dhds * dhdr + &
rlm / h**2 * dhdsr )
D(:,2,5) = D(:,2,5) - fact * ( g1dlm * divum / h + dlm * g1divum )
Vxx(:,2,2) = fact * rlm / h**2
Vxy(:,2,3) = fact * rlm / h
Vxz(:,2,4) = fact * rlm / h
!.... (viscous mu) (curve*)
fact = one / Re
A(:,2,2) = A(:,2,2) - fact * ( two * g1mu / h**2 - &
two * rmu * dhds / h**3 )
A(:,2,3) = A(:,2,3) - fact * ( g2mu / h + &
rmu * 3.0 * dhdr / h**2 )
A(:,2,4) = A(:,2,4) - fact * g3mu / h
A(:,2,5) = A(:,2,5) - fact * dmu * two * S(:,1,1) / h
B(:,2,2) = B(:,2,2) - fact * ( g2mu + rmu * dhdr / h )
B(:,2,5) = B(:,2,5) - fact * dmu * two * S(:,1,2)
C(:,2,2) = C(:,2,2) - fact * g3mu
C(:,2,5) = C(:,2,5) - fact * dmu * two * S(:,1,3)
D(:,2,2) = D(:,2,2) - fact * ( g2mu / h * (-dhdr) - &
rmu * ( dhdr**2 + dhdrr * h ) / h**2 )
D(:,2,3) = D(:,2,3) - fact * ( two * g1mu / h**2 * dhdr + &
two * rmu * ( dhdsr * h - dhds * dhdr ) / h**3 )
D(:,2,5) = D(:,2,5) - fact * two * ( g1dmu / h * S(:,1,1) + &
g2dmu * S(:,1,2) + g3dmu * S(:,1,3) + &
dmu * S1jj )
Vxx(:,2,2) = Vxx(:,2,2) + fact * two * rmu / h**2
Vxy(:,2,3) = Vxy(:,2,3) + fact * rmu / h
Vyy(:,2,2) = Vyy(:,2,2) + fact * rmu
Vxz(:,2,4) = Vxz(:,2,4) + fact * rmu / h
Vzz(:,2,2) = Vzz(:,2,2) + fact * rmu
end if
!.... Momentum equation -- x_2 (convective + pressure) (curve*)
G(:,3,3) = rhom
A(:,3,3) = rhom * u1m / h
B(:,3,1) = tm/(gamma * Ma**2)
B(:,3,3) = rhom * u2m
B(:,3,5) = rhom/(gamma * Ma**2)
C(:,3,3) = rhom * u3m
D(:,3,1) = u1m / h * ( gum(:,2,1) - u1m * dhdr ) + &
u2m * gum(:,2,2) + u3m * gum(:,2,3) + &
gtm(:,2) / (gamma * Ma**2)
D(:,3,2) = rhom * ( gum(:,2,1) - two * u1m * dhdr ) / h
D(:,3,3) = rhom * gum(:,2,2)
D(:,3,4) = rhom * gum(:,2,3)
D(:,3,5) = grhom(:,2) / (gamma * Ma**2)
!.... (viscous lambda) (curve*)
if (Navier) then
fact = rlme / (rmue * Re)
A(:,3,2) = A(:,3,2) - fact * ( g2lm / h - rlm * dhdr / h**2 )
B(:,3,3) = B(:,3,3) - fact * ( g2lm + rlm * dhdr / h )
B(:,3,5) = B(:,3,5) - fact * dlm * divum
C(:,3,4) = C(:,3,4) - fact * ( g2lm )
D(:,3,3) = D(:,3,3) - fact * ( g2lm / h * dhdr - &
rlm * dhdr / h**2 * dhdr + &
rlm / h * dhdrr )
D(:,3,5) = D(:,3,5) - fact * ( g2dlm * divum + dlm * g2divum )
Vxy(:,3,2) = fact * rlm / h
Vyy(:,3,3) = fact * rlm
Vyz(:,3,4) = fact * rlm
!.... (viscous mu) (curve*)
fact = one / Re
A(:,3,2) = A(:,3,2) + fact * rmu * 3.0 * dhdr / h**2
A(:,3,3) = A(:,3,3) - fact * ( g1mu / h**2 - &
rmu * dhds / h**3 )
A(:,3,5) = A(:,3,5) - fact * dmu * two * S(:,2,1) / h
B(:,3,2) = B(:,3,2) - fact * g1mu / h
B(:,3,3) = B(:,3,3) - fact * ( two * g2mu + two * rmu * dhdr / h )
B(:,3,4) = B(:,3,4) - fact * g3mu
B(:,3,5) = B(:,3,5) - fact * dmu * two * S(:,2,2)
C(:,3,3) = C(:,3,3) - fact * g3mu
C(:,3,5) = C(:,3,5) - fact * dmu * two * S(:,2,3)
D(:,3,2) = D(:,3,2) - fact * ( g1mu / h**2 * (-dhdr) + &
rmu * (dhds * dhdr - h * dhdsr) / h**3 )
D(:,3,3) = D(:,3,3) + fact * two * rmu * dhdr**2 / h**2
D(:,3,5) = D(:,3,5) - fact * two * ( g1dmu / h * S(:,2,1) + &
g2dmu * S(:,2,2) + g3dmu * S(:,2,3) + &
dmu * S2jj )
Vxx(:,3,3) = Vxx(:,3,3) + fact * rmu / h**2
Vxy(:,3,2) = Vxy(:,3,2) + fact * rmu / h
Vyy(:,3,3) = Vyy(:,3,3) + fact * two * rmu
Vyz(:,3,4) = Vyz(:,3,4) + fact * rmu
Vzz(:,3,3) = Vzz(:,3,3) + fact * rmu
end if
!.... Momentum equation -- x_3 (convective + pressure) (curve*)
G(:,4,4) = rhom
A(:,4,4) = rhom * u1m / h
B(:,4,4) = rhom * u2m
C(:,4,1) = tm/(gamma * Ma**2)
C(:,4,4) = rhom * u3m
C(:,4,5) = rhom/(gamma * Ma**2)
D(:,4,1) = u1m * gum(:,3,1) / h + u2m * gum(:,3,2) + &
u3m * gum(:,3,3) + gtm(:,3) / (gamma * Ma**2)
D(:,4,2) = rhom * gum(:,3,1) / h
D(:,4,3) = rhom * gum(:,3,2)
D(:,4,4) = rhom * gum(:,3,3)
D(:,4,5) = grhom(:,3) / (gamma * Ma**2)
!.... (viscous lambda) (curve*)
if (Navier) then
fact = rlme / (rmue * Re)
A(:,4,2) = A(:,4,2) - fact * g3lm / h
B(:,4,3) = B(:,4,3) - fact * g3lm
C(:,4,4) = C(:,4,4) - fact * g3lm
C(:,4,3) = C(:,4,3) - fact * rlm / h * dhdr
C(:,4,5) = C(:,4,5) - fact * dlm * divum
D(:,4,3) = D(:,4,3) - fact * ( g2lm / h * dhdr )
D(:,4,5) = D(:,4,5) - fact * ( g3dlm * divum + dlm * g3divum )
Vxz(:,4,2) = fact * rlm / h
Vyz(:,4,3) = fact * rlm
Vzz(:,4,4) = fact * rlm
!.... (viscous mu) (curve*)
fact = one / Re
A(:,4,4) = A(:,4,4) - fact * ( g1mu / h**2 - rmu * dhds / h**3 )
A(:,4,5) = A(:,4,5) - fact * dmu * two * S(:,3,1) / h
B(:,4,4) = B(:,4,4) - fact * ( g2mu + rmu * dhdr / h )
B(:,4,5) = B(:,4,5) - fact * dmu * two * S(:,3,2)
C(:,4,2) = C(:,4,2) - fact * g1mu / h
C(:,4,3) = C(:,4,3) - fact * ( g2mu + rmu * dhdr / h )
C(:,4,4) = C(:,4,4) - fact * two * g3mu
C(:,4,5) = C(:,4,5) - fact * dmu * two * S(:,3,3)
D(:,4,5) = D(:,4,5) - fact * two * ( g1dmu / h * S(:,3,1) + &
g2dmu * S(:,3,2) + g3dmu * S(:,3,3) + &
dmu * S3jj )
Vxx(:,4,4) = Vxx(:,4,4) + fact * rmu / h**2
Vyy(:,4,4) = Vyy(:,4,4) + fact * rmu
Vxz(:,4,2) = Vxz(:,4,2) + fact * rmu / h
Vyz(:,4,3) = Vyz(:,4,3) + fact * rmu
Vzz(:,4,4) = Vzz(:,4,4) + fact * two * rmu
end if
!.... Energy equation (Advection + pressure) (curve*)
G(:,5,5) = rhom
A(:,5,2) = rhom * gamma1 * tm / h
A(:,5,5) = rhom * u1m / h
B(:,5,3) = rhom * gamma1 * tm
B(:,5,5) = rhom * u2m
C(:,5,4) = rhom * gamma1 * tm
C(:,5,5) = rhom * u3m
D(:,5,1) = u1m / h * gtm(:,1) + u2m * gtm(:,2) + u3m * gtm(:,3) + &
gamma1 * tm * divum
D(:,5,2) = rhom * gtm(:,1) / h
D(:,5,3) = rhom * gtm(:,2) + rhom * gamma1 * tm * dhdr / h
D(:,5,4) = rhom * gtm(:,3)
!.... It looks like I'm using the NONLINEAR D(5,5) ??
!.... It's okay, since d\bar\rho/dt = 0
D(:,5,5) = rhom * gamma1 * divum
if (Navier) then
!.... diffusion (curve*)
fact = gamma / (Pr * Re)
A(:,5,5) = A(:,5,5) - fact * (g1con / h**2 + dcon * gtm(:,1) / h**2 - &
con * dhds / h**3 )
B(:,5,5) = B(:,5,5) - fact * (g2con + dcon * gtm(:,2) + &
con * dhdr / h )
C(:,5,5) = C(:,5,5) - fact * (g3con + dcon * gtm(:,3))
D(:,5,5) = D(:,5,5) - fact * (g1dcon * gtm(:,1) / h**2 + &
g2dcon * gtm(:,2) + g3dcon * gtm(:,3) + &
dcon * Lapt )
Vxx(:,5,5) = fact * con / h**2
Vyy(:,5,5) = fact * con
Vzz(:,5,5) = fact * con
!.... dissipation (lambda) (curve*)
fact = gamma * gamma1 * Ma**2 * rlme / (Re * rmue)
A(:,5,2) = A(:,5,2) - fact * two * rlm * divum / h
B(:,5,3) = B(:,5,3) - fact * two * rlm * divum
C(:,5,4) = C(:,5,4) - fact * two * rlm * divum
D(:,5,3) = D(:,5,3) - fact * two * rlm * divum * dhdr / h
D(:,5,5) = D(:,5,5) - fact * dlm * divum * divum
!.... dissipation (mu) (curve*)
fact = gamma * gamma1 * Ma**2 / Re
A(:,5,2) = A(:,5,2) - fact * four * rmu * S(:,1,1) / h
A(:,5,3) = A(:,5,3) - fact * four * rmu * S(:,2,1) / h
A(:,5,4) = A(:,5,4) - fact * four * rmu * S(:,3,1) / h
B(:,5,2) = B(:,5,2) - fact * four * rmu * S(:,1,2)
B(:,5,3) = B(:,5,3) - fact * four * rmu * S(:,2,2)
B(:,5,4) = B(:,5,4) - fact * four * rmu * S(:,3,2)
C(:,5,2) = C(:,5,2) - fact * four * rmu * S(:,1,3)
C(:,5,3) = C(:,5,3) - fact * four * rmu * S(:,2,3)
C(:,5,4) = C(:,5,4) - fact * four * rmu * S(:,3,3)
D(:,5,2) = D(:,5,2) + fact * four * rmu * S(:,2,1) * dhdr / h
D(:,5,3) = D(:,5,3) - fact * four * rmu * S(:,1,1) * dhdr / h
D(:,5,5) = D(:,5,5) - fact * two * dmu * ( S(:,1,1)**2 + &
S(:,1,2)**2 + S(:,1,3)**2 + S(:,2,1)**2 + &
S(:,2,2)**2 + S(:,2,3)**2 + S(:,3,1)**2 + &
S(:,3,2)**2 + S(:,3,3)**2)
end if
!==============================================================================
if(verbose) write(*,*) "Finished building matrices"
!.... initialize
C0 = zero
C1 = zero
C2 = zero
!.... form the equations
Dh = D + im * beta * C + beta**2 * Vzz
Bh = B - im * beta * Vyz
!.... account for the mapping
do idof = 1, ndof
do jdof = 1, ndof
Bh(:,idof,jdof) = Bh(:,idof,jdof) * deta - Vyy(:,idof,jdof) * d2eta
Vyy(:,idof,jdof) = Vyy(:,idof,jdof) * deta**2
end do
end do
!.... C0
if (top.eq.1) then
i = 1
i0 = (i-1)*ndof
idof = 1 ! continuity at infinity
do jdof = 1, ndof
do j = 1, ny
j0 = (j-1)*ndof
C0(i0+idof,j0+jdof) = C0(i0+idof,j0+jdof) + &
Bh(i,idof,jdof) * D1(i,j)
end do
j0 = (i-1)*ndof
C0(i0+idof,j0+jdof) = C0(i0+idof,j0+jdof) + Dh(i,idof,jdof)
end do
end if
do idof = 1, ndof
do jdof = 1, ndof
do i = 2, ny-1
i0 = (i-1)*ndof
do j = 1, ny
j0 = (j-1)*ndof
C0(i0+idof,j0+jdof) = C0(i0+idof,j0+jdof) + &
Bh(i,idof,jdof) * D1(i,j) - &
Vyy(i,idof,jdof) * D2(i,j)
end do
j0 = (i-1)*ndof
C0(i0+idof,j0+jdof) = C0(i0+idof,j0+jdof) + Dh(i,idof,jdof)
end do
end do
end do
i = ny
i0 = (i-1)*ndof
idof = 1 ! continuity equation at the wall
do jdof = 1, ndof
do j = 1, ny
j0 = (j-1)*ndof
C0(i0+idof,j0+jdof) = C0(i0+idof,j0+jdof) + &
Bh(i,idof,jdof) * D1(i,j)
end do
j0 = (i-1)*ndof
C0(i0+idof,j0+jdof) = C0(i0+idof,j0+jdof) + Dh(i,idof,jdof)
end do
if (wallt.eq.2) then
idof = ndof ! energy equation at the wall
do jdof = 1, ndof-1
do j = 1, ny
j0 = (j-1)*ndof
C0(i0+idof,j0+jdof) = C0(i0+idof,j0+jdof) + &
Bh(i,idof,jdof) * D1(i,j) - &
Vyy(i,idof,jdof) * D2(i,j)
end do
j0 = (i-1)*ndof
C0(i0+idof,j0+jdof) = C0(i0+idof,j0+jdof) + Dh(i,idof,jdof)
end do
jdof = ndof
do j = 1, ny
j0 = (j-1)*ndof
C0(i0+idof,j0+jdof) = C0(i0+idof,j0+jdof) + &
Bh(i,idof,jdof) * Dt1(i,j) - &
Vyy(i,idof,jdof) * Dt2(i,j)
end do
j0 = (i-1)*ndof
C0(i0+idof,j0+jdof) = C0(i0+idof,j0+jdof) + Dh(i,idof,jdof)
end if
!.... Add the time term into C0 accounting for BC's
i = 1
if (top.eq.1) then
C0(1,1) = C0(1,1) - im * omega ! continuity equation
else
C0(1,1) = -one ! zero density at infinity
end if
C0(2,2) = -one
C0(3,3) = -one
C0(4,4) = -one
C0(5,5) = -one
do idof = 1, ndof
do jdof = 1, ndof
do i = 2, ny-1
i0 = (i-1)*ndof
C0(i0+idof,i0+jdof) = C0(i0+idof,i0+jdof) - &
im * omega * G(i,idof,jdof)
end do
end do
end do
i = ny
i0 = (i-1)*ndof
idof = 1
C0(i0+idof,i0+idof) = C0(i0+idof,i0+idof) - im * omega
idof = 2
C0(i0+idof,i0+idof) = C0(i0+idof,i0+idof) - one
idof = 3
C0(i0+idof,i0+idof) = C0(i0+idof,i0+idof) - one
idof = 4
C0(i0+idof,i0+idof) = C0(i0+idof,i0+idof) - one
idof = ndof
if (wallt.eq.0) then
C0(i0+idof,i0+idof) = C0(i0+idof,i0+idof) - one
else if (wallt.eq.2) then
do jdof = 1, ndof
C0(i0+idof,i0+jdof) = C0(i0+idof,i0+jdof) - im * omega * &
G(i,idof,jdof)
end do
else
write(*,"('Illegal value of wallt: ',i4)") wallt
call exit(1)
end if
!.... form the equations
Dh = im * A + beta * Vxz
Bh = -im * Vxy
!.... account for the mapping
do idof = 1, ndof
do jdof = 1, ndof
Bh(:,idof,jdof) = Bh(:,idof,jdof) * deta
end do
end do
!.... C1
if (top.eq.1) then
i = 1
i0 = (i-1)*ndof
idof = 1 ! continuity equation at infinity
do jdof = 1, ndof
do j = 1, ny
j0 = (j-1)*ndof
C1(i0+idof,j0+jdof) = C1(i0+idof,j0+jdof) + &
Bh(i,idof,jdof) * D1(i,j)
end do
j0 = (i-1)*ndof
C1(i0+idof,j0+jdof) = C1(i0+idof,j0+jdof) + Dh(i,idof,jdof)
end do
end if
do idof = 1, ndof
do jdof = 1, ndof
do i = 2, ny-1
i0 = (i-1)*ndof
do j = 1, ny
j0 = (j-1)*ndof
C1(i0+idof,j0+jdof) = C1(i0+idof,j0+jdof) + &
Bh(i,idof,jdof) * D1(i,j)
end do
j0 = (i-1)*ndof
C1(i0+idof,j0+jdof) = C1(i0+idof,j0+jdof) + Dh(i,idof,jdof)
end do
end do
end do
i = ny
i0 = (i-1)*ndof
idof = 1 ! density equation at the wall
do jdof = 1, ndof
do j = 1, ny
j0 = (j-1)*ndof
C1(i0+idof,j0+jdof) = C1(i0+idof,j0+jdof) + &
Bh(i,idof,jdof) * D1(i,j)
end do
j0 = (i-1)*ndof
C1(i0+idof,j0+jdof) = C1(i0+idof,j0+jdof) + Dh(i,idof,jdof)
end do
if (wallt.eq.2) then
i = ny
i0 = (i-1)*ndof
idof = ndof ! energy equation at the wall
do jdof = 1, ndof-1
do j = 1, ny
j0 = (j-1)*ndof
C1(i0+idof,j0+jdof) = C1(i0+idof,j0+jdof) + &
Bh(i,idof,jdof) * D1(i,j)
end do
j0 = (i-1)*ndof
C1(i0+idof,j0+jdof) = C1(i0+idof,j0+jdof) + Dh(i,idof,jdof)
end do
jdof = ndof
do j = 1, ny
j0 = (j-1)*ndof
C1(i0+idof,j0+jdof) = C1(i0+idof,j0+jdof) + &
Bh(i,idof,jdof) * Dt1(i,j)
end do
j0 = (i-1)*ndof
C1(i0+idof,j0+jdof) = C1(i0+idof,j0+jdof) + Dh(i,idof,jdof)
end if
!.... C2 (only viscous contribution)
do idof = 1, ndof
do jdof = 1, ndof
do i = 2, ny-1
i0 = (i-1)*ndof
C2(i0+idof,i0+jdof) = Vxx(i,idof,jdof)
end do
end do
end do
if (wallt.eq.2) then
i = ny
i0 = (i-1)*ndof
idof = ndof ! energy equation at the wall
do jdof = 1, ndof
C2(i0+idof,i0+jdof) = Vxx(i,idof,jdof)
end do
end if
!.... form the extended system
if (verbose) write(*,*) "Forming the extended system"
A0 = zero
B0 = zero
evec = zero
alp = zero
bet = zero
omg = zero
allocate (ipvt(ndof*ny))
#ifdef CRAY
call CGETRF(ndof*ny, ndof*ny, C0, ndof*ny, ipvt, info)
if (info.ne.zero) write(*,*) 'CGETRF: ',info
#else
call ZGETRF(ndof*ny, ndof*ny, C0, ndof*ny, ipvt, info)
if (info.ne.zero) write(*,*) 'ZGETRF: ',info
#endif
C1 = -C1
C2 = -C2
#ifdef CRAY
call CGETRS('N', ndof*ny, ndof*ny, C0, ndof*ny, &
ipvt, C1, ndof*ny, info)
if (info.ne.0) then
write(*,*) 'CGETRS: ',info
call exit(1)
end if
call CGETRS('N', ndof*ny, ndof*ny, C0, ndof*ny, &
ipvt, C2, ndof*ny, info)
if (info.ne.0) write(*,*) 'CGETRS: ',info
#else
call ZGETRS('N', ndof*ny, ndof*ny, C0, ndof*ny, &
ipvt, C1, ndof*ny, info)
if (info.ne.0) then
write(*,*) 'ZGETRS: ',info
call exit(1)