Skip to content

Commit 841f863

Browse files
committed
Changes to through the code to make fluid variables uniform
The following PR comprises changes to the code in order to call fluid variables uniformly through the code. The main changes for this PR is to change all the fluid_pp(i)% to their respective, which are defined on src/common/m_variables_conversion.fpp. For instance, substituting fluid_pp(i)%pi_inf by pi_infs(i), and so on. In certain cases, variable indices are also replaced to be uniform The importance of this PR is that, if these variables change through the code for whatever reason, they will be followed through the rest of the code
1 parent 3668f05 commit 841f863

File tree

10 files changed

+54
-68
lines changed

10 files changed

+54
-68
lines changed

src/common/m_variables_conversion.fpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,8 +1306,7 @@ contains
13061306
elseif ((model_eqns /= 4) .and. (bubbles_euler .neqv. .true.)) then
13071307
! E = Gamma*P + \rho u u /2 + \pi_inf + (\alpha\rho qv)
13081308
q_cons_vf(E_idx)%sf(j, k, l) = &
1309-
gamma*q_prim_vf(E_idx)%sf(j, k, l) + dyn_pres + pi_inf &
1310-
+ qv
1309+
gamma*q_prim_vf(E_idx)%sf(j, k, l) + dyn_pres + pi_inf + qv
13111310
else if ((model_eqns /= 4) .and. (bubbles_euler)) then
13121311
! \tilde{E} = dyn_pres + (1-\alf)(\Gamma p_l + \Pi_inf)
13131312
q_cons_vf(E_idx)%sf(j, k, l) = dyn_pres + &
@@ -1323,11 +1322,9 @@ contains
13231322
if (model_eqns == 3) then
13241323
do i = 1, num_fluids
13251324
! internal energy calculation for each of the fluids
1326-
q_cons_vf(i + internalEnergies_idx%beg - 1)%sf(j, k, l) = &
1327-
q_cons_vf(i + adv_idx%beg - 1)%sf(j, k, l)* &
1328-
(fluid_pp(i)%gamma*q_prim_vf(E_idx)%sf(j, k, l) + &
1329-
fluid_pp(i)%pi_inf) + &
1330-
q_cons_vf(i + cont_idx%beg - 1)%sf(j, k, l)*fluid_pp(i)%qv
1325+
q_cons_vf(i + intxb - 1)%sf(j, k, l) = q_cons_vf(i + advxb - 1)%sf(j, k, l)* &
1326+
(gammas(i)*q_prim_vf(E_idx)%sf(j, k, l) + pi_infs(i)) + &
1327+
q_cons_vf(i + contxb - 1)%sf(j, k, l)*qvs(i)
13311328
end do
13321329
end if
13331330

@@ -1637,7 +1634,7 @@ contains
16371634
c = 0._wp
16381635
$:GPU_LOOP(parallelism='[seq]')
16391636
do q = 1, num_fluids
1640-
c = c + adv(q)*(1._wp/gammas(q) + 1._wp)* &
1637+
c = c + adv(q)*gs_min(q)* &
16411638
(pres + pi_infs(q)/(gammas(q) + 1._wp))
16421639
end do
16431640
c = c/rho

src/post_process/m_data_output.fpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ module m_data_output
2121

2222
use m_helper
2323

24+
use m_variables_conversion
25+
2426
implicit none
2527

2628
private; public :: s_initialize_data_output_module, &
@@ -1612,7 +1614,7 @@ contains
16121614
pi_inf = 0._wp
16131615
qv = 0._wp
16141616
pres = q_prim_vf(E_idx)%sf(i, j, k)
1615-
Egint = Egint + q_prim_vf(E_idx + 2)%sf(i, j, k)*(fluid_pp(2)%gamma*pres)*dV
1617+
Egint = Egint + q_prim_vf(E_idx + 2)%sf(i, j, k)*(gammas(2)*pres)*dV
16161618
do s = 1, num_vels
16171619
vel(s) = q_prim_vf(num_fluids + s)%sf(i, j, k)
16181620
Egk = Egk + 0.5_wp*q_prim_vf(E_idx + 2)%sf(i, j, k)*q_prim_vf(2)%sf(i, j, k)*vel(s)*vel(s)*dV
@@ -1623,10 +1625,10 @@ contains
16231625
end do
16241626
do l = 1, adv_idx%end - E_idx
16251627
adv(l) = q_prim_vf(E_idx + l)%sf(i, j, k)
1626-
gamma = gamma + adv(l)*fluid_pp(l)%gamma
1627-
pi_inf = pi_inf + adv(l)*fluid_pp(l)%pi_inf
1628+
gamma = gamma + adv(l)*gammas(l)
1629+
pi_inf = pi_inf + adv(l)*pi_infs(l)
16281630
rho = rho + adv(l)*q_prim_vf(l)%sf(i, j, k)
1629-
qv = qv + adv(l)*q_prim_vf(l)%sf(i, j, k)*fluid_pp(l)%qv
1631+
qv = qv + adv(l)*q_prim_vf(l)%sf(i, j, k)*qvs(l)
16301632
end do
16311633
16321634
H = ((gamma + 1._wp)*pres + pi_inf + qv)/rho

