Skip to content

Commit fc7f770

Browse files
committed
src: delete the remaining validator-dead hypoelastic blocks in LF and HLLC; doc fixes
Guard inventory (every tau_e/G consumer in the two files was classified by its exact guard before deletion): - LF: hypoelastic momentum flux (else if hypoelasticity), hypoelastic energy flux (else if hypoelasticity), stress evolution flux (if hypoelasticity), cylindrical tau_sigmasigma source (if cyl_coord .and. hypoelasticity) - all deleted. - HLLC: stress evolution flux (if hypoelasticity), both 6-eqn and 5-eqn copies - deleted. The hyperelasticity-gated tau_e/G/xi_field loads and the elasticity-gated wave speeds and elastic momentum/energy fluxes are untouched (live under hyperelasticity, which is legal with all solvers). - HLL is untouched. case_validator.py prohibits hypoelasticity with any solver but HLL, so these blocks were unreachable; after PR #1572 deleted the hypoelastic energy blocks they consumed tau_e_L/R that nothing in these files loads. Per the maintainer ruling: prefer deleting code - lifting the restriction later means adding the code back deliberately. Unused locals removed from LF: tau_e_L/R and flux_tau_L/R (zero refs after deletion) and xi_field_L/R (orphaned since the solver split, never referenced in LF) - declarations and GPU private-list entries. HLLC declarations are unchanged (tau_e/G remain live on the hyper/elasticity paths). GPU census: LF -7 acc seq-loop directives (2 deleted seq loops x 3 sweep copies + 1 cyl-only), HLLC -6 (1 seq loop x 3 copies x 2 blocks), OMP path unchanged (seq loops emit nothing under OMP); all deltas trace to deleted blocks. Doc fixes: rescope the cray_inline guidance to cross-module helpers only, describe the AMD case-opt guard as sitting on the helper's dummy declaration with matching caller-local guards, and note in s_compute_hypoelastic_interface_energy that the verysmall gate is the deliberate ruling that replaced HLL's former G > 1000 stability floor and retired its TODO.
1 parent a577f15 commit fc7f770

4 files changed

Lines changed: 18 additions & 81 deletions

File tree

docs/documentation/gpuParallelization.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,11 @@ end subroutine s_accumulate_mixture_properties
635635

636636
**Key idioms.**
637637

638-
- Always ``parallelism='[seq]'`` and `cray_inline=True` for these helpers. The Cray
639-
compiler does not inline cross-file `routine` calls without `cray_inline`; without
640-
it, performance collapses silently on that backend.
638+
- Always ``parallelism='[seq]'`` for these helpers. `cray_inline=True` is required
639+
when the helper is called from other modules — the Cray compiler does not inline
640+
cross-file `routine` calls without it, and performance collapses silently on that
641+
backend. Helpers called only from their own module (e.g., the shear/bulk stress
642+
tensor pair in `m_riemann_state.fpp`) do not need it.
641643
- `function_name=` is required when `cray_inline=True` (the Cray inline directive
642644
needs the explicit name).
643645
- The `GPU_ROUTINE` directive lives in the *definition*, not the call site. The
@@ -654,8 +656,9 @@ arrays that are sized by runtime parameters at compile time must be declared wit
654656
explicit constant bound. Use an explicit `n` argument (e.g., `integer, intent(in) ::
655657
nf`) and dimension helpers as `dimension(nf)` rather than `dimension(num_fluids)`.
656658
See `s_compute_interface_reynolds` in `src/simulation/m_riemann_state.fpp` for the
657-
`#:if not MFC_CASE_OPTIMIZATION and USING_AMD` guard pattern where the caller-side
658-
dimensioning differs.
659+
`#:if not MFC_CASE_OPTIMIZATION and USING_AMD` guard pattern: the guard sits on the
660+
dummy-argument declaration in the helper's definition, with matching guards on the
661+
callers' own local declarations so the actual and dummy bounds agree.
659662

660663
**Declare scoping.** The `GPU_ROUTINE` directive must appear in the source file
661664
that defines the routine. Helpers added to `m_riemann_state.fpp` are automatically

src/simulation/m_riemann_solver_hllc.fpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -442,17 +442,6 @@ contains
442442

443443
flux_src_rsx_vf(${SF('')}$, eqn_idx%adv%beg) = vel_src_rsx_vf(${SF('')}$, dir_idx(1))
444444

