Skip to content

Commit ffce00e

Browse files
authored
Fix Chemistry advection fluxes (#752)
1 parent 3116b34 commit ffce00e

File tree

18 files changed

+81
-1045
lines changed

18 files changed

+81
-1045
lines changed

examples/nD_perfect_reactor/case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
sol.TPX = 1_600, ct.one_atm, 'H2:0.04, O2:0.02, AR:0.94'
2828

29-
Nx = 25 * args.scale
29+
Nx = int(25 * args.scale)
3030
Tend = 1e-4
3131
s = 1e-2
3232
dt = 1e-7

src/common/m_variables_conversion.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module m_variables_conversion
2323
use m_helper
2424

2525
use m_thermochem, only: &
26-
num_species, get_temperature, get_pressure, &
26+
num_species, get_temperature, get_pressure, gas_constant, &
2727
get_mixture_molecular_weight, get_mixture_energy_mass
2828

2929
! ==========================================================================
@@ -1114,7 +1114,7 @@ contains
11141114
end do
11151115

11161116
call get_mixture_molecular_weight(Ys, mix_mol_weight)
1117-
T = q_prim_vf(T_idx)%sf(j, k, l)
1117+
T = q_prim_vf(E_idx)%sf(j, k, l)*mix_mol_weight/(gas_constant*rho)
11181118
call get_mixture_energy_mass(T, Ys, e_mix)
11191119

11201120
q_cons_vf(E_idx)%sf(j, k, l) = &

src/post_process/p_main.fpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ program p_main
4444

4545
! Time-Marching Loop =======================================================
4646
do
47+
! If all time-steps are not ready to be post-processed and one rank is
48+
! faster than another, the slower rank processing the last available
49+
! step might be killed when the faster rank attempts to process the
50+
! first missing step, before the slower rank finishes writing the last
51+
! available step. To avoid this, we force synchronization here.
52+
call s_mpi_barrier()
53+
4754
call s_perform_time_step(t_step)
4855

4956
call s_save_data(t_step, varname, pres, c, H)

src/simulation/m_chemistry.fpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -51,53 +51,6 @@ contains
5151

5252
end subroutine s_finalize_chemistry_module
5353

54-
subroutine s_compute_chemistry_advection_flux(flux_n, rhs_vf)
55-
56-
type(vector_field), dimension(:), intent(IN) :: flux_n
57-
type(scalar_field), dimension(sys_size), intent(INOUT) :: rhs_vf
58-
integer :: x, y, z
59-
integer :: eqn
60-
61-
real(kind(0d0)) :: flux_x, flux_y, flux_z
62-
63-
#:for num_dims in range(1, 4)
64-
if (num_dims == ${num_dims}$) then
65-
!$acc parallel loop collapse(4) gang vector default(present) &
66-
!$acc private(flux_x, flux_y, flux_z)
67-
do z = idwint(3)%beg, idwint(3)%end
68-
do y = idwint(2)%beg, idwint(2)%end
69-
do x = idwint(1)%beg, idwint(1)%end
70-
do eqn = chemxb, chemxe
71-
! \nabla \cdot (F)
72-
flux_x = (flux_n(1)%vf(eqn)%sf(x - 1, y, z) - &
73-
flux_n(1)%vf(eqn)%sf(x, y, z))/dx(x)
74-
75-
#:if num_dims >= 2
76-
flux_y = (flux_n(2)%vf(eqn)%sf(x, y - 1, z) - &
77-
flux_n(2)%vf(eqn)%sf(x, y, z))/dy(y)
78-
#:else
79-
flux_y = 0d0
80-
#:endif
81-
82-
#:if num_dims == 3
83-
flux_z = (flux_n(3)%vf(eqn)%sf(x, y, z - 1) - &
84-
flux_n(3)%vf(eqn)%sf(x, y, z))/dz(z)
85-
#:else
86-
flux_z = 0d0
87-
#:endif
88-
89-
rhs_vf(eqn)%sf(x, y, z) = flux_x + flux_y + flux_z
90-
end do
91-
92-
rhs_vf(T_idx)%sf(x, y, z) = 0d0
93-
end do
94-
end do
95-
end do
96-
end if
97-
#:endfor
98-
99-
end subroutine s_compute_chemistry_advection_flux
100-
10154
subroutine s_compute_chemistry_reaction_flux(rhs_vf, q_cons_qp, q_prim_qp)
10255

10356
type(scalar_field), dimension(sys_size), intent(INOUT) :: rhs_vf, q_cons_qp, q_prim_qp

src/simulation/m_rhs.fpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -860,12 +860,6 @@ contains
860860
end do
861861
! END: Dimensional Splitting Loop =================================
862862

863-
if (chemistry) then
864-
call nvtxStartRange("RHS-CHEM-ADVECTION")
865-
call s_compute_chemistry_advection_flux(flux_n, rhs_vf)
866-
call nvtxEndRange
867-
end if
868-
869863
if (ib) then
870864
!$acc parallel loop collapse(3) gang vector default(present)
871865
do l = 0, p
@@ -904,6 +898,10 @@ contains
904898
end if
905899

906900
if (chemistry) then
901+
!$acc kernels
902+
rhs_vf(T_idx)%sf(:, :, :) = 0d0
903+
!$acc end kernels
904+
907905
if (chem_params%reactions) then
908906
call nvtxStartRange("RHS-CHEM-REACTIONS")
909907
call s_compute_chemistry_reaction_flux(rhs_vf, q_cons_qp%vf, q_prim_qp%vf)

src/simulation/m_riemann_solvers.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,8 +797,8 @@ contains
797797
Y_L = qL_prim_rs${XYZ}$_vf(j, k, l, i)
798798
Y_R = qR_prim_rs${XYZ}$_vf(j + 1, k, l, i)
799799
800-
flux_rs${XYZ}$_vf(j, k, l, i) = (s_M*Y_R*rho_R*vel_R(dir_idx(norm_dir)) &
801-
- s_P*Y_L*rho_L*vel_L(dir_idx(norm_dir)) &
800+
flux_rs${XYZ}$_vf(j, k, l, i) = (s_M*Y_R*rho_R*vel_R(dir_idx(1)) &
801+
- s_P*Y_L*rho_L*vel_L(dir_idx(1)) &
802802
+ s_M*s_P*(Y_L*rho_L - Y_R*rho_R)) &
803803
/(s_M - s_P)
804804
flux_src_rs${XYZ}$_vf(j, k, l, i) = 0d0

tests/1550B67E/golden-metadata.txt

Lines changed: 2 additions & 134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)