This repository has been archived by the owner on Nov 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
convdiff.f90
2104 lines (1751 loc) · 76.1 KB
/
convdiff.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
!################################################################################
!This file is part of Incompact3d.
!
!Incompact3d
!Copyright (c) 2012 Eric Lamballais and Sylvain Laizet
!
! Incompact3d is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation.
!
! Incompact3d is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with the code. If not, see <http://www.gnu.org/licenses/>.
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
! We kindly request that you cite Incompact3d in your publications and
! presentations. The following citations are suggested:
!
! 1-Laizet S. & Lamballais E., 2009, High-order compact schemes for
! incompressible flows: a simple and efficient method with the quasi-spectral
! accuracy, J. Comp. Phys., vol 228 (15), pp 5989-6015
!
! 2-Laizet S. & Li N., 2011, Incompact3d: a powerful tool to tackle turbulence
! problems with up to 0(10^5) computational cores, Int. J. of Numerical
! Methods in Fluids, vol 67 (11), pp 1735-1757
!################################################################################
!********************************************************************
!
!
!********************************************************************
subroutine convdiff(ux1,uy1,uz1,rho1,mu1,ta1,tb1,tc1,td1,te1,tf1,tg1,th1,ti1,di1,&
ux2,uy2,uz2,rho2,mu2,ta2,tb2,tc2,td2,te2,tf2,tg2,th2,ti2,tj2,di2,&
ux3,uy3,uz3,rho3,mu3,divu3,ta3,tb3,tc3,td3,te3,tf3,tg3,th3,ti3,di3)
USE param
USE variables
USE decomp_2d
USE MPI
implicit none
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: ux1,uy1,uz1
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: ta1,tb1,tc1,td1,te1,tf1,tg1,th1,ti1,di1
real(mytype),dimension(ysize(1),ysize(2),ysize(3)) :: ux2,uy2,uz2
real(mytype),dimension(ysize(1),ysize(2),ysize(3)) :: ta2,tb2,tc2,td2,te2,tf2,tg2,th2,ti2,tj2,di2
real(mytype),dimension(zsize(1),zsize(2),zsize(3)) :: ux3,uy3,uz3
real(mytype),dimension(zsize(1),zsize(2),zsize(3)) :: ta3,tb3,tc3,td3,te3,tf3,tg3,th3,ti3,di3
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: rho1
real(mytype),dimension(ysize(1),ysize(2),ysize(3)) :: rho2
real(mytype),dimension(zsize(1),zsize(2),zsize(3)) :: rho3
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: divu1
real(mytype),dimension(ysize(1),ysize(2),ysize(3)) :: divu2
real(mytype),dimension(zsize(1),zsize(2),zsize(3)) :: divu3
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: clx1, cly1, clz1
real(mytype),dimension(ysize(1),ysize(2),ysize(3)) :: clx2, cly2, clz2
real(mytype),dimension(zsize(1),zsize(2),zsize(3)) :: clx3, cly3, clz3
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: mu1
real(mytype),dimension(ysize(1),ysize(2),ysize(3)) :: mu2
real(mytype),dimension(zsize(1),zsize(2),zsize(3)) :: mu3
integer :: ijk,nvect1,nvect2,nvect3,i,j,k
real(mytype) :: x,y,z
real(mytype), parameter :: ONETHIRD = 1._mytype / 3._mytype
logical :: entrain_y, entrain_z
entrain_y = .FALSE.
entrain_z = .FALSE.
if (itype.eq.5) then
if (ncly.eq.2) then
entrain_y = .TRUE.
endif
if (nclz.eq.2) then
entrain_z = .TRUE.
endif
endif
nvect1=xsize(1)*xsize(2)*xsize(3)
nvect2=ysize(1)*ysize(2)*ysize(3)
nvect3=zsize(1)*zsize(2)*zsize(3)
if (iskew==0) then !UROTU!
!WORK X-PENCILS
call derx (ta1,uy1,di1,sx,ffxp,fsxp,fwxp,xsize(1),xsize(2),xsize(3),1)
call derx (tb1,uz1,di1,sx,ffxp,fsxp,fwxp,xsize(1),xsize(2),xsize(3),1)
call transpose_x_to_y(ux1,ux2)
call transpose_x_to_y(uy1,uy2)
call transpose_x_to_y(uz1,uz2)
call transpose_x_to_y(ta1,ta2)
call transpose_x_to_y(tb1,tb2)
!WORK Y-PENCILS
call dery (tc2,ux2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
call dery (td2,uz2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
call transpose_y_to_z(ux2,ux3)
call transpose_y_to_z(uy2,uy3)
call transpose_y_to_z(uz2,uz3)
call transpose_y_to_z(ta2,ta3)
call transpose_y_to_z(tb2,tb3)
call transpose_y_to_z(tc2,tc3)
call transpose_y_to_z(td2,td3)
!WORK Z-PENCILS
call derz (te3,ux3,di3,sz,ffzp,fszp,fwzp,zsize(1),zsize(2),zsize(3),1)
call derz (tf3,uy3,di3,sz,ffzp,fszp,fwzp,zsize(1),zsize(2),zsize(3),1)
do ijk=1,nvect3
ta3(ijk,1,1)=uz3(ijk,1,1)*(te3(ijk,1,1)-tb3(ijk,1,1))-&
uy3(ijk,1,1)*(ta3(ijk,1,1)-tc3(ijk,1,1))
tb3(ijk,1,1)=ux3(ijk,1,1)*(ta3(ijk,1,1)-tc3(ijk,1,1))-&
uz3(ijk,1,1)*(td3(ijk,1,1)-tf3(ijk,1,1))
tc3(ijk,1,1)=uy3(ijk,1,1)*(td3(ijk,1,1)-tf3(ijk,1,1))-&
ux3(ijk,1,1)*(te3(ijk,1,1)-tb3(ijk,1,1))
enddo
else !SKEW!
!WORK X-PENCILS
td1(:,:,:) = rho1(:,:,:) * ux1(:,:,:) * ux1(:,:,:)
te1(:,:,:) = rho1(:,:,:) * uy1(:,:,:) * ux1(:,:,:)
tf1(:,:,:) = rho1(:,:,:) * uz1(:,:,:) * ux1(:,:,:)
call derx (tg1,td1,di1,sx,ffxp,fsxp,fwxp,xsize(1),xsize(2),xsize(3),1)
call derx (th1,te1,di1,sx,ffx,fsx,fwx,xsize(1),xsize(2),xsize(3),0)
call derx (ti1,tf1,di1,sx,ffx,fsx,fwx,xsize(1),xsize(2),xsize(3),0)
call derx (td1,ux1,di1,sx,ffx,fsx,fwx,xsize(1),xsize(2),xsize(3),0)
call derx (te1,uy1,di1,sx,ffxp,fsxp,fwxp,xsize(1),xsize(2),xsize(3),1)
call derx (tf1,uz1,di1,sx,ffxp,fsxp,fwxp,xsize(1),xsize(2),xsize(3),1)
ta1(:,:,:) = tg1(:,:,:) + rho1(:,:,:) * ux1(:,:,:) * td1(:,:,:)
tb1(:,:,:) = th1(:,:,:) + rho1(:,:,:) * ux1(:,:,:) * te1(:,:,:)
tc1(:,:,:) = ti1(:,:,:) + rho1(:,:,:) * ux1(:,:,:) * tf1(:,:,:)
if ((iskew.eq.1).and.(ilmn.ne.0)) then
! Quasi-skew symmetric terms
call derx(tg1,rho1,di1,sx,ffxp,fsxp,fwxp,xsize(1),xsize(2),xsize(3),1)
ta1(:,:,:) = ta1(:,:,:) + ux1(:,:,:) * ux1(:,:,:) * tg1(:,:,:)
tb1(:,:,:) = tb1(:,:,:) + uy1(:,:,:) * ux1(:,:,:) * tg1(:,:,:)
tc1(:,:,:) = tc1(:,:,:) + uz1(:,:,:) * ux1(:,:,:) * tg1(:,:,:)
endif
call transpose_x_to_y(ux1,ux2)
call transpose_x_to_y(uy1,uy2)
call transpose_x_to_y(uz1,uz2)
call transpose_x_to_y(ta1,ta2)
call transpose_x_to_y(tb1,tb2)
call transpose_x_to_y(tc1,tc2)
call transpose_x_to_y(rho1,rho2)
!WORK Y-PENCILS
td2(:,:,:) = rho2(:,:,:) * ux2(:,:,:) * uy2(:,:,:)
te2(:,:,:) = rho2(:,:,:) * uy2(:,:,:) * uy2(:,:,:)
tf2(:,:,:) = rho2(:,:,:) * uz2(:,:,:) * uy2(:,:,:)
call dery (tg2,td2,di2,sy,ffy,fsy,fwy,ppy,ysize(1),ysize(2),ysize(3),0)
call dery (th2,te2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
call dery (ti2,tf2,di2,sy,ffy,fsy,fwy,ppy,ysize(1),ysize(2),ysize(3),0)
call dery (td2,ux2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
call dery (te2,uy2,di2,sy,ffy,fsy,fwy,ppy,ysize(1),ysize(2),ysize(3),0)
call dery (tf2,uz2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
ta2(:,:,:) = ta2(:,:,:) + tg2(:,:,:) + rho2(:,:,:) * uy2(:,:,:) * td2(:,:,:)
tb2(:,:,:) = tb2(:,:,:) + th2(:,:,:) + rho2(:,:,:) * uy2(:,:,:) * te2(:,:,:)
tc2(:,:,:) = tc2(:,:,:) + ti2(:,:,:) + rho2(:,:,:) * uy2(:,:,:) * tf2(:,:,:)
if ((iskew.eq.1).and.(ilmn.ne.0)) then
! Quasi-skew symmetric terms
call dery(th2,rho2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
ta2(:,:,:) = ta2(:,:,:) + ux2(:,:,:) * uy2(:,:,:) * th2(:,:,:)
tb2(:,:,:) = tb2(:,:,:) + uy2(:,:,:) * uy2(:,:,:) * th2(:,:,:)
tc2(:,:,:) = tc2(:,:,:) + uz2(:,:,:) * uy2(:,:,:) * th2(:,:,:)
endif
call transpose_y_to_z(ux2,ux3)
call transpose_y_to_z(uy2,uy3)
call transpose_y_to_z(uz2,uz3)
call transpose_y_to_z(ta2,ta3)
call transpose_y_to_z(tb2,tb3)
call transpose_y_to_z(tc2,tc3)
call transpose_y_to_z(rho2,rho3)
!WORK Z-PENCILS
td3(:,:,:) = rho3(:,:,:) * ux3(:,:,:) * uz3(:,:,:)
te3(:,:,:) = rho3(:,:,:) * uy3(:,:,:) * uz3(:,:,:)
tf3(:,:,:) = rho3(:,:,:) * uz3(:,:,:) * uz3(:,:,:)
call derz (tg3,td3,di3,sz,ffz,fsz,fwz,zsize(1),zsize(2),zsize(3),0)
call derz (th3,te3,di3,sz,ffz,fsz,fwz,zsize(1),zsize(2),zsize(3),0)
call derz (ti3,tf3,di3,sz,ffzp,fszp,fwzp,zsize(1),zsize(2),zsize(3),1)
call derz (td3,ux3,di3,sz,ffzp,fszp,fwzp,zsize(1),zsize(2),zsize(3),1)
call derz (te3,uy3,di3,sz,ffzp,fszp,fwzp,zsize(1),zsize(2),zsize(3),1)
call derz (tf3,uz3,di3,sz,ffz,fsz,fwz,zsize(1),zsize(2),zsize(3),0)
ta3(:,:,:) = ta3(:,:,:) + tg3(:,:,:) + rho3(:,:,:) * uz3(:,:,:) * td3(:,:,:)
tb3(:,:,:) = tb3(:,:,:) + th3(:,:,:) + rho3(:,:,:) * uz3(:,:,:) * te3(:,:,:)
tc3(:,:,:) = tc3(:,:,:) + ti3(:,:,:) + rho3(:,:,:) * uz3(:,:,:) * tf3(:,:,:)
if ((iskew.eq.1).and.(ilmn.ne.0)) then
! Quasi-skew symmetric terms (Note here also include contribution from div(u))
call derz(ti3,rho3,di3,sz,ffzp,fszp,fwzp,zsize(1),zsize(2),zsize(3),1)
ta3(:,:,:) = ta3(:,:,:) + ux3(:,:,:) &
* (uz3(:,:,:) * ti3(:,:,:) + rho3(:,:,:) * divu3(:,:,:))
tb3(:,:,:) = tb3(:,:,:) + uy3(:,:,:) &
* (uz3(:,:,:) * ti3(:,:,:) + rho3(:,:,:) * divu3(:,:,:))
tc3(:,:,:) = tc3(:,:,:) + uz3(:,:,:) &
* (uz3(:,:,:) * ti3(:,:,:) + rho3(:,:,:) * divu3(:,:,:))
endif
!! Need to multiply by 1/2
ta3(:,:,:) = 0.5_mytype * ta3(:,:,:)
tb3(:,:,:) = 0.5_mytype * tb3(:,:,:)
tc3(:,:,:) = 0.5_mytype * tc3(:,:,:)
endif
!ALL THE CONVECTIVE TERMS ARE IN TA3, TB3 and TC3
tg3(:,:,:) = ta3(:,:,:)
th3(:,:,:) = tb3(:,:,:)
ti3(:,:,:) = tc3(:,:,:)
!DIFFUSIVE TERMS IN Z
call derzz (ta3,ux3,di3,sz,sfzp,sszp,swzp,zsize(1),zsize(2),zsize(3),1)
call derzz (tb3,uy3,di3,sz,sfzp,sszp,swzp,zsize(1),zsize(2),zsize(3),1)
call derzz (tc3,uz3,di3,sz,sfz ,ssz ,swz ,zsize(1),zsize(2),zsize(3),0)
ta3(:,:,:) = mu3(:,:,:) * ta3(:,:,:)
tb3(:,:,:) = mu3(:,:,:) * tb3(:,:,:)
tc3(:,:,:) = mu3(:,:,:) * tc3(:,:,:)
if (ilmn.ne.0) then
!! Compute bulk shear contribution
! tg3, th3, ti3 available as work vectors
! TODO need to check ffzp, and whether last terms should be 1 or 0
call derz(tf3, divu3, di3, sz, ffz, fsz, fwz, zsize(1), zsize(2), zsize(3), 0)
tc3(:,:,:) = tc3(:,:,:) - 2._mytype * ONETHIRD * mu3(:,:,:) * tf3(:,:,:)
endif
!! XXX Transpose advection terms to make room for 2nd non-conservative diffusion
! term
call transpose_z_to_y(tg3,tg2)
call transpose_z_to_y(th3,th2)
call transpose_z_to_y(ti3,ti2)
if (iprops.ne.0) then
!! Fluid properties are variable
call derz(td3, ux3, di3, sz, ffzp, fszp, fwzp, zsize(1), zsize(2), zsize(3), 1)
call derz(te3, uy3, di3, sz, ffzp, fszp, fwzp, zsize(1), zsize(2), zsize(3), 1)
call derz(tf3, uz3, di3, sz, ffz, fsz, fwz, zsize(1), zsize(2), zsize(3), 0)
call derz(ti3, mu3, di3, sz, ffzp, fszp, fwzp, zsize(1), zsize(2), zsize(3), 1)
ta3(:,:,:) = ta3(:,:,:) + ti3(:,:,:) * td3(:,:,:)
tb3(:,:,:) = tb3(:,:,:) + ti3(:,:,:) * te3(:,:,:)
tc3(:,:,:) = tc3(:,:,:) + ti3(:,:,:) * tf3(:,:,:) &
- ti3(:,:,:) * 2._mytype * ONETHIRD * divu3(:,:,:)
endif
clx3(:,:,:) = 0._mytype
cly3(:,:,:) = 0._mytype
clz3(:,:,:) = 0._mytype
IF (entrain_y.EQV..TRUE.) THEN
!! Apply y-normal BCs (in Z pencil)
CALL entrainment_bcy(ux3, uy3, uz3, clx3, cly3, clz3)
ENDIF
call transpose_z_to_y(ta3,ta2)
call transpose_z_to_y(tb3,tb2)
call transpose_z_to_y(tc3,tc2)
call transpose_z_to_y(divu3, divu2)
if (iprops.eq.0) then
mu2(:,:,:) = 1._mytype
endif
!WORK Y-PENCILS
IF ((entrain_y.EQV..TRUE.).OR.(entrain_z.EQV..TRUE.)) THEN
CALL transpose_z_to_y(clx3, clx2)
CALL transpose_z_to_y(cly3, cly2)
CALL transpose_z_to_y(clz3, clz2)
ENDIF
!DIFFUSIVE TERMS IN Y
!-->for ux
if (istret.ne.0) then
call deryy (td2,ux2,di2,sy,sfyp,ssyp,swyp,ysize(1),ysize(2),ysize(3),1)
call dery (te2,ux2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
do k=1,ysize(3)
do j=1,ysize(2)
do i=1,ysize(1)
td2(i,j,k)=td2(i,j,k)*pp2y(j)-pp4y(j)*te2(i,j,k)
enddo
enddo
enddo
else
call deryy (td2,ux2,di2,sy,sfyp,ssyp,swyp,ysize(1),ysize(2),ysize(3),1)
endif
!-->for uy
if (istret.ne.0) then
call deryy (te2,uy2,di2,sy,sfy,ssy,swy,ysize(1),ysize(2),ysize(3),0)
call dery (tf2,uy2,di2,sy,ffy,fsy,fwy,ppy,ysize(1),ysize(2),ysize(3),0)
do k=1,ysize(3)
do j=1,ysize(2)
do i=1,ysize(1)
te2(i,j,k)=te2(i,j,k)*pp2y(j)-pp4y(j)*tf2(i,j,k)
enddo
enddo
enddo
else
call deryy (te2,uy2,di2,sy,sfy,ssy,swy,ysize(1),ysize(2),ysize(3),0)
endif
!-->for uz
if (istret.ne.0) then
call deryy (tf2,uz2,di2,sy,sfyp,ssyp,swyp,ysize(1),ysize(2),ysize(3),1)
call dery (tj2,uz2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
do k=1,ysize(3)
do j=1,ysize(2)
do i=1,ysize(1)
tf2(i,j,k)=tf2(i,j,k)*pp2y(j)-pp4y(j)*tj2(i,j,k)
enddo
enddo
enddo
else
call deryy (tf2,uz2,di2,sy,sfyp,ssyp,swyp,ysize(1),ysize(2),ysize(3),1)
endif
ta2(:,:,:) = ta2(:,:,:) + mu2(:,:,:) * td2(:,:,:)
tb2(:,:,:) = tb2(:,:,:) + mu2(:,:,:) * te2(:,:,:)
tc2(:,:,:) = tc2(:,:,:) + mu2(:,:,:) * tf2(:,:,:)
if (ilmn.ne.0) then
!! Compute bulk shear contribution
! td2, te2, tf2 avaiable as work vectors
call dery(te2, divu2, di2, sy, ffy, fsy, fwy, ppy, ysize(1), ysize(2), ysize(3), 0)
tb2(:,:,:) = tb2(:,:,:) - 2._mytype * ONETHIRD * mu2(:,:,:) * te2(:,:,:)
endif
IF (entrain_z.EQV..TRUE.) THEN
!! Apply Z-normal BCs
CALL entrainment_bcz(ux2, uy2, uz2, clx2, cly2, clz2)
ENDIF
!! XXX First move advection terms to make room to work
call transpose_y_to_x(tg2,tg1)
call transpose_y_to_x(th2,th1)
call transpose_y_to_x(ti2,ti1) !conv
if (iprops.ne.0) then
!! Compute non-conservative part of viscous stress tensor
call dery (td2,ux2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
call dery (te2,uy2,di2,sy,ffy,fsy,fwy,ppy,ysize(1),ysize(2),ysize(3),0)
call dery (tf2,uz2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
call dery (th2,mu2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
ta2(:,:,:) = ta2(:,:,:) + th2(:,:,:) * td2(:,:,:)
tb2(:,:,:) = tb2(:,:,:) + th2(:,:,:) * te2(:,:,:) &
- th2(:,:,:) * 2._mytype * ONETHIRD * divu2(:,:,:)
tc2(:,:,:) = tc2(:,:,:) + th2(:,:,:) * tf2(:,:,:)
endif
!WORK X-PENCILS
call transpose_y_to_x(ta2,ta1)
call transpose_y_to_x(tb2,tb1)
call transpose_y_to_x(tc2,tc1) !diff
call transpose_y_to_x(divu2, divu1)
if (iprops.eq.0) then
mu1(:,:,:) = 1._mytype
endif
!WORK X-PENCILS
IF ((entrain_y.EQV..TRUE.).OR.(entrain_z.EQV..TRUE.)) THEN
CALL transpose_y_to_x(clx2, clx1)
CALL transpose_y_to_x(cly2, cly1)
CALL transpose_y_to_x(clz2, clz1)
ENDIF
!DIFFUSIVE TERMS IN X
call derxx (td1,ux1,di1,sx,sfx ,ssx ,swx ,xsize(1),xsize(2),xsize(3),0)
call derxx (te1,uy1,di1,sx,sfxp,ssxp,swxp,xsize(1),xsize(2),xsize(3),1)
call derxx (tf1,uz1,di1,sx,sfxp,ssxp,swxp,xsize(1),xsize(2),xsize(3),1)
ta1(:,:,:) = ta1(:,:,:) + mu1(:,:,:) * td1(:,:,:)
tb1(:,:,:) = tb1(:,:,:) + mu1(:,:,:) * te1(:,:,:)
tc1(:,:,:) = tc1(:,:,:) + mu1(:,:,:) * tf1(:,:,:)
if (ilmn.ne.0) then
!! Compute bulk shear contribution
! td1, te1, tf1 available as work vectors
! TODO need to check ffzp, and whether last terms should be 1 or 0
call derx(td1, divu1, di1, sx, ffx, fsx, fwx, xsize(1), xsize(2), xsize(3), 0)
ta1(:,:,:) = ta1(:,:,:) - 2._mytype * ONETHIRD * mu1(:,:,:) * td1(:,:,:)
endif
!INTERMEDIATE SUM: DIFF TERMS + CONV TERMS
ta1(:,:,:) = xnu * ta1(:,:,:) - tg1(:,:,:)
tb1(:,:,:) = xnu * tb1(:,:,:) - th1(:,:,:)
tc1(:,:,:) = xnu * tc1(:,:,:) - ti1(:,:,:)
!! We now have room to do the non-conservative part of viscous stress tensor
if (iprops.ne.0) then
call derx (td1,ux1,di1,sx,ffx,fsx,fwx,xsize(1),xsize(2),xsize(3),0)
call derx (te1,uy1,di1,sx,ffxp,fsxp,fwxp,xsize(1),xsize(2),xsize(3),1)
call derx (tf1,uz1,di1,sx,ffxp,fsxp,fwxp,xsize(1),xsize(2),xsize(3),1)
call derx (tg1,mu1,di1,sx,ffxp,fsxp,fwxp,xsize(1),xsize(2),xsize(3),1)
ta1(:,:,:) = ta1(:,:,:) + xnu * (tg1(:,:,:) * td1(:,:,:) &
- tg1(:,:,:) * 2._mytype * ONETHIRD * divu1(:,:,:))
tb1(:,:,:) = tb1(:,:,:) + xnu * tg1(:,:,:) * te1(:,:,:)
tc1(:,:,:) = tc1(:,:,:) + xnu * tg1(:,:,:) * tf1(:,:,:)
endif
if (ilmn.ne.0) then
!! Compute cross-shear
! NB ta1,tb1,tc1 cannot be touched!
! NB u2,u3 have already been updated, no need to transpose velocities!
! X - accumulate d(v,w)dx terms
call derx(te1, uy1, di1, sx, ffxp, fsxp, fwxp, xsize(1), xsize(2), xsize(3), 1)
call derx(tf1, uz1, di1, sx, ffxp, fsxp, fwxp, xsize(1), xsize(2), xsize(3), 1)
call transpose_x_to_y(te1, te2) ! te2 contains dvdx
call transpose_x_to_y(tf1, tf2) ! tf2 contains dwdx
! Y - accumulate dwdy terms
call dery(ti2, uz2, di2, sy, ffyp, fsyp, fwyp, ppy, ysize(1), ysize(2), ysize(3), 1)
call transpose_y_to_z(tf2, tg3) ! tg3 contains dwdx
call transpose_y_to_z(ti2, th3) ! th3 contains dwdy
! Z - accumulate ddz terms
call derz(ta3, ux3, di3, sz, ffzp, fszp, fwzp, zsize(1), zsize(2), zsize(3), 1)
call derz(tb3, uy3, di3, sz, ffzp, fszp, fwzp, zsize(1), zsize(2), zsize(3), 1)
call derz(tc3, uz3, di3, sz, ffz, fsz, fwz, zsize(1), zsize(2), zsize(3), 0)
! Z - compute ddz(dwdx, dwdy, dwdz)
call derz(td3, tg3, di3, sz, ffz, fsz, fwz, zsize(1), zsize(2), zsize(3), 0)
call derz(te3, th3, di3, sz, ffz, fsz, fwz, zsize(1), zsize(2), zsize(3), 0)
call derz(tf3, tc3, di3, sz, ffzp, fszp, fwzp, zsize(1), zsize(2), zsize(3), 1)
td3(:,:,:) = mu3(:,:,:) * td3(:,:,:)
te3(:,:,:) = mu3(:,:,:) * te3(:,:,:)
tf3(:,:,:) = mu3(:,:,:) * tf3(:,:,:)
if (iprops.ne.0) then
!! Store dmudz in ti3
call derz(ti3, mu3, di3, sz, ffzp, fszp, fwzp, zsize(1), zsize(2), zsize(3), 1)
! Add dmudz * \nabla w to cross-shear
td3(:,:,:) = td3(:,:,:) + ti3(:,:,:) * tg3(:,:,:)
te3(:,:,:) = te3(:,:,:) + ti3(:,:,:) * th3(:,:,:)
tf3(:,:,:) = tf3(:,:,:) + ti3(:,:,:) * tc3(:,:,:)
endif
call transpose_z_to_y(td3, tg2) ! tg2 contains mu * d2wdzdx + dmudz * dwdx
call transpose_z_to_y(te3, th2) ! th2 contains mu * d2wdzdy + dmudz * dwdy
call transpose_z_to_y(tf3, ti2) ! ti2 contains mu * d2wdzdz + dmudz * dwdz
call transpose_z_to_y(ta3, ta2) ! ta2 contains dudz
call transpose_z_to_y(tb3, tb2) ! tb2 contains dvdz
! Y - compute ddy(dvdx, dvdy, dvdz)
tj2(:,:,:) = te2(:,:,:) ! Store dvdx
call dery(td2, te2, di2, sy, ffy, fsy, fwy, ppy, ysize(1), ysize(2), ysize(3), 0)
call dery(tc2, uy2, di2, sy, ffy, fsy, fwy, ppy, ysize(1), ysize(2), ysize(3), 0)
call dery(te2, tc2, di2, sy, ffyp, fsyp, fwyp, ppy, ysize(1), ysize(2), ysize(3), 1)
call dery(tf2, tb2, di2, sy, ffy, fsy, fwy, ppy, ysize(1), ysize(2), ysize(3), 0)
td2(:,:,:) = mu2(:,:,:) * td2(:,:,:)
te2(:,:,:) = mu2(:,:,:) * te2(:,:,:)
tf2(:,:,:) = mu2(:,:,:) * tf2(:,:,:)
td2(:,:,:) = td2(:,:,:) + tg2(:,:,:) ! td2 contains mu * (d2vdydx + d2wdzdx) + dmudz * dwdx
te2(:,:,:) = te2(:,:,:) + th2(:,:,:) ! te2 contains mu * (d2vdydy + d2wdzdy) + dmudz * dwdy
tf2(:,:,:) = tf2(:,:,:) + ti2(:,:,:) ! tf2 contains mu * (d2vdydz + d2wdzdz) + dmudz * dwdz
if (iprops.ne.0) then
!! Store dmudy in th2
call dery(th2, mu2, di2, sy, ffyp, fsyp, fwyp, ppy, ysize(1), ysize(2), ysize(3), 1)
! Add dmudy * \nabla v to cross-shear
td2(:,:,:) = td2(:,:,:) + th2(:,:,:) * tj2(:,:,:)
te2(:,:,:) = te2(:,:,:) + th2(:,:,:) * tc2(:,:,:)
tf2(:,:,:) = tf2(:,:,:) + th2(:,:,:) * tb2(:,:,:)
endif
call transpose_y_to_x(td2, td1) ! td1 contains mu * (d2vdydx + d2wdzdx) + (dmudy * dvdx + dmudz * dwdx)
call transpose_y_to_x(te2, te1) ! te1 contains mu * (d2vdydy + d2wdzdy) + (dmudy * dvdy + dmudz * dwdy)
call transpose_y_to_x(tf2, tf1) ! tf1 contains mu * (d2vdydz + d2wdzdz) + (dmudy * dvdz + dmudz * dwdz)
call dery(tc2, ux2, di2, sy, ffyp, fsyp, fwyp, ppy, ysize(1), ysize(2), ysize(3), 1)
call transpose_y_to_x(tc2, th1) ! th1 contains dudy
call transpose_y_to_x(ta2, ti1) ! ti1 contains dudz
! X - compute ddx(dudx, dudy, dudz)
! First make some room to work!
ta1(:,:,:) = ta1(:,:,:) + xnu * td1(:,:,:)
tb1(:,:,:) = tb1(:,:,:) + xnu * te1(:,:,:)
tc1(:,:,:) = tc1(:,:,:) + xnu * tf1(:,:,:)
call derx(tg1, ux1, di1, sx, ffx, fsx, fwx, xsize(1), xsize(2), xsize(3), 0)
call derx(td1, tg1, di1, sx, ffxp, fsxp, fwxp, xsize(1), xsize(2), xsize(3), 1)
call derx(te1, th1, di1, sx, ffx, fsx, fwx, xsize(1), xsize(2), xsize(3), 0)
call derx(tf1, ti1, di1, sx, ffx, fsx, fwx, xsize(1), xsize(2), xsize(3), 0)
!! Finish off adding cross-stresses to shear stress
ta1(:,:,:) = ta1(:,:,:) + xnu * mu1(:,:,:) * td1(:,:,:)
tb1(:,:,:) = tb1(:,:,:) + xnu * mu1(:,:,:) * te1(:,:,:)
tc1(:,:,:) = tc1(:,:,:) + xnu * mu1(:,:,:) * tf1(:,:,:)
if (iprops.ne.0) then
!! Add dmudx * \nabla u to cross-shear
call derx(td1, mu1, di1, sx, ffxp, fsxp, fwxp, xsize(1), xsize(2), xsize(3), 1)
ta1(:,:,:) = ta1(:,:,:) + xnu * td1(:,:,:) * tg1(:,:,:)
tb1(:,:,:) = tb1(:,:,:) + xnu * td1(:,:,:) * th1(:,:,:)
tc1(:,:,:) = tc1(:,:,:) + xnu * td1(:,:,:) * ti1(:,:,:)
endif
endif
! CALL fringe_bcx(ta1, tb1, tc1, ux1, uy1, uz1, rho1)
!! Setting entrainment boundary conditions
IF (entrain_z.EQV..TRUE.) THEN
CALL set_velocity_entrainment_z(clx1, cly1, clz1)
ENDIF !! End Z BC
IF (entrain_y.EQV..TRUE.) THEN
CALL set_velocity_entrainment_y(clx1, cly1, clz1)
ENDIF !! End Y BC
! !! MMS Source term
! call momentum_source_mms(ta1,tb1,tc1)
end subroutine convdiff
!************************************************************
!
!
!************************************************************
subroutine scalar(ux1,uy1,uz1,rho1,phi1,gamma1,phis1,phiss1,di1,ta1,tb1,tc1,td1,&
uy2,uz2,rho2,phi2,gamma2,di2,ta2,tb2,tc2,td2,&
uz3,rho3,phi3,gamma3,di3,ta3,tb3,tc3,epsi)
USE param
USE variables
USE decomp_2d
implicit none
real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: ux1,uy1,uz1,rho1,phi1,gamma1,phis1,&
phiss1,di1,ta1,tb1,tc1,td1,epsi
real(mytype),dimension(ysize(1),ysize(2),ysize(3)) :: uy2,uz2,rho2,phi2,gamma2,di2,ta2,tb2,tc2,td2
real(mytype),dimension(zsize(1),zsize(2),zsize(3)) :: uz3,rho3,phi3,gamma3,di3,ta3,tb3,tc3
integer :: ijk,nvect1,nvect2,nvect3,i,j,k,nxyz
real(mytype) :: x,y,z
nvect1=xsize(1)*xsize(2)*xsize(3)
nvect2=ysize(1)*ysize(2)*ysize(3)
nvect3=zsize(1)*zsize(2)*zsize(3)
!X PENCILS
do ijk=1,nvect1
ta1(ijk,1,1)=rho1(ijk,1,1)*phi1(ijk,1,1)*ux1(ijk,1,1)
enddo
call derx (tb1,ta1,di1,sx,ffx,fsx,fwx,xsize(1),xsize(2),xsize(3),0)
if (iprops.eq.0) then
call derxx (ta1,phi1,di1,sx,sfxp,ssxp,swxp,xsize(1),xsize(2),xsize(3),1)
else
call derx (ta1,phi1,di1,sx,ffxp,fsxp,fwxp,xsize(1),xsize(2),xsize(3),1)
tc1(:,:,:) = gamma1(:,:,:) * ta1(:,:,:)
call derx (ta1,tc1,di1,sx,ffx,fsx,fwx,xsize(1),xsize(2),xsize(3),0)
call transpose_x_to_y(gamma1, gamma2)
endif
call transpose_x_to_y(phi1,phi2)
call transpose_x_to_y(uy1,uy2)
call transpose_x_to_y(uz1,uz2)
call transpose_x_to_y(rho1,rho2)
!Y PENCILS
do ijk=1,nvect2
ta2(ijk,1,1)=rho2(ijk,1,1)*phi2(ijk,1,1)*uy2(ijk,1,1)
enddo
call dery (tb2,ta2,di2,sy,ffy,fsy,fwy,ppy,ysize(1),ysize(2),ysize(3),0)
if (iprops.eq.0) then
if (istret.ne.0) then
call deryy (ta2,phi2,di2,sy,sfyp,ssyp,swyp,ysize(1),ysize(2),ysize(3),1)
call dery (tc2,phi2,di2,sy,ffy,fsy,fwy,ppy,ysize(1),ysize(2),ysize(3),0)
do k=1,ysize(3)
do j=1,ysize(2)
do i=1,ysize(1)
ta2(i,j,k)=ta2(i,j,k)*pp2y(j)-pp4y(j)*tc2(i,j,k)
enddo
enddo
enddo
else
call deryy (ta2,phi2,di2,sy,sfyp,ssyp,swyp,ysize(1),ysize(2),ysize(3),1)
endif
else
call dery (ta2,phi2,di2,sy,ffyp,fsyp,fwyp,ppy,ysize(1),ysize(2),ysize(3),1)
tc2(:,:,:) = gamma2(:,:,:) * ta2(:,:,:)
call dery (ta2,tc2,di2,sy,ffy,fsy,fwy,ppy,ysize(1),ysize(2),ysize(3),0)
call transpose_y_to_z(gamma2, gamma3)
endif
call transpose_y_to_z(phi2,phi3)
call transpose_y_to_z(uz2,uz3)
call transpose_y_to_z(rho2,rho3)
!Z PENCILS
do ijk=1,nvect3
ta3(ijk,1,1)=rho3(ijk,1,1)*phi3(ijk,1,1)*uz3(ijk,1,1)
enddo
call derz (tb3,ta3,di3,sz,ffz,fsz,fwz,zsize(1),zsize(2),zsize(3),0)
if (iprops.eq.0) then
call derzz (ta3,phi3,di3,sz,sfzp,sszp,swzp,zsize(1),zsize(2),zsize(3),1)
else
call derz (ta3,phi3,di3,sz,ffzp,fszp,fwzp,zsize(1),zsize(2),zsize(3),1)
tc3(:,:,:) = gamma3(:,:,:) * ta3(:,:,:)
call derz (ta3,tc3,di3,sz,ffz,fsz,fwz,zsize(1),zsize(2),zsize(3),0)
endif
call transpose_z_to_y(ta3,tc2)
call transpose_z_to_y(tb3,td2)
!Y PENCILS ADD TERMS
do ijk=1,nvect2
tc2(ijk,1,1)=tc2(ijk,1,1)+ta2(ijk,1,1)
td2(ijk,1,1)=td2(ijk,1,1)+tb2(ijk,1,1)
enddo
call transpose_y_to_x(tc2,tc1)
call transpose_y_to_x(td2,td1)
!X PENCILS ADD TERMS
do ijk=1,nvect1
ta1(ijk,1,1)=ta1(ijk,1,1)+tc1(ijk,1,1) !SECOND DERIVATIVE
tb1(ijk,1,1)=tb1(ijk,1,1)+td1(ijk,1,1) !FIRST DERIVATIVE
enddo
do ijk=1,nvect1
ta1(ijk,1,1)=xnu/sc*ta1(ijk,1,1)-tb1(ijk,1,1)
enddo
if (ilmn.ne.0) then
phi1(:,:,:) = rho1(:,:,:)*phi1(:,:,:)
endif
!TIME ADVANCEMENT
nxyz=xsize(1)*xsize(2)*xsize(3)
if ((nscheme.eq.1).or.(nscheme.eq.2)) then
if ((nscheme.eq.1.and.itime.eq.1.and.ilit.eq.0).or.&
(nscheme.eq.2.and.itr.eq.1)) then
do ijk=1,nxyz
phi1(ijk,1,1)=gdt(itr)*ta1(ijk,1,1)+phi1(ijk,1,1)
phis1(ijk,1,1)=ta1(ijk,1,1)
enddo
else
do ijk=1,nxyz
phi1(ijk,1,1)=adt(itr)*ta1(ijk,1,1)+bdt(itr)*phis1(ijk,1,1)+phi1(ijk,1,1)
phis1(ijk,1,1)=ta1(ijk,1,1)
enddo
endif
endif
if (nscheme.eq.3) then
if (nrank==0) print *,'Not ready'
stop
endif
if (nscheme==4) then
if ((itime.eq.1).and.(ilit.eq.0)) then
if (nrank==0) print *,'start with Euler',itime
do ijk=1,nxyz !start with Euler
phi1(ijk,1,1)=dt*ta1(ijk,1,1)+phi1(ijk,1,1)
phis1(ijk,1,1)=ta1(ijk,1,1)
enddo
else
if ((itime.eq.2).and.(ilit.eq.0)) then
if (nrank==0) print *,'then with AB2',itime
do ijk=1,nxyz
phi1(ijk,1,1)=1.5_mytype*dt*ta1(ijk,1,1)-0.5_mytype*dt*phis1(ijk,1,1)+phi1(ijk,1,1)
phiss1(ijk,1,1)=phis1(ijk,1,1)
phis1(ijk,1,1)=ta1(ijk,1,1)
enddo
else
do ijk=1,nxyz
phi1(ijk,1,1)=adt(itr)*ta1(ijk,1,1)+bdt(itr)*phis1(ijk,1,1)+&
cdt(itr)*phiss1(ijk,1,1)+phi1(ijk,1,1)
phiss1(ijk,1,1)=phis1(ijk,1,1)
phis1(ijk,1,1)=ta1(ijk,1,1)
enddo
endif
endif
endif
end subroutine scalar
!!--------------------------------------------------------------------
!! Subroutine: conv_density
!!
!! Description: Advances density in time for LMN.
!!
!! Notes: The "diffusion" term in the continuity equation is
!! given as:
!!
!! (1 / (Re Pr T)) div(kappa grad(T))
!!
!! however, we have p = rho T and grad(p) = 0, where p is
!! the thermodynamic pressure in the LMN approximation.
!! Therefore can make the substitution T = p / rho giving
!!
!! (1 / (Re Pr (p / rho))) div(kappa grad(p / rho))
!! => (rho / (Re Pr)) div(kappa grad(1 / rho))
!!
!! making use of grad(p) = 0. This saves
!! memory/communication as would need to compute, store
!! and transpose temperature array when we do this with
!! density anyway.
!!--------------------------------------------------------------------
SUBROUTINE conv_density(ux1, uy1, uz1, rho1, di1, ta1, tb1, tc1, td1,&
uy2, uz2, rho2, di2, ta2, tb2, tc2, td2, &
uz3, rho3, divu3, di3, ta3, tb3, &
epsi)
USE param
USE variables
USE decomp_2d
IMPLICIT NONE
REAL(mytype), DIMENSION(xsize(1), xsize(2), xsize(3)) :: ux1, uy1, uz1
REAL(mytype), DIMENSION(xsize(1), xsize(2), xsize(3)) :: rho1
REAL(mytype), DIMENSION(xsize(1), xsize(2), xsize(3)) :: di1, ta1, tb1, tc1, td1, epsi
REAL(mytype), DIMENSION(ysize(1), ysize(2), ysize(3)) :: uy2, uz2
REAL(mytype), DIMENSION(ysize(1), ysize(2), ysize(3)) :: rho2
REAL(mytype), DIMENSION(ysize(1), ysize(2), ysize(3)) :: di2, ta2, tb2, tc2, td2
REAL(mytype), DIMENSION(zsize(1), zsize(2), zsize(3)) :: uz3
REAL(mytype), DIMENSION(zsize(1), zsize(2), zsize(3)) :: rho3
REAL(mytype), DIMENSION(zsize(1), zsize(2), zsize(3)) :: divu3
REAL(mytype), DIMENSION(zsize(1), zsize(2), zsize(3)) :: di3, ta3, tb3
REAL(mytype) :: invpe
INTEGER :: ijk, nvect1, nvect2, nvect3
nvect1 = xsize(1) * xsize(2) * xsize(3)
nvect2 = ysize(1) * ysize(2) * ysize(3)
nvect3 = zsize(1) * zsize(2) * zsize(3)
invpe = xnu / sc
!------------------------------------------------------------------------
! X PENCILS
! tb1 = diffusion
! ta1 = advection
! Advection term (non-conservative)
CALL derx (ta1, rho1, di1, sx, ffxp, fsxp, fwxp, xsize(1), xsize(2), xsize(3), 1)
ta1(:,:,:) = ux1(:,:,:) * ta1(:,:,:)
! Go to Y
CALL transpose_x_to_y(rho1, rho2)
CALL transpose_x_to_y(uy1, uy2)
CALL transpose_x_to_y(uz1, uz2)
!------------------------------------------------------------------------
!Y PENCILS
! tb2 = diffusion
! ta2 = advection
! Advection term (non-conservative)
CALL dery (ta2, rho2, di2, sy, ffyp, fsyp, fwyp, ppy, ysize(1), ysize(2), ysize(3), 1)
ta2(:,:,:) = uy2(:,:,:) * ta2(:,:,:)
! Go to Z
CALL transpose_y_to_z(rho2, rho3)
CALL transpose_y_to_z(uz2, uz3)
!------------------------------------------------------------------------
! Z PENCILS
! tb3 = diffusion
! ta3 = advection
! Advection term (non-conservative)
! XXX Also adds contribution from divu3
CALL derz (ta3, rho3, di3, sz, ffzp, fszp, fwzp, zsize(1), zsize(2), zsize(3), 1)
ta3(:,:,:) = uz3(:,:,:) * ta3(:,:,:) + rho3(:,:,:) * divu3(:,:,:)
! call derzz (tb3,rho3,di3,sz,sfzp,sszp,swzp,zsize(1),zsize(2),zsize(3),1)
! ta3(:,:,:) = ta3(:,:,:) - invpe * tb3(:,:,:)
! Get back to Y
CALL transpose_z_to_y(ta3, td2)
!------------------------------------------------------------------------
!Y PENCILS ADD TERMS
td2(:,:,:) = td2(:,:,:) + ta2(:,:,:)
! call deryy (tb2,rho2,di2,sy,sfyp,ssyp,swyp,ysize(1),ysize(2),ysize(3),1)
! td2(:,:,:) = td2(:,:,:) - invpe * tb2(:,:,:)
! Get back to X
CALL transpose_y_to_x(td2, td1)
!------------------------------------------------------------------------
! X PENCILS ADD TERMS and set negative (ddt rho = -div(rho u))
ta1(:,:,:) = -(ta1(:,:,:) + td1(:,:,:)) !FIRST DERIVATIVE (CONV)
! call derxx (tb1,rho1,di1,sx,sfxp,ssxp,swxp,xsize(1),xsize(2),xsize(3),1)
! ta1(:,:,:) = ta1(:,:,:) + invpe * tb1(:,:,:)
! !! MMS Source term
! CALL density_source_mms(ta1)
ENDSUBROUTINE conv_density
!!--------------------------------------------------------------------
!!--------------------------------------------------------------------
SUBROUTINE convdiff_temperature(ux1, uy1, uz1, rho1, temperature1, di1, ta1, tb1,&
uy2, uz2, rho2, temperature2, di2, ta2, tb2,&
uz3, rho3, temperature3, di3, ta3, tb3)
USE param
USE variables
USE decomp_2d
IMPLICIT NONE
REAL(mytype), DIMENSION(xsize(1), xsize(2), xsize(3)) :: ux1, uy1, uz1
REAL(mytype), DIMENSION(xsize(1), xsize(2), xsize(3)) :: temperature1, rho1
REAL(mytype), DIMENSION(xsize(1), xsize(2), xsize(3)) :: di1, ta1, tb1
REAL(mytype), DIMENSION(ysize(1), ysize(2), ysize(3)) :: uy2, uz2
REAL(mytype), DIMENSION(ysize(1), ysize(2), ysize(3)) :: temperature2, rho2
REAL(mytype), DIMENSION(ysize(1), ysize(2), ysize(3)) :: di2, ta2, tb2
REAL(mytype), DIMENSION(zsize(1), zsize(2), zsize(3)) :: uz3
REAL(mytype), DIMENSION(zsize(1), zsize(2), zsize(3)) :: temperature3, rho3
REAL(mytype), DIMENSION(zsize(1), zsize(2), zsize(3)) :: di3, ta3, tb3
REAL(mytype) :: invpr
invpr = 1._mytype / pr
!!----------------------------------------------------------------
! Accumulate advection
!----------------------------------------
! X-pencils
CALL derx (tb1, temperature1, di1, sx, ffxp, fsxp, fwxp, xsize(1), xsize(2), xsize(3), 1)
tb1(:,:,:) = ux1(:,:,:) * tb1(:,:,:)
! Go to Y
CALL transpose_x_to_y(temperature1, temperature2)
CALL transpose_x_to_y(uy1, uy2)
CALL transpose_x_to_y(uz1, uz2)
CALL transpose_x_to_y(rho1, rho2)
!----------------------------------------
!Y PENCILS
CALL dery (tb2, temperature2, di2, sy, ffyp, fsyp, fwyp, ppy, ysize(1), ysize(2), ysize(3), 1)
tb2(:,:,:) = uy2(:,:,:) * tb2(:,:,:)
! Go to Z
CALL transpose_y_to_z(temperature2, temperature3)
CALL transpose_y_to_z(uz2, uz3)
CALL transpose_y_to_z(rho2, rho3)
!----------------------------------------
! Z PENCILS
CALL derz (tb3, temperature3, di3, sz, ffzp, fszp, fwzp, zsize(1), zsize(2), zsize(3), 1)
tb3(:,:,:) = uz3(:,:,:) * tb3(:,:,:)
!!----------------------------------------------------------------
! Add diffusion and get back to X
! XXX The diffusion term is equivalent to T div(u)
call derzz (tb3,temperature3,di3,sz,sfzp,sszp,swzp,zsize(1),zsize(2),zsize(3),1)
ta3(:,:,:) = (xnu * invpr / rho3(:,:,:)) * ta3(:,:,:) - tb3(:,:,:)
CALL transpose_z_to_y(ta3, ta2)
ta2(:,:,:) = ta2(:,:,:) - tb2(:,:,:)
call deryy (tb2,temperature2,di2,sy,sfyp,ssyp,swyp,ysize(1),ysize(2),ysize(3),1)
ta2(:,:,:) = ta2(:,:,:) + (xnu * invpr / rho2(:,:,:)) * tb2(:,:,:)
CALL transpose_y_to_x(ta2, ta1)
ta1(:,:,:) = ta1(:,:,:) - tb1(:,:,:)
call derxx (tb1,temperature1,di1,sx,sfxp,ssxp,swxp,xsize(1),xsize(2),xsize(3),1)
ta1(:,:,:) = ta1(:,:,:) + (xnu * invpr / rho1(:,:,:)) * tb1(:,:,:)
ENDSUBROUTINE convdiff_temperature
SUBROUTINE convdiff_massfrac(ux1, uy1, uz1, rho1, massfrac1, massfracs1, massfracss1, ta1, tb1, tc1, di1, &
uy2, uz2, rho2, massfrac2, ta2, tb2, tc2, di2, &
uz3, rho3, massfrac3, ta3, tb3, tc3, di3)
USE param
USE variables
USE decomp_2d
IMPLICIT NONE
REAL(mytype), DIMENSION(xsize(1), xsize(2), xsize(3)) :: ux1, uy1, uz1, rho1
REAL(mytype), DIMENSION(xsize(1), xsize(2), xsize(3)) :: massfrac1, massfracs1, massfracss1
REAL(mytype), DIMENSION(xsize(1), xsize(2), xsize(3)) :: di1, ta1, tb1, tc1
REAL(mytype), DIMENSION(ysize(1), ysize(2), ysize(3)) :: uy2, uz2, rho2
REAL(mytype), DIMENSION(ysize(1), ysize(2), ysize(3)) :: massfrac2
REAL(mytype), DIMENSION(ysize(1), ysize(2), ysize(3)) :: di2, ta2, tb2, tc2
REAL(mytype), DIMENSION(zsize(1), zsize(2), zsize(3)) :: uz3, rho3
REAL(mytype), DIMENSION(zsize(1), zsize(2), zsize(3)) :: massfrac3
REAL(mytype), DIMENSION(zsize(1), zsize(2), zsize(3)) :: di3, ta3, tb3, tc3
INTEGER :: ijk, nxyz
REAL(mytype) :: invsc
invsc = 1._mytype / sc
nxyz = xsize(1) * xsize(2) * xsize(3)
!!----------------------------------------------------------------
! Accumulate diffusion - advection
!----------------------------------------
! X-pencils
CALL derx (ta1, massfrac1, di1, sx, ffxp, fsxp, fwxp, xsize(1), xsize(2), xsize(3), 1)
tb1(:,:,:) = rho1(:,:,:) * ta1(:,:,:)
call derx (tc1,tb1,di1,sx,ffx,fsx,fwx,xsize(1),xsize(2),xsize(3),0)
ta1(:,:,:) = (xnu * invsc / rho1(:,:,:)) * tc1(:,:,:) - ux1(:,:,:) * ta1(:,:,:)
! Go to Y
CALL transpose_x_to_y(massfrac1, massfrac2)
CALL transpose_x_to_y(uy1, uy2)
CALL transpose_x_to_y(uz1, uz2)
CALL transpose_x_to_y(rho1, rho2)
!----------------------------------------
!Y PENCILS
CALL dery (ta2, massfrac2, di2, sy, ffyp, fsyp, fwyp, ppy, ysize(1), ysize(2), ysize(3), 1)
tb2(:,:,:) = rho2(:,:,:) * ta2(:,:,:)
CALL dery (tc2, tb2, di2, sy, ffy, fsy, fwy, ppy, ysize(1), ysize(2), ysize(3), 0)
ta2(:,:,:) = (xnu * invsc / rho2(:,:,:)) * tc2(:,:,:) - uy2(:,:,:) * ta2(:,:,:)
! Go to Z
CALL transpose_y_to_z(massfrac2, massfrac3)
CALL transpose_y_to_z(uz2, uz3)
CALL transpose_y_to_z(rho2, rho3)
!----------------------------------------
! Z PENCILS
CALL derz (ta3, massfrac3, di3, sz, ffzp, fszp, fwzp, zsize(1), zsize(2), zsize(3), 1)
tb3(:,:,:) = rho3(:,:,:) * ta3(:,:,:)
CALL derz (tc3, tb3, di3, sz, ffz, fsz, fwz, zsize(1), zsize(2), zsize(3), 0)
ta3(:,:,:) = (xnu * invsc / rho3(:,:,:)) * tc3(:,:,:) - uz3(:,:,:) * ta3(:,:,:)
! Get back to X
CALL transpose_z_to_y(ta3, tb2)
ta2(:,:,:) = ta2(:,:,:) + tb2(:,:,:)
CALL transpose_y_to_x(ta2, tb1)
ta1(:,:,:) = ta1(:,:,:) + tb1(:,:,:)
!! Integrate in time
IF ((nscheme.EQ.1).OR.(nscheme.EQ.2)) THEN
!! AB2 or RK3
IF (((nscheme.EQ.1).AND.(itime.EQ.1).AND.(ilit.EQ.0)).OR.&
((nscheme.EQ.2).AND.(itr.EQ.1))) THEN
massfrac1(:,:,:) = massfrac1(:,:,:) + gdt(itr) * ta1(:,:,:)
ELSE
massfrac1(:,:,:) = massfrac1(:,:,:) + adt(itr) * ta1(:,:,:) &
+ bdt(itr) * massfracs1(:,:,:)
ENDIF
ELSE IF (nscheme.EQ.3) THEN
!! RK3