src/post_process/m_derived_variables.fpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ contains
204204
pi_inf_sf(i, j, k))/(gamma_sf(i, j, k)* &
205205
rho_sf(i, j, k)))
206206
else
207-
blkmod1 = ((fluid_pp(1)%gamma + 1._wp)*q_prim_vf(E_idx)%sf(i, j, k) + &
208-
fluid_pp(1)%pi_inf)/fluid_pp(1)%gamma
209-
blkmod2 = ((fluid_pp(2)%gamma + 1._wp)*q_prim_vf(E_idx)%sf(i, j, k) + &
210-
fluid_pp(2)%pi_inf)/fluid_pp(2)%gamma
207+
blkmod1 = ((gammas(1) + 1._wp)*q_prim_vf(E_idx)%sf(i, j, k) + &
208+
pi_infs(1))/gammas(1)
209+
blkmod2 = ((gammas(2) + 1._wp)*q_prim_vf(E_idx)%sf(i, j, k) + &
210+
pi_infs(2))/gammas(2)
211211
q_sf(i, j, k) = (1._wp/(rho_sf(i, j, k)*(q_prim_vf(adv_idx%beg)%sf(i, j, k)/blkmod1 + &
212212
(1._wp - q_prim_vf(adv_idx%beg)%sf(i, j, k))/blkmod2)))
213213
end if

src/pre_process/m_assign_variables.fpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ contains
213213
p0 = 101325._wp
214214
pres_mag = 1.e-1_wp
215215
loc = x_cc(177)
216-
n_tait = fluid_pp(1)%gamma
217-
B_tait = fluid_pp(1)%pi_inf
216+
n_tait = gs_min(1)
217+
B_tait = pi_infs(1)
218218
219219
n_tait = 1._wp/n_tait + 1._wp
220220
B_tait = B_tait*(n_tait - 1._wp)/n_tait
@@ -563,9 +563,9 @@ contains
563563
end do
564564
else
565565
!get mixture density from pressure via Tait EOS
566-
pi_inf = fluid_pp(1)%pi_inf
567-
gamma = fluid_pp(1)%gamma
568-
lit_gamma = (1._wp + gamma)/gamma
566+
pi_inf = pi_infs(1)
567+
gamma = gammas(1)
568+
lit_gamma = gs_min(1)
569569
570570
! \rho = (( p_l + pi_inf)/( p_ref + pi_inf))**(1/little_gam) * rhoref(1-alf)
571571
q_prim_vf(1)%sf(j, k, l) = &

src/pre_process/m_data_output.fpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ contains
273273
end do
274274
end if
275275

276-
gamma = fluid_pp(1)%gamma
277-
lit_gamma = 1._wp/fluid_pp(1)%gamma + 1._wp
278-
pi_inf = fluid_pp(1)%pi_inf
279-
qv = fluid_pp(1)%qv
276+
gamma = gammas(1)
277+
lit_gamma = gs_min(1)
278+
pi_inf = pi_infs(1)
279+
qv = qvs(1)
280280

281281
if (precision == 1) then
282282
FMT = "(2F30.3)"

src/pre_process/m_icpp_patches.fpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ module m_icpp_patches
3131

3232
use m_ib_patches
3333

34+
use m_variables_conversion
35+
3436
implicit none
3537

3638
private; public :: s_apply_icpp_patches
@@ -210,9 +212,9 @@ contains
210212
@:HardcodedDimensionsExtrusion()
211213
@:Hardcoded1DVariables()
212214

213-
pi_inf = fluid_pp(1)%pi_inf
214-
gamma = fluid_pp(1)%gamma
215-
lit_gamma = (1._wp + gamma)/gamma
215+
pi_inf = pi_infs(1)
216+
gamma = gammas(1)
217+
lit_gamma = gs_min(1)
216218
j = 0
217219
k = 0
218220

@@ -748,9 +750,9 @@ contains
748750
@:HardcodedDimensionsExtrusion()
749751
@:Hardcoded2DVariables()
750752

751-
pi_inf = fluid_pp(1)%pi_inf
752-
gamma = fluid_pp(1)%gamma
753-
lit_gamma = (1._wp + gamma)/gamma
753+
pi_inf = pi_infs(1)
754+
gamma = gammas(1)
755+
lit_gamma = gs_min(1)
754756

