Newer
Older
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
#pragma once
// [bl-flux-def.h]: boundary-layer turbulent fluxes definitions
//
// -------------------------------------------------------------------------------------------- //
#include "wstgrid3d.h"
namespace nse
{
// U,V,W,P 2nd order moments
// -------------------------------------------------------------------------------------------- //
template< typename T >
void uv_flux(T* flux, // node: [C || V]
const T* const UV, // node: [C || V]
const T* const U, // node: [C || C]
const T* const V, // node: [C || V]
const nse_const3d::axisType axis, const wstGrid3d< T >& grid); // [axisZ || axisYZ]
template< typename T >
void uw_flux(T* flux, // node: [W]
const T* const UW, // node: [W]
const T* const U, // node: [C]
const T* const W, // node: [W]
const nse_const3d::axisType axis, const wstGrid3d< T >& grid); // [axisZ || axisYZ]
template< typename T >
void vw_flux(T* flux, // node: [W || VW]
const T* const VW, // node: [W || VW]
const T* const V, // node: [C || V]
const T* const W, // node: [W || W]
const nse_const3d::axisType axis, const wstGrid3d< T >& grid); // [axisZ || axisYZ]
template< typename T >
void pu_flux(T* flux, // node: [C]
const T* const PU, // node: [C]
const T* const P, // node: [C]
const T* const U, // node: [C]
const wstGrid3d< T >& grid);
template< typename T >
void pv_flux(T* flux, // node: [C]
const T* const PV, // node: [C]
const T* const P, // node: [C]
const T* const V, // node: [C]
const wstGrid3d< T >& grid);
template< typename T >
void pw_flux(T* flux, // node: [W]
const T* const PW, // node: [W]
const T* const P, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
// -------------------------------------------------------------------------------------------- /
// U,V,W,C 2nd order moments
// -------------------------------------------------------------------------------------------- //
template< typename T >
void cu_flux(T* flux, // node: [C]
const T* const CU, // node: [C]
const T* const C, // node: [C]
const T* const U, // node: [C]
const wstGrid3d< T >& grid);
template< typename T >
void cv_flux(T* flux, // node: [C]
const T* const CV, // node: [C]
const T* const C, // node: [C]
const T* const V, // node: [C]
const wstGrid3d< T >& grid);
template< typename T >
void cw_flux(T* flux, // node: [W]
const T* const CW, // node: [W]
const T* const C, // node: [C]
const T* const W, // node: [W]
const nse_const3d::axisType axis, const wstGrid3d< T >& grid); // [axisZ || axisYZ]
template< typename T >
void cc_flux(T* flux, // node: [C]
const T* const CC, // node: [C]
const T* const Ca, // node: [C]
const T* const Cb, // node: [C]
const wstGrid3d< T >& grid);
// -------------------------------------------------------------------------------------------- //
// [U^2,V^2,W^2] * W - fluxes
// -------------------------------------------------------------------------------------------- //
template< typename T >
void u2w_flux(T* flux, // node: [W]
const T* const U2W, // node: [W]
const T* const U2, // node: [W]
const T* const UW, // node: [W]
const T* const UW_adv, // node: [W]
const T* const U, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
template< typename T >
void v2w_flux(T* flux, // node: [W]
const T* const V2W, // node: [W]
const T* const V2, // node: [W]
const T* const VW, // node: [W]
const T* const VW_adv, // node: [W]
const T* const V, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
template< typename T >
void w2w_flux(T* flux, // node: [C]
const T* const W3, // node: [C]
const T* const W2_c, // node: [C]
const T* const W2_w, // node: [W]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
// -------------------------------------------------------------------------------------------- //
// [C^2] * W - fluxes
// -------------------------------------------------------------------------------------------- //
template< typename T >
void c2w_flux(T* flux, // node: [W]
const T* const C2W, // node: [W]
const T* const C2, // node: [W]
const T* const CW, // node: [W]
const T* const CW_adv, // node: [W]
const T* const C, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
// -------------------------------------------------------------------------------------------- //
// [UV, UW, VW] * W - fluxes
// -------------------------------------------------------------------------------------------- //
template< typename T >
void uvw_flux(T* flux, // node: [W]
const T* const UVW, // node: [W]
const T* const UW, // node: [W]
const T* const VW, // node: [W]
const T* const UV_uvw, // node: [W]
const T* const UW_uvw, // node: [W]
const T* const VW_uvw, // node: [W]
const T* const U, // node: [C]
const T* const V, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
template< typename T >
void uww_flux(T* flux, // node: [C]
const T* const UWW, // node: [C]
const T* const W2_w, // node: [W]
const T* const W2_c, // node: [C]
const T* const W2_u, // node: [C]
const T* const W2_uw, // node: [W]
const T* const UW, // node: [W]
const T* const UW_bottom_uw, // node: [W (C -- W)]
const T* const UW_top_uw, // node: [W (C -- W)]
const T* const U, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
template< typename T >
void vww_flux(T* flux, // node: [C]
const T* const VWW, // node: [C]
const T* const W2_w, // node: [W]
const T* const W2_c, // node: [C]
const T* const W2_v, // node: [C]
const T* const W2_vw, // node: [W]
const T* const VW, // node: [W]
const T* const VW_bottom_vw, // node: [W (C -- W)]
const T* const VW_top_vw, // node: [W (C -- W)]
const T* const V, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
// -------------------------------------------------------------------------------------------- //
// [CU, CV, CW] * W - fluxes
// -------------------------------------------------------------------------------------------- //
template< typename T >
void cuw_flux(T* flux, // node: [W]
const T* const CUW, // node: [W]
const T* const UW, // node: [W]
const T* const CU_uw, // node: [W]
const T* const CW, // node: [W]
const T* const CW_uw, // node: [W]
const T* const C, // node: [C]
const T* const U, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
template< typename T >
void cvw_flux(T* flux, // node: [W]
const T* const CVW, // node: [W]
const T* const VW, // node: [W]
const T* const CV_vw, // node: [W]
const T* const CW, // node: [W]
const T* const CW_vw, // node: [W]
const T* const C, // node: [C]
const T* const V, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
template< typename T >
void cww_flux(T* flux, // node: [C]
const T* const CWW, // node: [C]
const T* const W2_w, // node: [W]
const T* const W2_c, // node: [C]
const T* const CW, // node: [W]
const T* const CW_bottom_w, // node: [W (C -- W)]
const T* const CW_top_w, // node: [W (C -- W)]
const T* const C, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid);
// -------------------------------------------------------------------------------------------- //
// c - pressure gradient covariances
// -------------------------------------------------------------------------------------------- //
template< typename T >
void c_w_pressure_gradient_turb(T* c_dpdz_turb, // node: [W]
const T* const C_dPdz, // node: [W]
const T* const C, // node: [C]
const T* const Pressure, // node: [C]
const wstGrid3d< T >& grid);
// -------------------------------------------------------------------------------------------- //
}
// U,V,W,P 2nd order moments
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::uv_flux(
T* flux, // node: [C || V]
const T* const UV, // node: [C || V]
const T* const U, // node: [C || C]
const T* const V, // node: [C || V]
const nse_const3d::axisType axis, const wstGrid3d< T >& grid) // [axisZ || axisYZ]
// ____ __ _ _
// u'v' = UV - U * V
{
if (axis == nse_const3d::axisZ) {
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
flux[k] = UV[k] - U[k] * V[k];
}
return;
}
if (axis == nse_const3d::axisYZ) {
// [UV, V] averages have to be known at all [V] nodes, including walls
// [U] average has to be known at all [C] nodes and ghost nodes: (j + 1/2), (j - 1/2)
int j, k, idx;
#pragma omp parallel for private(j, k, idx) shared(flux)
for (j = grid.gcy; j <= grid.ny - grid.gcy; j++) // all [V] nodes
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
idx = j * grid.nz + k;
flux[idx] = UV[idx] - (T) 0.5 * (U[idx] + U[idx - grid.nz]) * V[idx];
}
return;
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::uw_flux(
T* flux, // node: [W]
const T* const UW, // node: [W]
const T* const U, // node: [C]
const T* const W, // node: [W]
const nse_const3d::axisType axis, const wstGrid3d< T >& grid) // [axisZ || axisYZ]
// ____ __ _ _
// u'w' = UW - U * W
// [UW, W] averages have to be known at all [W] nodes, including walls
// [U] average has to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
{
if (axis == nse_const3d::axisZ) {
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
flux[k] = UW[k] - (T) 0.5 * (U[k] + U[k - 1]) * W[k];
}
return;
}
if (axis == nse_const3d::axisYZ) {
int j, k, idx;
#pragma omp parallel for private(j, k, idx) shared(flux)
for (j = grid.gcy; j < grid.ny - grid.gcy; j++)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
idx = j * grid.nz + k;
flux[idx] = UW[idx] - (T) 0.5 * (U[idx] + U[idx - 1]) * W[idx];
}
return;
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::vw_flux(
T* flux, // node: [W || VW]
const T* const VW, // node: [W || VW]
const T* const V, // node: [C || V]
const T* const W, // node: [W || W]
const nse_const3d::axisType axis, const wstGrid3d< T >& grid) // [axisZ || axisYZ]
// ____ __ _ _
// v'w' = VW - V * W
{
if (axis == nse_const3d::axisZ) {
// [VW, W] averages have to be known at all [W] nodes, including walls
// [V] average has to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
flux[k] = VW[k] - (T) 0.5 * (V[k] + V[k - 1]) * W[k];
}
return;
}
if (axis == nse_const3d::axisYZ) {
// [VW] average has to be known at all [VW] nodes, including walls
// [W] average has to be known at all [W] nodes and ghost nodes: (j + 1/2), (j - 1/2)
// [V] average has to be known at all [V] nodes and ghost nodes: (k + 1/2), (k - 1/2)
int j, k, idx;
#pragma omp parallel for private(j, k, idx) shared(flux)
for (j = grid.gcy; j <= grid.ny - grid.gcy; j++) // all [V] nodes
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
idx = j * grid.nz + k;
flux[idx] = VW[idx] - (T) 0.25 *
(V[idx] + V[idx - 1]) * (W[idx] + W[idx - grid.nz]);
}
return;
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::pu_flux(T* flux, // node: [C]
const T* const PU, // node: [C]
const T* const P, // node: [C]
const T* const U, // node: [C]
const wstGrid3d< T >& grid)
// ____ __ _ _
// p'u' = PU - P * U
//
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
flux[k] = PU[k] - P[k] * U[k];
}
}
template< typename T >
void nse::pv_flux(T* flux, // node: [C]
const T* const PV, // node: [C]
const T* const P, // node: [C]
const T* const V, // node: [C]
const wstGrid3d< T >& grid)
// ____ __ _ _
// p'v' = PV - P * V
//
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
flux[k] = PV[k] - P[k] * V[k];
}
}
template< typename T >
void nse::pw_flux(
T* flux, // node: [W]
const T* const PW, // node: [W]
const T* const P, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ____ __ _ _
// p'w' = PW - P * W
// ____ __
// p'w' and PW - are defined at [W] node for the following reason:
// for staggered grid interpolation to [C] node in TKE equation results in:
// ______ 1z ___ 1z
// dp d(w * p ) dw
// w * -- = -------- - p * --
// dz dz dz
//
// [PW, W] averages have to be known at all [W] nodes, including walls
// [P] average has to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
flux[k] = PW[k] - (T) 0.5 * (P[k] + P[k - 1]) * W[k];
}
}
// -------------------------------------------------------------------------------------------- //
// U,V,W,C 2nd order moments
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::cu_flux(
T* flux, // node: [C]
const T* const CU, // node: [C]
const T* const C, // node: [C]
const T* const U, // node: [C]
const wstGrid3d< T >& grid)
// ____ __ _ _
// c'u' = CU - C * U
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
flux[k] = CU[k] - C[k] * U[k];
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::cv_flux(
T* flux, // -z [C] node
const T* const CV, // -z [C] node
const T* const C, // -z [C] node
const T* const V, // -z [C] node
const wstGrid3d< T >& grid)
// ____ __ _ _
// c'v' = CV - C * V
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
flux[k] = CV[k] - C[k] * V[k];
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::cw_flux(
T* flux, // node: [W]
const T* const CW, // node: [W]
const T* const C, // node: [C]
const T* const W, // node: [W]
const nse_const3d::axisType axis, const wstGrid3d< T >& grid) // [axisZ || axisYZ]
// ____ __ _ _
// c'w' = CW - C * W
// [CW, W] averages have to be known at all [W] nodes, including walls
// [C] average has to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
{
if (axis == nse_const3d::axisZ) {
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
flux[k] = CW[k] - (T) 0.5 * (C[k] + C[k - 1]) * W[k];
}
return;
}
if (axis == nse_const3d::axisYZ) {
int j, k, idx;
#pragma omp parallel for private(j, k, idx) shared(flux)
for (j = grid.gcy; j < grid.ny - grid.gcy; j++)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
idx = j * grid.nz + k;
flux[idx] = CW[idx] - (T) 0.5 * (C[idx] + C[idx - 1]) * W[idx];
}
return;
}
}
// -------------------------------------------------------------------------------------------- //
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::cc_flux(T* flux, // node: [C]
const T* const CC, // node: [C]
const T* const Ca, // node: [C]
const T* const Cb, // node: [C]
const wstGrid3d< T >& grid)
// ______ __ __ __
// ca'cb' = CC - Cb * Ca
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
flux[k] = CC[k] - Ca[k] * Cb[k];
}
}
// -------------------------------------------------------------------------------------------- //
// [U^2,V^2,W^2] * W - fluxes
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::u2w_flux(
T* flux, // node: [W]
const T* const U2W, // node: [W]
const T* const U2, // node: [W]
const T* const UW, // node: [W]
const T* const UW_adv, // node: [W]
const T* const U, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ______ ___ __ _ _ __ _ _ _
// u'u'w' = UUW - UU * W - 2 * U * UW + 2 * U * U * W
// ___ _ _ _
// calculation of UUW and U * U * W product:
// ~~~~~1z __1x
// (U * U) * W
//
// [U2W, U2, UW, UW_adv, W] averages have to be known at all [W] nodes, including walls
// [U] average has to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
flux[k] =
U2W[k] - U2[k] * W[k] - (U[k] + U[k - 1]) * UW[k] +
(T) 2.0 * (U[k] * U[k - 1]) * W[k] +
// correction term:
UW_adv[k] * (U[k] - U[k - 1]) * grid.dzh[k];
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::v2w_flux(
T* flux, // node: [W]
const T* const V2W, // node: [W]
const T* const V2, // node: [W]
const T* const VW, // node: [W]
const T* const VW_adv, // node: [W]
const T* const V, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ______ ___ __ _ _ __ _ _ _
// v'v'w' = VVW - VV * W - 2 * V * VW + 2 * V * V * W
// ___ _ _ _
// calculation of VVW product and V * V * W:
// ~~~~~1z __1y
// (V * V) * W
//
// [V2W, V2, VW, VW_adv, W] averages have to be known at all [W] nodes, including walls
// [V] average has to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
flux[k] =
V2W[k] - V2[k] * W[k] - (V[k] + V[k - 1]) * VW[k] +
(T) 2.0 * (V[k] * V[k - 1]) * W[k] +
// correction term:
VW_adv[k] * (V[k] - V[k - 1]) * grid.dzh[k];
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::w2w_flux(
T* flux, // node: [C]
const T* const W3, // node: [C]
const T* const W2_c, // node: [C]
const T* const W2_w, // node: [W]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ______ ___ _ __ _ _ _
// w'w'w' = WWW - 3 * W * WW + 2 * W * W * W
// ___ _ _ _
// calculation of WWW and W * W * W product:
// ~~~~~1z __1z
// (W * W) * W
//
// [W2_w, W] averages have to be known at all [W] nodes, including walls
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
flux[k] =
W3[k] - (W[k] + W[k + 1]) * W2_c[k] -
(T) 0.5 * (W[k] * W2_w[k + 1] + W[k + 1] * W2_w[k]) +
W[k] * W[k + 1] * (W[k] + W[k + 1]);
}
}
// -------------------------------------------------------------------------------------------- //
// [C^2] * W - fluxes
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::c2w_flux(
T* flux, // node: [W]
const T* const C2W, // node: [W]
const T* const C2, // node: [W]
const T* const CW, // node: [W]
const T* const CW_adv, // node: [W]
const T* const C, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ______ ___ __ _ _ __ _ _ _
// c'c'w' = CCW - CC * W - 2 * C * CW + 2 * C * C * W
// ___ _ _ _
// calculation of CCW product and C * C * W:
// ~~~~~1z
// (C * C) * W
//
// [C2W, C2, CW, CW_adv, W] averages have to be known at all [W] nodes, including walls
// [C] average has to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
flux[k] =
C2W[k] - C2[k] * W[k] - (C[k] + C[k - 1]) * CW[k] +
(T) 2.0 * (C[k] * C[k - 1]) * W[k] +
// correction term:
CW_adv[k] * (C[k] - C[k - 1]) * grid.dzh[k];
}
}
// -------------------------------------------------------------------------------------------- //
// [UV, UW, VW] * W - fluxes
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::uvw_flux(
T* flux, // node: [W]
const T* const UVW, // node: [W]
const T* const UW, // node: [W]
const T* const VW, // node: [W]
const T* const UV_uvw, // node: [W]
const T* const UW_uvw, // node: [W]
const T* const VW_uvw, // node: [W]
const T* const U, // node: [C]
const T* const V, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ______ ___ __ _ __ _ __ _ _ _ _
// u'v'w' = UVW - UW * V - VW * U - UV * W + 2 * U * V * W
//
// [UW, VW, UV, W] averages have to be known at all [W] nodes, including walls
// [U, V] averages have to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
flux[k] = UVW[k] -
(T)0.25 * (UW[k] + UW_uvw[k]) * (V[k] + V[k - 1]) -
(T)0.25 * (VW[k] + VW_uvw[k]) * (U[k] + U[k - 1]) -
UV_uvw[k] * W[k] +
(T)0.5 * W[k] * (U[k] + U[k - 1]) * (V[k] + V[k - 1]);
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::uww_flux(
T* flux, // node: [C]
const T* const UWW, // node: [C]
const T* const W2_w, // node: [W]
const T* const W2_c, // node: [C]
const T* const W2_u, // node: [C]
const T* const W2_uw, // node: [W]
const T* const UW, // node: [W]
const T* const UW_bottom_uw, // node: [W (C -- W)]
const T* const UW_top_uw, // node: [W (C -- W)]
const T* const U, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ______ ___ __ _ _ __ __ _ _ _ _
// u'w'w' = UWW - WW * U - W * UW - UW * W + 2 * U * W * W
//
// [W^2 (at -UW and -W nodes), W, UW] averages have to be known at all [W] nodes, including walls
// [U] average has to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
// [UW-top] average has to be known at (gcz, nz - gcz - 1) nodes
// [UW-bottom] average has to be known at (gcz + 1, nz - gcz) nodes
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
flux[k] = UWW[k] -
// __ _
// WW * U
(T)0.5 * (
(T)0.25 * (U[k + 1] + (T)2.0 * U[k] + U[k - 1]) *
(T)0.25 * (W2_w[k] + (T)2.0 * W2_c[k] + W2_w[k + 1])
+
(T)0.5 *
(T)0.25 * (W2_uw[k + 1] + W2_u[k]) * (U[k] + U[k + 1])
+
(T)0.5 *
(T)0.25 * (W2_uw[k] + W2_u[k]) * (U[k] + U[k - 1])
)
-
// _ __ __ _
// - W * UW - UW * W
(
(T)0.25 * (W[k] + W[k + 1]) * (UW_bottom_uw[k + 1] + UW_top_uw[k]) +
(T)0.25 * (W[k + 1] * UW_bottom_uw[k + 1] + W[k] * UW_top_uw[k]) +
(T)0.125 * (W[k] + W[k + 1]) * (UW[k] + UW[k + 1])
)
+
// _ _ _
// 2 * W * W * U
(T)0.5 * (W[k] + W[k + 1]) *
(
(T)0.125 * (W[k] + W[k + 1]) * (U[k + 1] + (T)2.0 * U[k] + U[k - 1]) +
(T)0.25 * W[k + 1] * (U[k] + U[k + 1]) + (T)0.25 * W[k] * (U[k] + U[k - 1])
);
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::vww_flux(
T* flux, // node: [C]
const T* const VWW, // node: [C]
const T* const W2_w, // node: [W]
const T* const W2_c, // node: [C]
const T* const W2_v, // node: [C]
const T* const W2_vw, // node: [W]
const T* const VW, // node: [W]
const T* const VW_bottom_vw, // node: [W (C -- W)]
const T* const VW_top_vw, // node: [W (C -- W)]
const T* const V, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ______ ___ __ _ _ __ __ _ _ _ _
// v'w'w' = VWW - WW * V - W * VW - VW * W + 2 * V * W * W
//
// [W^2 (at -VW and -W nodes), W, VW] averages have to be known at all [W] nodes, including walls
// [V] average has to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
// [VW-top] average has to be known at (gcz, nz - gcz - 1) nodes
// [VW-bottom] average has to be known at (gcz + 1, nz - gcz) nodes
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
flux[k] = VWW[k] -
// __ _
// WW * V
(T)0.5 * (
(T)0.25 * (V[k + 1] + (T)2.0 * V[k] + V[k - 1]) *
(T)0.25 * (W2_w[k] + (T)2.0 * W2_c[k] + W2_w[k + 1])
+
(T)0.5 *
(T)0.25 * (W2_vw[k + 1] + W2_v[k]) * (V[k] + V[k + 1])
+
(T)0.5 *
(T)0.25 * (W2_vw[k] + W2_v[k]) * (V[k] + V[k - 1])
)
-
// _ __ __ _
// - W * VW - VW * W
(
(T)0.25 * (W[k] + W[k + 1]) * (VW_bottom_vw[k + 1] + VW_top_vw[k]) +
(T)0.25 * (W[k + 1] * VW_bottom_vw[k + 1] + W[k] * VW_top_vw[k]) +
(T)0.125 * (W[k] + W[k + 1]) * (VW[k] + VW[k + 1])
)
+
// _ _ _
// 2 * W * W * V
(T)0.5 * (W[k] + W[k + 1]) *
(
(T)0.125 * (W[k] + W[k + 1]) * (V[k + 1] + (T)2.0 * V[k] + V[k - 1]) +
(T)0.25 * W[k + 1] * (V[k] + V[k + 1]) + (T)0.25 * W[k] * (V[k] + V[k - 1])
);
}
}
// -------------------------------------------------------------------------------------------- //
// [CU, CV, CW] * W - fluxes
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::cuw_flux(
T* flux, // node: [W]
const T* const CUW, // node: [W]
const T* const UW, // node: [W]
const T* const CU_uw, // node: [W]
const T* const CW, // node: [W]
const T* const CW_uw, // node: [W]
const T* const C, // node: [C]
const T* const U, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ______ ___ __ _ _ __ _ __ _ _ _
// c'u'w' = CUW - CU * W - C * UW - U * CW + 2 * C * U * W
//
// [CUW, UW, CW, CU, W] averages have to be known at all [W] nodes, including walls
// [U, C] averages have to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) {
flux[k] = CUW[k] - (T)0.5 * UW[k] * (C[k] + C[k - 1])
- (T)0.25 * (CW_uw[k] + CW[k]) * (U[k] + U[k - 1])
- CU_uw[k] * W[k] +
(T)2.0 * (T)0.25 * (U[k] + U[k - 1]) * (C[k] + C[k - 1]) * W[k];
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::cvw_flux(
T* flux, // node: [W]
const T* const CVW, // node: [W]
const T* const VW, // node: [W]
const T* const CV_vw, // node: [W]
const T* const CW, // node: [W]
const T* const CW_vw, // node: [W]
const T* const C, // node: [C]
const T* const V, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ______ ___ __ _ _ __ _ __ _ _ _
// c'v'w' = CVW - CV * W - C * VW - V * CW + 2 * C * V * W
//
// [CVW, VW, CW, CV, W] averages have to be known at all [W] nodes, including walls
// [V, C] averages have to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) {
flux[k] = CVW[k] - (T)0.5 * VW[k] * (C[k] + C[k - 1])
- (T)0.25 * (CW_vw[k] + CW[k]) * (V[k] + V[k - 1])
- CV_vw[k] * W[k] +
(T)2.0 * (T)0.25 * (V[k] + V[k - 1]) * (C[k] + C[k - 1]) * W[k];
}
}
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::cww_flux(
T* flux, // node: [C]
const T* const CWW, // node: [C]
const T* const W2_w, // node: [W]
const T* const W2_c, // node: [C]
const T* const CW, // node: [W]
const T* const CW_bottom_w, // node: [W (C -- W)]
const T* const CW_top_w, // node: [W (C -- W)]
const T* const C, // node: [C]
const T* const W, // node: [W]
const wstGrid3d< T >& grid)
// ______ ___ __ _ _ __ __ _ _ _ _
// c'w'w' = CWW - WW * C - W * CW - WC * W + 2 * C * W * W
//
// [W^2, CW, W] averages have to be known at all [W] nodes, including walls
// [C] average has to be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
// [CW-top] average has to be known at (gcz, nz - gcz - 1) nodes
// [CW-bottom] average has to be known at (gcz + 1, nz - gcz) nodes
{
int k;
#pragma omp parallel for private(k) shared(flux)
for (k = grid.gcz; k < grid.nz - grid.gcz; k++) {
flux[k] = CWW[k]
// __ _
// WW * C
- (T)0.5 * (
(T)0.25 * (T)0.25 * (W2_w[k] + W2_w[k + 1] + (T)2.0 * W2_c[k]) * (C[k + 1] + (T)2.0 * C[k] + C[k - 1]) +
(T)0.25 * (T)0.5 * (W2_w[k] + W2_c[k]) * (C[k] + C[k - 1]) +
(T)0.25 * (T)0.5 * (W2_w[k + 1] + W2_c[k]) * (C[k] + C[k + 1]))
// _ __
// W * CW
- (T)0.125 * (W[k] + W[k + 1]) * (CW_bottom_w[k + 1] + CW_top_w[k] + CW[k] + CW[k + 1])
- (T)0.25 * (
(T)0.5 * (W[k] + W[k + 1]) * (CW_bottom_w[k + 1] + CW_top_w[k]) +
W[k] * CW_top_w[k] + W[k + 1] * CW_bottom_w[k + 1])
// _ _ _
// 2 * W * W * C
+ (T)0.5 * (W[k] + W[k + 1]) * (
(T)0.5 * (T)0.25 * (W[k] + W[k + 1]) * (C[k + 1] + (T)2.0 * C[k] + C[k - 1]) +
(T)0.25 * W[k] * (C[k] + C[k - 1]) + (T)0.25 * W[k + 1] * (C[k] + C[k + 1]));
}
}
// -------------------------------------------------------------------------------------------- //
// c - pressure gradient covariances
// -------------------------------------------------------------------------------------------- //
template< typename T >
void nse::c_w_pressure_gradient_turb(
T* c_dpdz_turb, // node: [W]
const T* const C_dPdz, // node: [W]
const T* const C, // node: [C]
const T* const Pressure, // node: [C]
const wstGrid3d< T >& grid)
// C-pressure gradient covariance
// __________
// dp'
// c' * ----
// dz
//
// [C, P] averages have be known at all [C] nodes and ghost nodes: (k + 1/2), (k - 1/2)
{
int k;
#pragma omp parallel for private(k) shared(c_dpdz_turb)
for (k = grid.gcz; k <= grid.nz - grid.gcz; k++) { // all [W] nodes
c_dpdz_turb[k] = C_dPdz[k] -
(C[k] + C[k - 1]) * (Pressure[k] - Pressure[k - 1]) * grid.dzmi[k];
}
}
// -------------------------------------------------------------------------------------------- //