445-
! HYPOELASTIC STRESS EVOLUTION FLUX.
446-
if (hypoelasticity) then
447-
$:GPU_LOOP(parallelism='[seq]')
448-
do i = 1, eqn_idx%stress%end - eqn_idx%stress%beg + 1
449-
flux_rsx_vf(${SF('')}$, &
450-
& eqn_idx%stress%beg - 1 + i) = xi_M*(s_S/(s_L - s_S))*(s_L*rho_L*tau_e_L(i) &
451-
& - rho_L*vel_L(dir_idx(1))*tau_e_L(i)) + xi_P*(s_S/(s_R - s_S)) &
452-
& *(s_R*rho_R*tau_e_R(i) - rho_R*vel_R(dir_idx(1))*tau_e_R(i))
453-
end do
454-
end if
455-
456445
! Hyperelastic reference map flux for material deformation tracking
457446
if (hyperelasticity) then
458447
$:GPU_LOOP(parallelism='[seq]')
@@ -1404,17 +1393,6 @@ contains
14041393
flux_rsx_vf(${SF('')}$, eqn_idx%E) = flux_rsx_vf(${SF('')}$, eqn_idx%E) + flux_ene_e
14051394
end if
14061395

1407-
! HYPOELASTIC STRESS EVOLUTION FLUX.
1408-
if (hypoelasticity) then
1409-
$:GPU_LOOP(parallelism='[seq]')
1410-
do i = 1, eqn_idx%stress%end - eqn_idx%stress%beg + 1
1411-
flux_rsx_vf(${SF('')}$, &
1412-
& eqn_idx%stress%beg - 1 + i) = xi_M*(s_S/(s_L - s_S))*(s_L*rho_L*tau_e_L(i) &
1413-
& - rho_L*vel_L(dir_idx(1))*tau_e_L(i)) + xi_P*(s_S/(s_R - s_S)) &
1414-
& *(s_R*rho_R*tau_e_R(i) - rho_R*vel_R(dir_idx(1))*tau_e_R(i))
1415-
end do
1416-
end if
1417-
14181396
! VOLUME FRACTION FLUX.
14191397
$:GPU_LOOP(parallelism='[seq]')
14201398
do i = eqn_idx%adv%beg, eqn_idx%adv%end

src/simulation/m_riemann_solver_lf.fpp

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ contains
3535

3636
! Intercell fluxes
3737
type(scalar_field), dimension(sys_size), intent(inout) :: flux_vf, flux_src_vf, flux_gsrc_vf
38-
real(wp) :: flux_tau_L, flux_tau_R
3938
integer, intent(in) :: norm_dir
4039
type(int_bounds_info), intent(in) :: ix, iy, iz
4140