755757
! Transferring the rectangle's centroid and length information
756758
x_centroid = patch_icpp(patch_id)%x_centroid
@@ -797,7 +799,7 @@ contains
797799
!zero density, reassign according to Tait EOS
798800
q_prim_vf(1)%sf(i, j, 0) = &
799801
(((q_prim_vf(E_idx)%sf(i, j, 0) + pi_inf)/(pref + pi_inf))**(1._wp/lit_gamma))* &
800-
rhoref*(1._wp - q_prim_vf(alf_idx)%sf(i, j, 0))
802+
(1._wp - q_prim_vf(alf_idx)%sf(i, j, 0))
801803
end if
802804
803805
! Updating the patch identities bookkeeping variable
@@ -911,9 +913,9 @@ contains
911913
@:HardcodedDimensionsExtrusion()
912914
@:Hardcoded2DVariables()
913915

914-
pi_inf = fluid_pp(1)%pi_inf
915-
gamma = fluid_pp(1)%gamma
916-
lit_gamma = (1._wp + gamma)/gamma
916+
pi_inf = pi_infs(1)
917+
gamma = gammas(1)
918+
lit_gamma = gs_min(1)
917919

918920
! Transferring the patch's centroid and length information
919921
x_centroid = patch_icpp(patch_id)%x_centroid
@@ -997,9 +999,9 @@ contains
997999
@:HardcodedDimensionsExtrusion()
9981000
@:Hardcoded1DVariables()
9991001

1000-
pi_inf = fluid_pp(1)%pi_inf
1001-
gamma = fluid_pp(1)%gamma
1002-
lit_gamma = (1._wp + gamma)/gamma
1002+
pi_inf = pi_infs(1)
1003+
gamma = gammas(1)
1004+
lit_gamma = gs_min(1)
10031005

10041006
! Transferring the patch's centroid and length information
10051007
x_centroid = patch_icpp(patch_id)%x_centroid

src/simulation/m_data_output.fpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ contains
507507
write (2) ib_markers%sf(0:m, 0:n, 0:p); close (2)
508508
end if
509509

510-
gamma = fluid_pp(1)%gamma
511-
lit_gamma = 1._wp/fluid_pp(1)%gamma + 1._wp
512-
pi_inf = fluid_pp(1)%pi_inf
513-
qv = fluid_pp(1)%qv
510+
gamma = gammas(1)
511+
lit_gamma = gs_min(1)
512+
pi_inf = pi_infs(1)
513+
qv = qvs(1)
514514

515515
if (precision == 1) then
516516
FMT = "(2F30.3)"
@@ -1239,7 +1239,7 @@ contains
12391239
end if
12401240

12411241
if (model_eqns == 4) then
1242-
lit_gamma = 1._wp/fluid_pp(1)%gamma + 1._wp
1242+
lit_gamma = gammas(1)
12431243
else if (elasticity) then
12441244
tau_e(1) = q_cons_vf(stress_idx%end)%sf(j - 2, k, l)/rho
12451245
end if
@@ -1353,7 +1353,7 @@ contains
13531353
end if
13541354

13551355
if (model_eqns == 4) then
1356-
lit_gamma = 1._wp/fluid_pp(1)%gamma + 1._wp
1356+
lit_gamma = gs_min(1)
13571357
else if (elasticity) then
13581358
do s = 1, 3
13591359
tau_e(s) = q_cons_vf(s)%sf(j - 2, k - 2, l)/rho

src/simulation/m_global_parameters.fpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,8 +943,6 @@ contains
943943
end if
944944
end if
945945
sys_size = bub_idx%end
946-
! print*, 'alf idx', alf_idx
947-
! print*, 'bub -idx beg end', bub_idx%beg, bub_idx%end
948946
949947
if (adv_n) then
950948
n_idx = bub_idx%end + 1

src/simulation/m_pressure_relaxation.fpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ module m_pressure_relaxation
2020
s_initialize_pressure_relaxation_module, &
2121
s_finalize_pressure_relaxation_module
2222

23-
real(wp), allocatable, dimension(:) :: gamma_min, pres_inf
24-
$:GPU_DECLARE(create='[gamma_min, pres_inf]')
25-
2623
real(wp), allocatable, dimension(:, :) :: Res_pr
2724
$:GPU_DECLARE(create='[Res_pr]')
2825

@@ -33,14 +30,6 @@ contains
3330

3431
integer :: i, j
3532

