forked from MFlowCode/MFC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathm_cbc.fpp
More file actions
1706 lines (1407 loc) · 73.1 KB
/
m_cbc.fpp
File metadata and controls
1706 lines (1407 loc) · 73.1 KB
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
!>
!! @file
!! @brief Contains module m_cbc
!> @brief Characteristic boundary conditions (CBC) for slip walls, non-reflecting subsonic inflow/outflow, and supersonic boundaries
#:include 'case.fpp'
#:include 'macros.fpp'
module m_cbc
use m_derived_types !< Definitions of the derived types
use m_global_parameters !< Definitions of the global parameters
use m_variables_conversion !< State variables type conversion procedures
use m_compute_cbc
use m_thermochem, only: &
get_mixture_energy_mass, get_mixture_specific_heat_cv_mass, &
get_mixture_specific_heat_cp_mass, gas_constant, &
get_mixture_molecular_weight, get_species_enthalpies_rt, &
molecular_weights, get_species_specific_heats_r, &
get_mole_fractions, get_species_specific_heats_r
#:if USING_AMD
use m_chemistry, only: molecular_weights_nonparameter
#:endif
implicit none
private; public :: s_initialize_cbc_module, s_cbc, s_finalize_cbc_module
!! The cell-average primitive variables. They are obtained by reshaping (RS)
!! q_prim_vf in the coordinate direction normal to the domain boundary along
!! which the CBC is applied.
real(wp), allocatable, dimension(:, :, :, :) :: q_prim_rsx_vf
real(wp), allocatable, dimension(:, :, :, :) :: q_prim_rsy_vf
real(wp), allocatable, dimension(:, :, :, :) :: q_prim_rsz_vf
$:GPU_DECLARE(create='[q_prim_rsx_vf,q_prim_rsy_vf,q_prim_rsz_vf]')
!! Cell-average fluxes (src - source). These are directly determined from the
!! cell-average primitive variables, q_prims_rs_vf, and not a Riemann solver.
real(wp), allocatable, dimension(:, :, :, :) :: F_rsx_vf, F_src_rsx_vf !<
real(wp), allocatable, dimension(:, :, :, :) :: F_rsy_vf, F_src_rsy_vf !<
real(wp), allocatable, dimension(:, :, :, :) :: F_rsz_vf, F_src_rsz_vf !<
$:GPU_DECLARE(create='[F_rsx_vf,F_src_rsx_vf,F_rsy_vf,F_src_rsy_vf,F_rsz_vf,F_src_rsz_vf]')
!! There is a CCE bug that is causing some subset of these variables to interfere
!! with variables of the same name in m_riemann_solvers.fpp, and giving this versions
!! unique "_l" names works around the bug. Other private module allocatable arrays
!! in `acc declare create` clauses don't have this problem, so we still need to
!! isolate this bug.
real(wp), allocatable, dimension(:, :, :, :) :: flux_rsx_vf_l, flux_src_rsx_vf_l !<
real(wp), allocatable, dimension(:, :, :, :) :: flux_rsy_vf_l, flux_src_rsy_vf_l
real(wp), allocatable, dimension(:, :, :, :) :: flux_rsz_vf_l, flux_src_rsz_vf_l
$:GPU_DECLARE(create='[flux_rsx_vf_l,flux_src_rsx_vf_l,flux_rsy_vf_l,flux_src_rsy_vf_l,flux_rsz_vf_l,flux_src_rsz_vf_l]')
real(wp), allocatable, dimension(:) :: ds !< Cell-width distribution in the s-direction
! CBC Coefficients
real(wp), allocatable, dimension(:, :) :: fd_coef_x !< Finite diff. coefficients x-dir
real(wp), allocatable, dimension(:, :) :: fd_coef_y !< Finite diff. coefficients y-dir
real(wp), allocatable, dimension(:, :) :: fd_coef_z !< Finite diff. coefficients z-dir
!! The first dimension identifies the location of a coefficient in the FD
!! formula, while the last dimension denotes the location of the CBC.
! Bug with NVHPC when using nullified pointers in a declare create
! real(wp), pointer, dimension(:, :) :: fd_coef => null()
real(wp), allocatable, dimension(:, :, :) :: pi_coef_x !< Polynomial interpolant coefficients in x-dir
real(wp), allocatable, dimension(:, :, :) :: pi_coef_y !< Polynomial interpolant coefficients in y-dir
real(wp), allocatable, dimension(:, :, :) :: pi_coef_z !< Polynomial interpolant coefficients in z-dir
$:GPU_DECLARE(create='[ds,fd_coef_x,fd_coef_y,fd_coef_z,pi_coef_x,pi_coef_y,pi_coef_z]')
!! The first dimension of the array identifies the polynomial, the
!! second dimension identifies the position of its coefficients and the last
!! dimension denotes the location of the CBC.
type(int_bounds_info) :: is1, is2, is3 !< Indical bounds in the s1-, s2- and s3-directions
$:GPU_DECLARE(create='[is1,is2,is3]')
integer :: dj
integer :: bcxb, bcxe, bcyb, bcye, bczb, bcze
integer :: cbc_dir, cbc_loc
integer :: flux_cbc_index
$:GPU_DECLARE(create='[dj,bcxb,bcxe,bcyb,bcye,bczb,bcze]')
$:GPU_DECLARE(create='[cbc_dir, cbc_loc,flux_cbc_index]')
!! GRCBC inputs for subsonic inflow and outflow conditions consisting of
!! inflow velocities, pressure, density and void fraction as well as
!! outflow velocities and pressure
real(wp), allocatable, dimension(:) :: pres_in, pres_out, Del_in, Del_out
real(wp), allocatable, dimension(:, :) :: vel_in, vel_out
real(wp), allocatable, dimension(:, :) :: alpha_rho_in, alpha_in
$:GPU_DECLARE(create='[pres_in,pres_out,Del_in,Del_out]')
$:GPU_DECLARE(create='[vel_in,vel_out]')
$:GPU_DECLARE(create='[alpha_rho_in,alpha_in]')
contains
!> The computation of parameters, the allocation of memory,
!! the association of pointers and/or the execution of any
!! other procedures that are necessary to setup the module.
impure subroutine s_initialize_cbc_module
integer :: i
logical :: is_cbc
type(int_bounds_info) :: idx1, idx2
if (chemistry) then
flux_cbc_index = sys_size
else
flux_cbc_index = adv_idx%end
end if
$:GPU_UPDATE(device='[flux_cbc_index]')
call s_any_cbc_boundaries(is_cbc)
if (is_cbc .eqv. .false.) return
if (n == 0) then
is2%beg = 0
else
is2%beg = -buff_size
end if
is2%end = n - is2%beg
if (p == 0) then
is3%beg = 0
else
is3%beg = -buff_size
end if
is3%end = p - is3%beg
@:ALLOCATE(q_prim_rsx_vf(0:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, 1:sys_size))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(F_rsx_vf(0:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, 1:flux_cbc_index))
@:ALLOCATE(F_src_rsx_vf(0:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, adv_idx%beg:adv_idx%end))
end if
@:ALLOCATE(flux_rsx_vf_l(-1:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, 1:flux_cbc_index))
@:ALLOCATE(flux_src_rsx_vf_l(-1:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, adv_idx%beg:adv_idx%end))
if (n > 0) then
if (m == 0) then
is2%beg = 0
else
is2%beg = -buff_size
end if
is2%end = m - is2%beg
if (p == 0) then
is3%beg = 0
else
is3%beg = -buff_size
end if
is3%end = p - is3%beg
@:ALLOCATE(q_prim_rsy_vf(0:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, 1:sys_size))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(F_rsy_vf(0:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, 1:flux_cbc_index))
@:ALLOCATE(F_src_rsy_vf(0:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, adv_idx%beg:adv_idx%end))
end if
@:ALLOCATE(flux_rsy_vf_l(-1:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, 1:flux_cbc_index))
@:ALLOCATE(flux_src_rsy_vf_l(-1:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, adv_idx%beg:adv_idx%end))
end if
if (p > 0) then
if (n == 0) then
is2%beg = 0
else
is2%beg = -buff_size
end if
is2%end = n - is2%beg
if (m == 0) then
is3%beg = 0
else
is3%beg = -buff_size
end if
is3%end = m - is3%beg
@:ALLOCATE(q_prim_rsz_vf(0:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, 1:sys_size))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(F_rsz_vf(0:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, 1:flux_cbc_index))
@:ALLOCATE(F_src_rsz_vf(0:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, adv_idx%beg:adv_idx%end))
end if
@:ALLOCATE(flux_rsz_vf_l(-1:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, 1:flux_cbc_index))
@:ALLOCATE(flux_src_rsz_vf_l(-1:buff_size, &
is2%beg:is2%end, &
is3%beg:is3%end, adv_idx%beg:adv_idx%end))
end if
! Allocating the cell-width distribution in the s-direction
@:ALLOCATE(ds(0:buff_size))
if (recon_type == WENO_TYPE) then
idx1%beg = 0
idx1%end = weno_polyn - 1
idx2%beg = 0
idx2%end = weno_order - 3
else if (recon_type == MUSCL_TYPE) then
idx1%beg = 0
idx1%end = muscl_polyn
idx2%beg = 0
idx2%end = muscl_order - 1
end if
! Allocating/Computing CBC Coefficients in x-direction
if (all((/bc_x%beg, bc_x%end/) <= -5) .and. all((/bc_x%beg, bc_x%end/) >= -13)) then
@:ALLOCATE(fd_coef_x(0:buff_size, -1:1))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(pi_coef_x(idx1%beg:idx1%end, idx2%beg:idx2%end, -1:1))
end if
call s_compute_cbc_coefficients(1, -1)
call s_compute_cbc_coefficients(1, 1)
elseif (bc_x%beg <= -5 .and. bc_x%beg >= -13) then
@:ALLOCATE(fd_coef_x(0:buff_size, -1:-1))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(pi_coef_x(idx1%beg:idx1%end, idx2%beg:idx2%end, -1:-1))
end if
call s_compute_cbc_coefficients(1, -1)
elseif (bc_x%end <= -5 .and. bc_x%end >= -13) then
@:ALLOCATE(fd_coef_x(0:buff_size, 1:1))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(pi_coef_x(idx1%beg:idx1%end, idx2%beg:idx2%end, 1:1))
end if
call s_compute_cbc_coefficients(1, 1)
end if
! Allocating/Computing CBC Coefficients in y-direction
if (n > 0) then
if (all((/bc_y%beg, bc_y%end/) <= -5) .and. all((/bc_y%beg, bc_y%end/) >= -13)) then
@:ALLOCATE(fd_coef_y(0:buff_size, -1:1))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(pi_coef_y(idx1%beg:idx1%end, idx2%beg:idx2%end, -1:1))
end if
call s_compute_cbc_coefficients(2, -1)
call s_compute_cbc_coefficients(2, 1)
elseif (bc_y%beg <= -5 .and. bc_y%beg >= -13) then
@:ALLOCATE(fd_coef_y(0:buff_size, -1:-1))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(pi_coef_y(idx1%beg:idx1%end, idx2%beg:idx2%end, -1:-1))
end if
call s_compute_cbc_coefficients(2, -1)
elseif (bc_y%end <= -5 .and. bc_y%end >= -13) then
@:ALLOCATE(fd_coef_y(0:buff_size, 1:1))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(pi_coef_y(idx1%beg:idx1%end, idx2%beg:idx2%end, 1:1))
end if
call s_compute_cbc_coefficients(2, 1)
end if
end if
! Allocating/Computing CBC Coefficients in z-direction
if (p > 0) then
if (all((/bc_z%beg, bc_z%end/) <= -5) .and. all((/bc_z%beg, bc_z%end/) >= -13)) then
@:ALLOCATE(fd_coef_z(0:buff_size, -1:1))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(pi_coef_z(idx1%beg:idx1%end, idx2%beg:idx2%end, -1:1))
end if
call s_compute_cbc_coefficients(3, -1)
call s_compute_cbc_coefficients(3, 1)
elseif (bc_z%beg <= -5 .and. bc_z%beg >= -13) then
@:ALLOCATE(fd_coef_z(0:buff_size, -1:-1))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(pi_coef_z(idx1%beg:idx1%end, idx2%beg:idx2%end, -1:-1))
end if
call s_compute_cbc_coefficients(3, -1)
elseif (bc_z%end <= -5 .and. bc_z%end >= -13) then
@:ALLOCATE(fd_coef_z(0:buff_size, 1:1))
if (weno_order > 1 .or. muscl_order > 1) then
@:ALLOCATE(pi_coef_z(idx1%beg:idx1%end, idx2%beg:idx2%end, 1:1))
end if
call s_compute_cbc_coefficients(3, 1)
end if
end if
$:GPU_UPDATE(device='[fd_coef_x,fd_coef_y,fd_coef_z, &
& pi_coef_x,pi_coef_y,pi_coef_z]')
! Associating the procedural pointer to the appropriate subroutine
! that will be utilized in the conversion to the mixture variables
bcxb = bc_x%beg
bcxe = bc_x%end
$:GPU_UPDATE(device='[bcxb, bcxe]')
if (n > 0) then
bcyb = bc_y%beg
bcye = bc_y%end
$:GPU_UPDATE(device='[bcyb, bcye]')
end if
if (p > 0) then
bczb = bc_z%beg
bcze = bc_z%end
$:GPU_UPDATE(device='[bczb, bcze]')
end if
! Allocate GRCBC inputs
@:ALLOCATE(pres_in(1:num_dims), pres_out(1:num_dims))
@:ALLOCATE(Del_in(1:num_dims), Del_out(1:num_dims))
@:ALLOCATE(vel_in(1:num_dims, 1:num_dims), vel_out(1:num_dims, 1:num_dims))
@:ALLOCATE(alpha_rho_in(1:num_fluids, 1:num_dims), alpha_in(1:num_fluids, 1:num_dims))
! Assign and update GRCBC inputs
#:for CBC_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')]
if (${CBC_DIR}$ <= num_dims) then
vel_in(${CBC_DIR}$, 1) = bc_${XYZ}$%vel_in(1)
vel_out(${CBC_DIR}$, 1) = bc_${XYZ}$%vel_out(1)
if (n > 0) then
vel_in(${CBC_DIR}$, 2) = bc_${XYZ}$%vel_in(2)
vel_out(${CBC_DIR}$, 2) = bc_${XYZ}$%vel_out(2)
if (p > 0) then
vel_in(${CBC_DIR}$, 3) = bc_${XYZ}$%vel_in(3)
vel_out(${CBC_DIR}$, 3) = bc_${XYZ}$%vel_out(3)
end if
end if
Del_in(${CBC_DIR}$) = maxval(d${XYZ}$)
Del_out(${CBC_DIR}$) = maxval(d${XYZ}$)
pres_in(${CBC_DIR}$) = bc_${XYZ}$%pres_in
pres_out(${CBC_DIR}$) = bc_${XYZ}$%pres_out
do i = 1, num_fluids
alpha_rho_in(i, ${CBC_DIR}$) = bc_${XYZ}$%alpha_rho_in(i)
alpha_in(i, ${CBC_DIR}$) = bc_${XYZ}$%alpha_in(i)
end do
end if
#:endfor
$:GPU_UPDATE(device='[vel_in,vel_out,pres_in,pres_out,Del_in,Del_out,alpha_rho_in,alpha_in]')
end subroutine s_initialize_cbc_module
!> Compute CBC coefficients
!! @param cbc_dir_in CBC coordinate direction
!! @param cbc_loc_in CBC coordinate location
subroutine s_compute_cbc_coefficients(cbc_dir_in, cbc_loc_in)
! Description: The purpose of this subroutine is to compute the grid
! dependent FD and PI coefficients, or CBC coefficients,
! provided the CBC coordinate direction and location.
! CBC coordinate direction and location
integer, intent(in) :: cbc_dir_in, cbc_loc_in
! Cell-boundary locations in the s-direction
real(wp), dimension(0:buff_size + 1) :: s_cb
! Generic loop iterator
integer :: i
! Associating CBC coefficients pointers
call s_associate_cbc_coefficients_pointers(cbc_dir_in, cbc_loc_in)
! Determining the cell-boundary locations in the s-direction
s_cb(0) = 0._wp
do i = 0, buff_size
s_cb(i + 1) = s_cb(i) + ds(i)
end do
! Computing CBC1 Coefficients
#:for CBC_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')]
if (cbc_dir_in == ${CBC_DIR}$ .and. recon_type == WENO_TYPE) then
if (weno_order == 1) then
fd_coef_${XYZ}$ (:, cbc_loc_in) = 0._wp
fd_coef_${XYZ}$ (0, cbc_loc_in) = -2._wp/(ds(0) + ds(1))
fd_coef_${XYZ}$ (1, cbc_loc_in) = -fd_coef_${XYZ}$ (0, cbc_loc_in)
! Computing CBC2 Coefficients
elseif (weno_order == 3) then
fd_coef_${XYZ}$ (:, cbc_loc_in) = 0._wp
fd_coef_${XYZ}$ (0, cbc_loc_in) = -6._wp/(3._wp*ds(0) + 2._wp*ds(1) - ds(2))
fd_coef_${XYZ}$ (1, cbc_loc_in) = -4._wp*fd_coef_${XYZ}$ (0, cbc_loc_in)/3._wp
fd_coef_${XYZ}$ (2, cbc_loc_in) = fd_coef_${XYZ}$ (0, cbc_loc_in)/3._wp
pi_coef_${XYZ}$ (0, 0, cbc_loc_in) = (s_cb(0) - s_cb(1))/(s_cb(0) - s_cb(2))
! Computing CBC4 Coefficients
else
fd_coef_${XYZ}$ (:, cbc_loc_in) = 0._wp
fd_coef_${XYZ}$ (0, cbc_loc_in) = -50._wp/(25._wp*ds(0) + 2._wp*ds(1) &
- 1.e1_wp*ds(2) + 1.e1_wp*ds(3) &
- 3._wp*ds(4))
fd_coef_${XYZ}$ (1, cbc_loc_in) = -48._wp*fd_coef_${XYZ}$ (0, cbc_loc_in)/25._wp
fd_coef_${XYZ}$ (2, cbc_loc_in) = 36._wp*fd_coef_${XYZ}$ (0, cbc_loc_in)/25._wp
fd_coef_${XYZ}$ (3, cbc_loc_in) = -16._wp*fd_coef_${XYZ}$ (0, cbc_loc_in)/25._wp
fd_coef_${XYZ}$ (4, cbc_loc_in) = 3._wp*fd_coef_${XYZ}$ (0, cbc_loc_in)/25._wp
pi_coef_${XYZ}$ (0, 0, cbc_loc_in) = &
((s_cb(0) - s_cb(1))*(s_cb(1) - s_cb(2))* &
(s_cb(1) - s_cb(3)))/((s_cb(1) - s_cb(4))* &
(s_cb(4) - s_cb(0))*(s_cb(4) - s_cb(2)))
pi_coef_${XYZ}$ (0, 1, cbc_loc_in) = &
((s_cb(1) - s_cb(0))*(s_cb(1) - s_cb(2))* &
((s_cb(1) - s_cb(3))*(s_cb(1) - s_cb(3)) - &
(s_cb(0) - s_cb(4))*((s_cb(3) - s_cb(1)) + &
(s_cb(4) - s_cb(1)))))/ &
((s_cb(0) - s_cb(3))*(s_cb(1) - s_cb(3))* &
(s_cb(0) - s_cb(4))*(s_cb(1) - s_cb(4)))
pi_coef_${XYZ}$ (0, 2, cbc_loc_in) = &
(s_cb(1) - s_cb(0))*((s_cb(1) - s_cb(2))* &
(s_cb(1) - s_cb(3)) + ((s_cb(0) - s_cb(2)) + &
(s_cb(1) - s_cb(3)))*(s_cb(0) - s_cb(4)))/ &
((s_cb(2) - s_cb(0))*(s_cb(0) - s_cb(3))* &
(s_cb(0) - s_cb(4)))
pi_coef_${XYZ}$ (1, 0, cbc_loc_in) = &
((s_cb(0) - s_cb(2))*(s_cb(2) - s_cb(1))* &
(s_cb(2) - s_cb(3)))/((s_cb(2) - s_cb(4))* &
(s_cb(4) - s_cb(0))*(s_cb(4) - s_cb(1)))
pi_coef_${XYZ}$ (1, 1, cbc_loc_in) = &
((s_cb(0) - s_cb(2))*(s_cb(1) - s_cb(2))* &
((s_cb(1) - s_cb(3))*(s_cb(2) - s_cb(3)) + &
(s_cb(0) - s_cb(4))*((s_cb(1) - s_cb(3)) + &
(s_cb(2) - s_cb(4)))))/ &
((s_cb(0) - s_cb(3))*(s_cb(1) - s_cb(3))* &
(s_cb(0) - s_cb(4))*(s_cb(1) - s_cb(4)))
pi_coef_${XYZ}$ (1, 2, cbc_loc_in) = &
((s_cb(1) - s_cb(2))*(s_cb(2) - s_cb(3))* &
(s_cb(2) - s_cb(4)))/((s_cb(0) - s_cb(2))* &
(s_cb(0) - s_cb(3))*(s_cb(0) - s_cb(4)))
end if
end if
#:endfor
! END: Computing CBC4 Coefficients
! Nullifying CBC coefficients
end subroutine s_compute_cbc_coefficients
!> @brief Associates finite-difference and polynomial-interpolation CBC coefficients with targets based on coordinate direction and boundary location.
!! The goal of the procedure is to associate the FD and PI
!! coefficients, or CBC coefficients, with the appropriate
!! targets, based on the coordinate direction and location
!! of the CBC.
!! @param cbc_dir_in CBC coordinate direction
!! @param cbc_loc_in CBC coordinate location
subroutine s_associate_cbc_coefficients_pointers(cbc_dir_in, cbc_loc_in)
integer, intent(in) :: cbc_dir_in, cbc_loc_in
integer :: i !< Generic loop iterator
! Associating CBC Coefficients in x-direction
if (cbc_dir_in == 1) then
!fd_coef => fd_coef_x; if (weno_order > 1) pi_coef => pi_coef_x
if (cbc_loc_in == -1) then
do i = 0, buff_size
ds(i) = dx(i)
end do
else
do i = 0, buff_size
ds(i) = dx(m - i)
end do
end if
! Associating CBC Coefficients in y-direction
elseif (cbc_dir_in == 2) then
!fd_coef => fd_coef_y; if (weno_order > 1) pi_coef => pi_coef_y
if (cbc_loc_in == -1) then
do i = 0, buff_size
ds(i) = dy(i)
end do
else
do i = 0, buff_size
ds(i) = dy(n - i)
end do
end if
! Associating CBC Coefficients in z-direction
else
!fd_coef => fd_coef_z; if (weno_order > 1) pi_coef => pi_coef_z
if (cbc_loc_in == -1) then
do i = 0, buff_size
ds(i) = dz(i)
end do
else
do i = 0, buff_size
ds(i) = dz(p - i)
end do
end if
end if
$:GPU_UPDATE(device='[ds]')
end subroutine s_associate_cbc_coefficients_pointers
!> The following is the implementation of the CBC based on
!! the work of Thompson (1987, 1990) on hyperbolic systems.
!! The CBC is indirectly applied in the computation of the
!! right-hand-side (RHS) near the relevant domain boundary
!! through the modification of the fluxes.
!! @param q_prim_vf Cell-average primitive variables
!! @param flux_vf Cell-boundary-average fluxes
!! @param flux_src_vf Cell-boundary-average flux sources
!! @param cbc_dir_norm CBC coordinate direction
!! @param cbc_loc_norm CBC coordinate location
!! @param ix Index bound in the first coordinate direction
!! @param iy Index bound in the second coordinate direction
!! @param iz Index bound in the third coordinate direction
subroutine s_cbc(q_prim_vf, flux_vf, flux_src_vf, &
cbc_dir_norm, cbc_loc_norm, &
ix, iy, iz)
type(scalar_field), &
dimension(sys_size), &
intent(in) :: q_prim_vf
type(scalar_field), &
dimension(sys_size), &
intent(inout) :: flux_vf, flux_src_vf
integer, intent(in) :: cbc_dir_norm, cbc_loc_norm
type(int_bounds_info), intent(in) :: ix, iy, iz
real(wp) :: drho_dt
real(wp) :: dpres_dt
real(wp) :: dgamma_dt
real(wp) :: dpi_inf_dt
real(wp) :: dqv_dt
real(wp) :: dpres_ds
#:if USING_AMD
real(wp), dimension(20) :: L
#:else
real(wp), dimension(sys_size) :: L
#:endif
#:if not MFC_CASE_OPTIMIZATION and USING_AMD
real(wp), dimension(3) :: alpha_rho, dalpha_rho_ds, mf
real(wp), dimension(3) :: vel, dvel_ds
real(wp), dimension(3) :: adv_local, dadv_ds
real(wp), dimension(3) :: dadv_dt
real(wp), dimension(3) :: dvel_dt
real(wp), dimension(3) :: dalpha_rho_dt
real(wp), dimension(10) :: Ys, h_k, dYs_dt, dYs_ds, Xs, Gamma_i, Cp_i
#:else
real(wp), dimension(num_fluids) :: alpha_rho, dalpha_rho_ds, mf
real(wp), dimension(num_vels) :: vel, dvel_ds
real(wp), dimension(num_fluids) :: adv_local, dadv_ds
real(wp), dimension(num_fluids) :: dadv_dt
real(wp), dimension(num_dims) :: dvel_dt
real(wp), dimension(num_fluids) :: dalpha_rho_dt
real(wp), dimension(num_species) :: Ys, h_k, dYs_dt, dYs_ds, Xs, Gamma_i, Cp_i
#:endif
real(wp), dimension(2) :: Re_cbc
real(wp), dimension(3) :: lambda
real(wp) :: rho !< Cell averaged density
real(wp) :: pres !< Cell averaged pressure
real(wp) :: E !< Cell averaged energy
real(wp) :: H !< Cell averaged enthalpy
real(wp) :: gamma !< Cell averaged specific heat ratio
real(wp) :: pi_inf !< Cell averaged liquid stiffness
real(wp) :: qv !< Cell averaged fluid reference energy
real(wp) :: c
real(wp) :: Ma
real(wp) :: T, sum_Enthalpies
real(wp) :: Cv, Cp, e_mix, Mw, R_gas
real(wp) :: vel_K_sum, vel_dv_dt_sum
integer :: i, j, k, r !< Generic loop iterators
! Reshaping of inputted data and association of the FD and PI
! coefficients, or CBC coefficients, respectively, hinging on
! selected CBC coordinate direction
cbc_dir = cbc_dir_norm
cbc_loc = cbc_loc_norm
$:GPU_UPDATE(device='[cbc_dir, cbc_loc]')
call s_initialize_cbc(q_prim_vf, flux_vf, flux_src_vf, &
ix, iy, iz)
call s_associate_cbc_coefficients_pointers(cbc_dir, cbc_loc)
#:for CBC_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')]
if (cbc_dir == ${CBC_DIR}$ .and. recon_type == WENO_TYPE) then
! PI2 of flux_rs_vf and flux_src_rs_vf at j = 1/2
if (weno_order == 3 .or. dummy) then
call s_convert_primitive_to_flux_variables(q_prim_rs${XYZ}$_vf, &
F_rs${XYZ}$_vf, &
F_src_rs${XYZ}$_vf, &
is1, is2, is3, idwbuff(2)%beg, idwbuff(3)%beg)
$:GPU_PARALLEL_LOOP(private='[i,r,k]', collapse=3)
do i = 1, flux_cbc_index
do r = is3%beg, is3%end
do k = is2%beg, is2%end
flux_rs${XYZ}$_vf_l(0, k, r, i) = F_rs${XYZ}$_vf(0, k, r, i) &
+ pi_coef_${XYZ}$ (0, 0, cbc_loc)* &
(F_rs${XYZ}$_vf(1, k, r, i) - &
F_rs${XYZ}$_vf(0, k, r, i))
end do
end do
end do
$:END_GPU_PARALLEL_LOOP()
$:GPU_PARALLEL_LOOP(private='[i,r,k]', collapse=3)
do i = advxb, advxe
do r = is3%beg, is3%end
do k = is2%beg, is2%end
flux_src_rs${XYZ}$_vf_l(0, k, r, i) = F_src_rs${XYZ}$_vf(0, k, r, i) + &
(F_src_rs${XYZ}$_vf(1, k, r, i) - &
F_src_rs${XYZ}$_vf(0, k, r, i)) &
*pi_coef_${XYZ}$ (0, 0, cbc_loc)
end do
end do
end do
$:END_GPU_PARALLEL_LOOP()
end if
! PI4 of flux_rs_vf and flux_src_rs_vf at j = 1/2, 3/2
if (weno_order == 5 .or. dummy) then
call s_convert_primitive_to_flux_variables(q_prim_rs${XYZ}$_vf, &
F_rs${XYZ}$_vf, &
F_src_rs${XYZ}$_vf, &
is1, is2, is3, idwbuff(2)%beg, idwbuff(3)%beg)
$:GPU_PARALLEL_LOOP(private='[i,j,r,k]', collapse=4)
do i = 1, flux_cbc_index
do j = 0, 1
do r = is3%beg, is3%end
do k = is2%beg, is2%end
flux_rs${XYZ}$_vf_l(j, k, r, i) = F_rs${XYZ}$_vf(j, k, r, i) &
+ pi_coef_${XYZ}$ (j, 0, cbc_loc)* &
(F_rs${XYZ}$_vf(3, k, r, i) - &
F_rs${XYZ}$_vf(2, k, r, i)) &
+ pi_coef_${XYZ}$ (j, 1, cbc_loc)* &
(F_rs${XYZ}$_vf(2, k, r, i) - &
F_rs${XYZ}$_vf(1, k, r, i)) &
+ pi_coef_${XYZ}$ (j, 2, cbc_loc)* &
(F_rs${XYZ}$_vf(1, k, r, i) - &
F_rs${XYZ}$_vf(0, k, r, i))
end do
end do
end do
end do
$:END_GPU_PARALLEL_LOOP()
$:GPU_PARALLEL_LOOP(private='[i,j,r,k]', collapse=4)
do i = advxb, advxe
do j = 0, 1
do r = is3%beg, is3%end
do k = is2%beg, is2%end
flux_src_rs${XYZ}$_vf_l(j, k, r, i) = F_src_rs${XYZ}$_vf(j, k, r, i) + &
(F_src_rs${XYZ}$_vf(3, k, r, i) - &
F_src_rs${XYZ}$_vf(2, k, r, i)) &
*pi_coef_${XYZ}$ (j, 0, cbc_loc) + &
(F_src_rs${XYZ}$_vf(2, k, r, i) - &
F_src_rs${XYZ}$_vf(1, k, r, i)) &
*pi_coef_${XYZ}$ (j, 1, cbc_loc) + &
(F_src_rs${XYZ}$_vf(1, k, r, i) - &
F_src_rs${XYZ}$_vf(0, k, r, i)) &
*pi_coef_${XYZ}$ (j, 2, cbc_loc)
end do
end do
end do
end do
$:END_GPU_PARALLEL_LOOP()
end if
! FD2 or FD4 of RHS at j = 0
$:GPU_PARALLEL_LOOP(collapse=2, private='[r,k,alpha_rho, vel, adv_local, mf, dvel_ds, dadv_ds, Re_cbc, dalpha_rho_ds, dpres_ds, dvel_dt, dadv_dt, dalpha_rho_dt, L, lambda, Ys, dYs_dt, dYs_ds, h_k, Cp_i, Gamma_i, Xs, drho_dt, dpres_dt, dpi_inf_dt, dqv_dt, dgamma_dt, rho, pres, E, H, gamma, pi_inf, qv, c, Ma, T, sum_Enthalpies, Cv, Cp, e_mix, Mw, R_gas, vel_K_sum, vel_dv_dt_sum, i, j]', copyin='[dir_idx]')
do r = is3%beg, is3%end
do k = is2%beg, is2%end
! Transferring the Primitive Variables
$:GPU_LOOP(parallelism='[seq]')
do i = 1, contxe
alpha_rho(i) = q_prim_rs${XYZ}$_vf(0, k, r, i)
end do
$:GPU_LOOP(parallelism='[seq]')
do i = 1, num_dims
vel(i) = q_prim_rs${XYZ}$_vf(0, k, r, contxe + i)
end do
vel_K_sum = 0._wp
$:GPU_LOOP(parallelism='[seq]')
do i = 1, num_dims
vel_K_sum = vel_K_sum + vel(i)**2._wp
end do
pres = q_prim_rs${XYZ}$_vf(0, k, r, E_idx)
$:GPU_LOOP(parallelism='[seq]')
do i = 1, advxe - E_idx
adv_local(i) = q_prim_rs${XYZ}$_vf(0, k, r, E_idx + i)
end do
call s_convert_species_to_mixture_variables_acc(rho, gamma, pi_inf, qv, adv_local, alpha_rho, Re_cbc)
$:GPU_LOOP(parallelism='[seq]')
do i = 1, contxe
mf(i) = alpha_rho(i)/rho
end do
if (chemistry) then
$:GPU_LOOP(parallelism='[seq]')
do i = chemxb, chemxe
Ys(i - chemxb + 1) = q_prim_rs${XYZ}$_vf(0, k, r, i)
end do
call get_mixture_molecular_weight(Ys, Mw)
R_gas = gas_constant/Mw
T = pres/rho/R_gas
call get_mixture_specific_heat_cp_mass(T, Ys, Cp)
call get_mixture_energy_mass(T, Ys, e_mix)
E = rho*e_mix + 5.e-1_wp*rho*vel_K_sum
if (chem_params%gamma_method == 1) then
!> gamma_method = 1: Ref. Section 2.3.1 Formulation of doi:10.7907/ZKW8-ES97.
call get_mole_fractions(Mw, Ys, Xs)
call get_species_specific_heats_r(T, Cp_i)
Gamma_i = Cp_i/(Cp_i - 1.0_wp)
gamma = sum(Xs(:)/(Gamma_i(:) - 1.0_wp))
else if (chem_params%gamma_method == 2) then
!> gamma_method = 2: c_p / c_v where c_p, c_v are specific heats.
call get_mixture_specific_heat_cv_mass(T, Ys, Cv)
gamma = 1.0_wp/(Cp/Cv - 1.0_wp)
end if
else
E = gamma*pres + pi_inf + 5.e-1_wp*rho*vel_K_sum
end if
H = (E + pres)/rho
! Compute mixture sound speed
call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, H, adv_local, vel_K_sum, 0._wp, c, qv)
! First-Order Spatial Derivatives of Primitive Variables
$:GPU_LOOP(parallelism='[seq]')
do i = 1, contxe
dalpha_rho_ds(i) = 0._wp
end do
$:GPU_LOOP(parallelism='[seq]')
do i = 1, num_dims
dvel_ds(i) = 0._wp
end do
dpres_ds = 0._wp
$:GPU_LOOP(parallelism='[seq]')
do i = 1, advxe - E_idx
dadv_ds(i) = 0._wp
end do
if (chemistry) then
$:GPU_LOOP(parallelism='[seq]')
do i = 1, num_species
dYs_ds(i) = 0._wp
end do
end if
$:GPU_LOOP(parallelism='[seq]')
do j = 0, buff_size
$:GPU_LOOP(parallelism='[seq]')
do i = 1, contxe
dalpha_rho_ds(i) = q_prim_rs${XYZ}$_vf(j, k, r, i)* &
fd_coef_${XYZ}$ (j, cbc_loc) + &
dalpha_rho_ds(i)
end do
$:GPU_LOOP(parallelism='[seq]')
do i = 1, num_dims
dvel_ds(i) = q_prim_rs${XYZ}$_vf(j, k, r, contxe + i)* &
fd_coef_${XYZ}$ (j, cbc_loc) + &
dvel_ds(i)
end do
dpres_ds = q_prim_rs${XYZ}$_vf(j, k, r, E_idx)* &
fd_coef_${XYZ}$ (j, cbc_loc) + &
dpres_ds
$:GPU_LOOP(parallelism='[seq]')
do i = 1, advxe - E_idx
dadv_ds(i) = q_prim_rs${XYZ}$_vf(j, k, r, E_idx + i)* &
fd_coef_${XYZ}$ (j, cbc_loc) + &
dadv_ds(i)
end do
if (chemistry) then
$:GPU_LOOP(parallelism='[seq]')
do i = 1, num_species
dYs_ds(i) = q_prim_rs${XYZ}$_vf(j, k, r, chemxb - 1 + i)* &
fd_coef_${XYZ}$ (j, cbc_loc) + &
dYs_ds(i)
end do
end if
end do
! First-Order Temporal Derivatives of Primitive Variables
lambda(1) = vel(dir_idx(1)) - c
lambda(2) = vel(dir_idx(1))
lambda(3) = vel(dir_idx(1)) + c
Ma = vel(dir_idx(1))/c
if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_SLIP_WALL) .or. &
(cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_SLIP_WALL)) then
call s_compute_slip_wall_L(lambda, L, rho, c, dpres_ds, dvel_ds)
else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_NR_SUB_BUFFER) .or. &
(cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_NR_SUB_BUFFER)) then
call s_compute_nonreflecting_subsonic_buffer_L(lambda, L, rho, c, mf, dalpha_rho_ds, dpres_ds, dvel_ds, dadv_ds, dYs_ds)
else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_NR_SUB_INFLOW) .or. &
(cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_NR_SUB_INFLOW)) then
call s_compute_nonreflecting_subsonic_inflow_L(lambda, L, rho, c, dpres_ds, dvel_ds)
! Add GRCBC for Subsonic Inflow
if (bc_${XYZ}$%grcbc_in) then
$:GPU_LOOP(parallelism='[seq]')
do i = 2, momxb
L(i) = c**3._wp*Ma*(alpha_rho(i - 1) - alpha_rho_in(i - 1, ${CBC_DIR}$))/Del_in(${CBC_DIR}$) - c*Ma*(pres - pres_in(${CBC_DIR}$))/Del_in(${CBC_DIR}$)
end do
if (n > 0) then
L(momxb + 1) = c*Ma*(vel(dir_idx(2)) - vel_in(${CBC_DIR}$, dir_idx(2)))/Del_in(${CBC_DIR}$)
if (p > 0) then
L(momxb + 2) = c*Ma*(vel(dir_idx(3)) - vel_in(${CBC_DIR}$, dir_idx(3)))/Del_in(${CBC_DIR}$)
end if
end if
$:GPU_LOOP(parallelism='[seq]')
do i = E_idx, advxe - 1
L(i) = c*Ma*(adv_local(i + 1 - E_idx) - alpha_in(i + 1 - E_idx, ${CBC_DIR}$))/Del_in(${CBC_DIR}$)
end do
L(advxe) = rho*c**2._wp*(1._wp + Ma)*(vel(dir_idx(1)) + vel_in(${CBC_DIR}$, dir_idx(1))*sign(1, cbc_loc))/Del_in(${CBC_DIR}$) + c*(1._wp + Ma)*(pres - pres_in(${CBC_DIR}$))/Del_in(${CBC_DIR}$)
end if
else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_NR_SUB_OUTFLOW) .or. &
(cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_NR_SUB_OUTFLOW)) then
call s_compute_nonreflecting_subsonic_outflow_L(lambda, L, rho, c, mf, dalpha_rho_ds, dpres_ds, dvel_ds, dadv_ds, dYs_ds)
! Add GRCBC for Subsonic Outflow (Pressure)
if (bc_${XYZ}$%grcbc_out) then
L(advxe) = c*(1._wp - Ma)*(pres - pres_out(${CBC_DIR}$))/Del_out(${CBC_DIR}$)
! Add GRCBC for Subsonic Outflow (Normal Velocity)
if (bc_${XYZ}$%grcbc_vel_out) then
L(advxe) = L(advxe) + rho*c**2._wp*(1._wp - Ma)*(vel(dir_idx(1)) + vel_out(${CBC_DIR}$, dir_idx(1))*sign(1, cbc_loc))/Del_out(${CBC_DIR}$)
end if
end if
else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_FF_SUB_OUTFLOW) .or. &
(cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_FF_SUB_OUTFLOW)) then
call s_compute_force_free_subsonic_outflow_L(lambda, L, rho, c, mf, dalpha_rho_ds, dpres_ds, dvel_ds, dadv_ds)
else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_CP_SUB_OUTFLOW) .or. &
(cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_CP_SUB_OUTFLOW)) then
call s_compute_constant_pressure_subsonic_outflow_L(lambda, L, rho, c, mf, dalpha_rho_ds, dpres_ds, dvel_ds, dadv_ds)
else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_SUP_INFLOW) .or. &
(cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_SUP_INFLOW)) then
call s_compute_supersonic_inflow_L(L)
else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_SUP_OUTFLOW) .or. &
(cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_SUP_OUTFLOW)) then
call s_compute_supersonic_outflow_L(lambda, L, rho, c, mf, dalpha_rho_ds, dpres_ds, dvel_ds, dadv_ds, dYs_ds)
end if
! Be careful about the cylindrical coordinate!
if (cyl_coord .and. cbc_dir == 2 .and. cbc_loc == 1) then
dpres_dt = -5.e-1_wp*(L(advxe) + L(1)) + rho*c*c*vel(dir_idx(1)) &
/y_cc(n)
else
dpres_dt = -5.e-1_wp*(L(advxe) + L(1))
end if
$:GPU_LOOP(parallelism='[seq]')
do i = 1, contxe
dalpha_rho_dt(i) = &
-(L(i + 1) - mf(i)*dpres_dt)/(c*c)
end do
$:GPU_LOOP(parallelism='[seq]')
do i = 1, num_dims
dvel_dt(dir_idx(i)) = dir_flg(dir_idx(i))* &
(L(1) - L(advxe))/(2._wp*rho*c) + &
(dir_flg(dir_idx(i)) - 1._wp)* &
L(momxb + i - 1)
end do
vel_dv_dt_sum = 0._wp
$:GPU_LOOP(parallelism='[seq]')
do i = 1, num_dims
vel_dv_dt_sum = vel_dv_dt_sum + vel(i)*dvel_dt(i)
end do