Skip to content

Commit 4bc84e7

Browse files
committed
Privatize c_sum_Yi_Phi in the pure-fluid HLLC kernel, and evaluate the JWL and Vinet isentrope in closed form
1 parent 9e06c61 commit 4bc84e7

6 files changed

Lines changed: 81 additions & 55 deletions

File tree

src/common/m_variables_conversion.fpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,20 @@ contains
14211421

14221422
end function f_is_state_dependent
14231423

1424+
!> True when fluid i's reference curve is itself an isentrope (de_ref = -p_ref d(1/rho), which holds for JWL and Vinet but not
1425+
!! for the Mie-Gruneisen Hugoniot) and its Gruneisen coefficient is constant. Those two together make the isentrope through any
1426+
!! state closed-form, so it never has to be integrated.
1427+
function f_has_isentropic_reference(i) result(yes)
1428+
1429+
$:GPU_ROUTINE(function_name='f_has_isentropic_reference', parallelism='[seq]', cray_inline=True)
1430+
1431+
integer, intent(in) :: i
1432+
logical :: yes
1433+
1434+
yes = (eoss(i) == eos_jwl .or. eoss(i) == eos_vinet) .and. gruneisen_as(i) == 0._wp
1435+
1436+
end function f_has_isentropic_reference
1437+
14241438
!> Gamma, Pi, dPi/drho and dGamma/drho of fluid i at density rho, the coefficients of rho e = Gamma p + Pi(rho). Stiffened and
14251439
!! ideal gas keep the constants resolved at init, bit for bit.
14261440
subroutine s_eos_coefficients(rho, i, gamma, pi_inf, dpi, dgamma)
@@ -1588,11 +1602,19 @@ contains
15881602
real(wp), intent(in) :: pres, rho, xi
15891603
integer, intent(in) :: i
15901604
real(wp), intent(out) :: p_isen
1605+
real(wp) :: p_ref_from, p_ref_to, e_ref, dp_drho, de_drho, G0, dG0
15911606

1592-
if (f_is_state_dependent(i)) then
1593-
call s_rk4(ode_isentrope, i, rho, pres, xi*rho, p_isen)
1594-
else
1607+
if (.not. f_is_state_dependent(i)) then
15951608
p_isen = (pres + isentrope_B(i))*xi**isentrope_n(i) - isentrope_B(i)
1609+
else if (f_has_isentropic_reference(i)) then
1610+
! Exact: the offset from an isentropic reference obeys dDelta/Delta = Gamma drho/rho, so
1611+
! p - p_ref scales as (rho'/rho)**(1 + Gamma). Integrating it instead costs a decimal per
1612+
! doubling of the expansion and turns the pressure negative past roughly twentyfold.
1613+
call s_reference_curve(rho, i, p_ref_from, e_ref, dp_drho, de_drho, G0, dG0)
1614+
call s_reference_curve(xi*rho, i, p_ref_to, e_ref, dp_drho, de_drho, G0, dG0)
1615+
p_isen = p_ref_to + (pres - p_ref_from)*xi**(1._wp + gruneisen0s(i))
1616+
else
1617+
call s_rk4(ode_isentrope, i, rho, pres, xi*rho, p_isen)
15961618
end if
15971619
15981620
end subroutine s_phase_pressure_on_isentrope

src/simulation/m_pressure_relaxation.fpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ contains
194194
end if
195195
end do
196196

197+
! A solve that ran out of iterations leaves rho_K_s holding whatever the last iterate produced, and writing
198+
! that into the volume fractions is how one bad cell becomes a NaN a few steps later. Leave the cell
199+
! unrelaxed instead. Written as .not. (<=) so a NaN residual takes the same path as a diverged one.
200+
if (.not. (abs(f_pres) <= TOLERANCE)) return
201+
197202
! Update volume fractions
198203
$:GPU_LOOP(parallelism='[seq]')
199204
do i = 1, num_fluids

src/simulation/m_riemann_solver_hllc.fpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,10 @@ contains
857857
#:set _hllc_p3 = 'F_HLL, u_n_HLL_trace, u_t_HLL_trace, u_t2_HLL_trace, p_face_HLL, tau_qq_face_HLL, tau_nn_HLL, phi, Sigma_L, Sigma_R, dSigma, Sigma_ref, a_L_ref, a_R_ref, a_ref, du_t, dtau_nt, du_t2, dtau_nt2, sensor_ptot, sensor_vt, sensor_tnt, sensor_combined, idx_phys]'
858858
#:set _hllc_priv = _hllc_p1 + _hllc_p2 + _hllc_p3
859859
#:else
860-
! Master's pure-fluid private list, unchanged
861-
#:set _hllc_priv = '[i, T_L, T_R, vel_L_rms, vel_R_rms, pres_L, pres_R, rho_L, gamma_L, pi_inf_L, qv_L, rho_R, gamma_R, pi_inf_R, qv_R, alpha_L_sum, alpha_R_sum, E_L, E_R, MW_L, MW_R, R_gas_L, R_gas_R, Cp_L, Cp_R, Cv_L, Cv_R, Gamm_L, Gamm_R, Y_L, Y_R, H_L, H_R, qv_avg, rho_avg, gamma_avg, H_avg, c_L, c_R, c_avg, s_P, s_M, xi_P, xi_M, xi_L, xi_R, xi_L_m1, xi_R_m1, Ms_L, Ms_R, pres_SL, pres_SR, vel_L, vel_R, Re_L, Re_R, alpha_L, alpha_R, alpha_rho_L, alpha_rho_R, alpha_lim_L, alpha_lim_R, s_L, s_R, s_S, vel_avg_rms, pcorr, Ys_L, Ys_R, Xs_L, Xs_R, Gamma_iL, Gamma_iR, Cp_iL, Cp_iR, R_species, h_iL, h_iR]'
860+
! c_sum_Yi_Phi is written by the chemistry block inside this kernel, so it has to be
861+
! private here as it already is in the hypoelastic list above. Shared, every thread wrote
862+
! the same scalar and the reacting Roe sound speed came out different run to run.
863+
#:set _hllc_priv = '[i, T_L, T_R, vel_L_rms, vel_R_rms, pres_L, pres_R, rho_L, gamma_L, pi_inf_L, qv_L, rho_R, gamma_R, pi_inf_R, qv_R, alpha_L_sum, alpha_R_sum, E_L, E_R, MW_L, MW_R, R_gas_L, R_gas_R, Cp_L, Cp_R, Cv_L, Cv_R, c_sum_Yi_Phi, Gamm_L, Gamm_R, Y_L, Y_R, H_L, H_R, qv_avg, rho_avg, gamma_avg, H_avg, c_L, c_R, c_avg, s_P, s_M, xi_P, xi_M, xi_L, xi_R, xi_L_m1, xi_R_m1, Ms_L, Ms_R, pres_SL, pres_SR, vel_L, vel_R, Re_L, Re_R, alpha_L, alpha_R, alpha_rho_L, alpha_rho_R, alpha_lim_L, alpha_lim_R, s_L, s_R, s_S, vel_avg_rms, pcorr, Ys_L, Ys_R, Xs_L, Xs_R, Gamma_iL, Gamma_iR, Cp_iL, Cp_iR, R_species, h_iL, h_iR]'
862864
#:endif
863865
! The two calls below are identical on purpose. An offload kernel is named
864866
! after the .fpp line of its GPU_PARALLEL_LOOP, so one shared call would give

tests/6AE3FB4E/golden-metadata.txt

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

0 commit comments

Comments
 (0)