@@ -73,9 +72,7 @@ contains
7372
real(wp) :: pi_inf_L, pi_inf_R
7473
real(wp) :: qv_L, qv_R
7574
real(wp) :: c_L, c_R
76-
real(wp), dimension(6) :: tau_e_L, tau_e_R
7775
real(wp), dimension(2) :: Re_L, Re_R
78-
real(wp), dimension(3) :: xi_field_L, xi_field_R
7976
real(wp) :: rho_avg
8077
real(wp) :: H_avg
8178
real(wp) :: gamma_avg
@@ -111,14 +108,13 @@ contains
111108
#:set SF = lambda offs: COORDS.format(STENCIL_IDX = SV + offs)
112109
if (norm_dir == ${NORM_DIR}$) then
113110
$:GPU_PARALLEL_LOOP(collapse=3, private='[i, j, k, l, alpha_rho_L, alpha_rho_R, vel_L, vel_R, alpha_L, alpha_R, &
114-
& tau_e_L, tau_e_R, Re_L, Re_R, rho_avg, h_avg, gamma_avg, s_L, s_R, s_S, Ys_L, Ys_R, &
115-
& xi_field_L, xi_field_R, Cp_iL, Cp_iR, Xs_L, Xs_R, Gamma_iL, Gamma_iR, Yi_avg, Phi_avg, &
116-
& h_iL, h_iR, h_avg_2, c_fast, pres_mag, B, Ga, vdotB, B2, b4, cm, pcorr, zcoef, vel_grad_L, &
117-
& vel_grad_R, idx_right_phys, vel_L_rms, vel_R_rms, vel_avg_rms, vel_L_tmp, vel_R_tmp, Ms_L, &
118-
& Ms_R, pres_SL, pres_SR, alpha_L_sum, alpha_R_sum, c_avg, pres_L, pres_R, rho_L, rho_R, &
119-
& gamma_L, gamma_R, pi_inf_L, pi_inf_R, qv_L, qv_R, c_L, c_R, E_L, E_R, H_L, H_R, ptilde_L, &
120-
& ptilde_R, s_M, s_P, xi_M, xi_P, Cp_avg, Cv_avg, T_avg, eps, c_sum_Yi_Phi, Cp_L, Cp_R, Cv_L, &
121-
& Cv_R, R_gas_L, R_gas_R, MW_L, MW_R, T_L, T_R, Y_L, Y_R]')
111+
& Re_L, Re_R, rho_avg, h_avg, gamma_avg, s_L, s_R, s_S, Ys_L, Ys_R, Cp_iL, Cp_iR, Xs_L, Xs_R, &
112+
& Gamma_iL, Gamma_iR, Yi_avg, Phi_avg, h_iL, h_iR, h_avg_2, c_fast, pres_mag, B, Ga, vdotB, &
113+
& B2, b4, cm, pcorr, zcoef, vel_grad_L, vel_grad_R, idx_right_phys, vel_L_rms, vel_R_rms, &
114+
& vel_avg_rms, vel_L_tmp, vel_R_tmp, Ms_L, Ms_R, pres_SL, pres_SR, alpha_L_sum, alpha_R_sum, &
115+
& c_avg, pres_L, pres_R, rho_L, rho_R, gamma_L, gamma_R, pi_inf_L, pi_inf_R, qv_L, qv_R, c_L, &
116+
& c_R, E_L, E_R, H_L, H_R, ptilde_L, ptilde_R, s_M, s_P, xi_M, xi_P, Cp_avg, Cv_avg, T_avg, &
117+
& eps, c_sum_Yi_Phi, Cp_L, Cp_R, Cv_L, Cv_R, R_gas_L, R_gas_R, MW_L, MW_R, T_L, T_R, Y_L, Y_R]')
122118
do l = ${Z_BND}$%beg, ${Z_BND}$%end
123119
do k = ${Y_BND}$%beg, ${Y_BND}$%end
124120
do j = ${X_BND}$%beg, ${X_BND}$%end
@@ -379,16 +375,6 @@ contains
379375
& + s_M*s_P*(rho_L*vel_L(dir_idx(i)) - rho_R*vel_R(dir_idx(i))))/(s_M - s_P) &
380376
& + (s_M/s_L)*(s_P/s_R)*pcorr*(vel_R(dir_idx(i)) - vel_L(dir_idx(i)))
381377
end do
382-
else if (hypoelasticity) then
383-
$:GPU_LOOP(parallelism='[seq]')
384-
do i = 1, num_vels
385-
flux_rsx_vf(${SF('')}$, &
386-
& eqn_idx%cont%end + dir_idx(i)) = (s_M*(rho_R*vel_R(dir_idx(1))*vel_R(dir_idx(i)) &
387-
& + dir_flg(dir_idx(i))*pres_R - tau_e_R(dir_idx_tau(i))) &
388-
& - s_P*(rho_L*vel_L(dir_idx(1))*vel_L(dir_idx(i)) + dir_flg(dir_idx(i))*pres_L &
389-
& - tau_e_L(dir_idx_tau(i))) + s_M*s_P*(rho_L*vel_L(dir_idx(i)) &
390-
& - rho_R*vel_R(dir_idx(i))))/(s_M - s_P)
391-
end do
392378
else
393379
$:GPU_LOOP(parallelism='[seq]')
394380
do i = 1, num_vels
@@ -422,34 +408,13 @@ contains
422408
& eqn_idx%E) = (s_M*vel_R(dir_idx(1))*(E_R + pres_R - ptilde_R) - s_P*vel_L(dir_idx(1) &
423409
& )*(E_L + pres_L - ptilde_L) + s_M*s_P*(E_L - E_R))/(s_M - s_P) + (s_M/s_L)*(s_P/s_R) &
424410
& *pcorr*(vel_R_rms - vel_L_rms)/2._wp
425-
else if (hypoelasticity) then
426-
flux_tau_L = 0._wp; flux_tau_R = 0._wp
427-
$:GPU_LOOP(parallelism='[seq]')
428-
do i = 1, num_dims
429-
flux_tau_L = flux_tau_L + tau_e_L(dir_idx_tau(i))*vel_L(dir_idx(i))
430-
flux_tau_R = flux_tau_R + tau_e_R(dir_idx_tau(i))*vel_R(dir_idx(i))
431-
end do
432-
flux_rsx_vf(${SF('')}$, &
433-
& eqn_idx%E) = (s_M*(vel_R(dir_idx(1))*(E_R + pres_R) - flux_tau_R) &
434-
& - s_P*(vel_L(dir_idx(1))*(E_L + pres_L) - flux_tau_L) + s_M*s_P*(E_L - E_R))/(s_M &
435-
& - s_P)
436411
else
437412
flux_rsx_vf(${SF('')}$, &
438413
& eqn_idx%E) = (s_M*vel_R(dir_idx(1))*(E_R + pres_R) - s_P*vel_L(dir_idx(1))*(E_L &
439414
& + pres_L) + s_M*s_P*(E_L - E_R))/(s_M - s_P) + (s_M/s_L)*(s_P/s_R)*pcorr*(vel_R_rms &
440415
& - vel_L_rms)/2._wp
441416
end if
442417