36-
@:ALLOCATE(gamma_min(1:num_fluids), pres_inf(1:num_fluids))
37-
38-
do i = 1, num_fluids
39-
gamma_min(i) = 1._wp/fluid_pp(i)%gamma + 1._wp
40-
pres_inf(i) = fluid_pp(i)%pi_inf/(1._wp + fluid_pp(i)%gamma)
41-
end do
42-
$:GPU_UPDATE(device='[gamma_min, pres_inf]')
43-
4433
if (viscous) then
4534
@:ALLOCATE(Res_pr(1:2, 1:Re_size_max))
4635
do i = 1, 2
@@ -56,7 +45,6 @@ contains
5645
!> Finalize the pressure relaxation module
5746
impure subroutine s_finalize_pressure_relaxation_module
5847

59-
@:DEALLOCATE(gamma_min, pres_inf)
6048
if (viscous) then
6149
@:DEALLOCATE(Res_pr)
6250
end if
@@ -170,8 +158,8 @@ contains
170158
if (q_cons_vf(i + advxb - 1)%sf(j, k, l) > sgm_eps) then
171159
pres_K_init(i) = (q_cons_vf(i + intxb - 1)%sf(j, k, l)/ &
172160
q_cons_vf(i + advxb - 1)%sf(j, k, l) - pi_infs(i))/gammas(i)
173-
if (pres_K_init(i) <= -(1._wp - 1.e-8_wp)*pres_inf(i) + 1.e-8_wp) &
174-
pres_K_init(i) = -(1._wp - 1.e-8_wp)*pres_inf(i) + 1.e-8_wp
161+
if (pres_K_init(i) <= -(1._wp - 1.e-8_wp)*ps_inf(i) + 1.e-8_wp) &
162+
pres_K_init(i) = -(1._wp - 1.e-8_wp)*ps_inf(i) + 1.e-8_wp
175163
else
176164
pres_K_init(i) = 0._wp
177165
end if
@@ -188,8 +176,8 @@ contains
188176

189177
! Enforce pressure bounds
190178
do i = 1, num_fluids
191-
if (pres_relax <= -(1._wp - 1.e-8_wp)*pres_inf(i) + 1.e-8_wp) &
192-
pres_relax = -(1._wp - 1.e-8_wp)*pres_inf(i) + 1._wp
179+
if (pres_relax <= -(1._wp - 1.e-8_wp)*ps_inf(i) + 1.e-8_wp) &
180+
pres_relax = -(1._wp - 1.e-8_wp)*ps_inf(i) + 1._wp
193181
end do
194182

195183
! Newton-Raphson step
@@ -200,11 +188,11 @@ contains
200188
if (q_cons_vf(i + advxb - 1)%sf(j, k, l) > sgm_eps) then
201189
rho_K_s(i) = q_cons_vf(i + contxb - 1)%sf(j, k, l)/ &
202190
max(q_cons_vf(i + advxb - 1)%sf(j, k, l), sgm_eps) &
203-
*((pres_relax + pres_inf(i))/(pres_K_init(i) + &
204-
pres_inf(i)))**(1._wp/gamma_min(i))
191+
*((pres_relax + ps_inf(i))/(pres_K_init(i) + &
192+
ps_inf(i)))**(1._wp/gs_min(i))
205193
f_pres = f_pres + q_cons_vf(i + contxb - 1)%sf(j, k, l)/rho_K_s(i)
206194
df_pres = df_pres - q_cons_vf(i + contxb - 1)%sf(j, k, l) &
207-
/(gamma_min(i)*rho_K_s(i)*(pres_relax + pres_inf(i)))
195+
/(gs_min(i)*rho_K_s(i)*(pres_relax + ps_inf(i)))
208196
end if
209197
end do
210198
end if

src/simulation/m_start_up.fpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,9 +1052,8 @@ contains
10521052
dyn_pres, pi_inf, gamma, rho, qv, rhoYks, pres, T, pres_mag=pres_mag)
10531053

10541054
do i = 1, num_fluids
1055-
v_vf(i + internalEnergies_idx%beg - 1)%sf(j, k, l) = v_vf(i + adv_idx%beg - 1)%sf(j, k, l)* &
1056-
(fluid_pp(i)%gamma*pres + fluid_pp(i)%pi_inf) &
1057-
+ v_vf(i + cont_idx%beg - 1)%sf(j, k, l)*fluid_pp(i)%qv
1055+
v_vf(i + intxb - 1)%sf(j, k, l) = v_vf(i + advxb - 1)%sf(j, k, l)*(gammas(i)*pres + pi_infs(i)) &
1056+
+ v_vf(i + contxb - 1)%sf(j, k, l)*qvs(i)
10581057
end do
10591058

10601059
end do

0 commit comments

Comments
 (0)