443-
! Elastic Stresses
444-
if (hypoelasticity) then
445-
do i = 1, eqn_idx%stress%end - eqn_idx%stress%beg + 1 ! TODO: this indexing may be slow
446-
flux_rsx_vf(${SF('')}$, &
447-
& eqn_idx%stress%beg - 1 + i) = (s_M*(rho_R*vel_R(dir_idx(1))*tau_e_R(i)) &
448-
& - s_P*(rho_L*vel_L(dir_idx(1))*tau_e_L(i)) + s_M*s_P*(rho_L*tau_e_L(i) &
449-
& - rho_R*tau_e_R(i)))/(s_M - s_P)
450-
end do
451-
end if
452-
453418
! Advection flux and source: interface velocity for volume fraction transport
454419
$:GPU_LOOP(parallelism='[seq]')
455420
do i = eqn_idx%adv%beg, eqn_idx%adv%end
@@ -521,17 +486,6 @@ contains
521486
flux_gsrc_rsx_vf(${SF('')}$, i) = flux_rsx_vf(${SF('')}$, i)
522487
end do
523488
end if
524-
525-
if (cyl_coord .and. hypoelasticity) then
526-
! += tau_sigmasigma using HLL
527-
flux_gsrc_rsx_vf(${SF('')}$, eqn_idx%cont%end + 2) = flux_gsrc_rsx_vf(${SF('')}$, &
528-
& eqn_idx%cont%end + 2) + (s_M*tau_e_R(4) - s_P*tau_e_L(4))/(s_M - s_P)
529-
530-
$:GPU_LOOP(parallelism='[seq]')
531-
do i = eqn_idx%stress%beg, eqn_idx%stress%end
532-
flux_gsrc_rsx_vf(${SF('')}$, i) = flux_rsx_vf(${SF('')}$, i)
533-
end do
534-
end if
535489
#:endif
536490
end do
537491
end do

src/simulation/m_riemann_state.fpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,9 @@ contains
10761076
!> Accumulate the hypoelastic stress contribution to the energies of the left and right Riemann states: mix the shear modulus
10771077
!! over the fluids, scale it by the continuum damage state when damage is modeled, and add the elastic energy of each stress
10781078
!! component (doubled for the shear components) when both mixture moduli are non-negligible. The elastic shear stresses are
1079-
!! loaded from the state buffers by the caller, which reuses them for the stress fluxes and elastic wave speeds.
1079+
!! loaded from the state buffers by the caller, which reuses them for the stress fluxes and elastic wave speeds. The G >
1080+
!! verysmall gate is a deliberate maintainer ruling that replaces HLL's former hard-coded G > 1000 stability floor, retiring its
1081+
!! "TODO take out if statement if stable without".
10801082
subroutine s_compute_hypoelastic_interface_energy(nf, alpha_L, alpha_R, damage_L, damage_R, tau_e_L, tau_e_R, G_L, G_R, E_L, &
10811083
& E_R)
10821084

0 commit comments

Comments
 (0)