Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/Fypp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ macro(HANDLE_SOURCES target useCommon)
-I "${${target}_DIR}/include"
-I "${common_DIR}/include"
-I "${common_DIR}"
-I "${common_DIR}/include/defaults"
-D MFC_${CMAKE_Fortran_COMPILER_ID}
-D MFC_${${target}_UPPER}
-D MFC_COMPILER="${CMAKE_Fortran_COMPILER_ID}"
Expand Down
4 changes: 4 additions & 0 deletions src/common/include/defaults/thermochem.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
! Default for Fypp runs outside the toolchain (e.g. documentation). Searched last, so the
! build/include/<target>/thermochem.fpp the toolchain writes from m_thermochem takes precedence.
#:set NUM_SPECIES = 1
#:set CHEMISTRY = False
12 changes: 6 additions & 6 deletions src/common/include/shared_parallel_macros.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#:set USING_CCE = (MFC_COMPILER == CCE_COMPILER_ID)
#:set USING_AMD = (MFC_COMPILER == AMD_COMPILER_ID)

#! Fallback extents the USING_AMD guards substitute for device-global array bounds when case
#! optimization is off. They are not independent: sys_size counts the species, so AMD_SYS_SIZE_MAX
#! must cover 3*num_fluids + num_vels + 1 + AMD_NUM_SPECIES_MAX. Keep them here rather than as
#! literals at each declaration, so raising one cannot silently outgrow the other.
#:set AMD_NUM_SPECIES_MAX = 60
#:set AMD_SYS_SIZE_MAX = 70
#! NUM_SPECIES (m_thermochem's species count) and CHEMISTRY, written per build by the toolchain.
#:include 'thermochem.fpp'

#! Fallback extent the USING_AMD guards substitute for sys_size arrays when case optimization is off.
#! Chemistry pins num_fluids to 1, leaving at most 10 flow variables beside the species.
#:set AMD_SYS_SIZE_MAX = 10 + NUM_SPECIES if CHEMISTRY else 70

#:def ASSERT_LIST(data, datatype)
#:assert data is not None
Expand Down
9 changes: 1 addition & 8 deletions src/common/m_checker_common.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@ contains
#:if not MFC_CASE_OPTIMIZATION
@:PROHIBIT(num_fluids > 3, "num_fluids <= 3 for AMDFLang when Case optimization is off")
@:PROHIBIT((bubbles_euler .or. bubbles_lagrange) .and. nb > 3, "nb <= 3 for AMDFLang when Case optimization is off")
@:PROHIBIT(chemistry .and. num_species > ${AMD_NUM_SPECIES_MAX}$, &
& "num_species <= ${AMD_NUM_SPECIES_MAX}$ for AMDFLang when Case optimization is off")
! The sys_size bound is not independent of the one above it. Chemistry pins num_fluids to 1, so with
! num_vels <= 3 the species terminate sys_size at 2*1 + 3 + 1 + 60 = 66 for five equations and
! 3*1 + 3 + 1 + 60 = 67 for six; 70 covers both with room, and hypoelastic stresses would add up to six
! more. It had no check of its own while the species cap was ten, because sys_size could not then reach
! the dimension(20) the guard gives every sys_size array; HLLC's star states have no other bound, so
! raising one cap without the other overruns them with nothing to say so.
! HLLC's star states and the CBC L vectors have no other bound.
@:PROHIBIT(sys_size > ${AMD_SYS_SIZE_MAX}$, &
& "sys_size <= ${AMD_SYS_SIZE_MAX}$ for AMDFLang when Case optimization is off")
#:endif
Expand Down
58 changes: 19 additions & 39 deletions src/common/m_chemistry.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,8 @@ contains
integer :: eqn
real(wp) :: T
real(wp) :: rho, omega_m

#:if not MFC_CASE_OPTIMIZATION and USING_AMD
real(wp), dimension(${AMD_NUM_SPECIES_MAX}$) :: Ys
real(wp), dimension(${AMD_NUM_SPECIES_MAX}$) :: omega
#:else
real(wp), dimension(num_species) :: Ys
real(wp), dimension(num_species) :: omega
#:endif
real(wp), dimension(${NUM_SPECIES}$) :: Ys
real(wp), dimension(${NUM_SPECIES}$) :: omega

$:GPU_PARALLEL_LOOP(collapse=3, private='[Ys, omega, eqn, T, rho, omega_m]', copyin='[bounds]')
do z = bounds(3)%beg, bounds(3)%end
Expand Down Expand Up @@ -172,13 +166,8 @@ contains
! stiff_target: fractional net composition change per sub-step targeted when sizing the adaptive
! nsub. An uncalibrated engineering default -- alpha-QSS is unconditionally stable, so it trades
! accuracy for cost (never stability), and the cost is bounded by reaction_substeps_max.
real(wp), parameter :: stiff_target = 0.5_wp

#:if not MFC_CASE_OPTIMIZATION and USING_AMD
real(wp), dimension(${AMD_NUM_SPECIES_MAX}$) :: Ys, cdot, ddot, y0, prod0, Lloss, alp
#:else
real(wp), dimension(num_species) :: Ys, cdot, ddot, y0, prod0, Lloss, alp
#:endif
real(wp), parameter :: stiff_target = 0.5_wp
real(wp), dimension(${NUM_SPECIES}$) :: Ys, cdot, ddot, y0, prod0, Lloss, alp

if (chem_params%adap_substeps) then
! Pass 1: per-rank local stiffness probe -> adapt nsub for this step, no MPI. Each rank
Expand Down Expand Up @@ -320,31 +309,22 @@ contains
!> Compute species mass diffusion fluxes at cell interfaces using mixture-averaged diffusivities.
subroutine s_compute_chemistry_diffusion_flux(idir, q_prim_qp, flux_src_vf, irx, iry, irz, q_T_sf)

type(scalar_field), dimension(sys_size), intent(in) :: q_prim_qp
type(scalar_field), dimension(sys_size), intent(in) :: q_prim_qp
type(scalar_field), dimension(sys_size), intent(inout) :: flux_src_vf
type(int_bounds_info), intent(in) :: irx, iry, irz
integer, intent(in) :: idir
type(scalar_field), intent(in) :: q_T_sf

#:if not MFC_CASE_OPTIMIZATION and USING_AMD
real(wp), dimension(${AMD_NUM_SPECIES_MAX}$) :: Xs_L, Xs_R, Xs_cell, Ys_L, Ys_R, Ys_cell
real(wp), dimension(${AMD_NUM_SPECIES_MAX}$) :: mass_diffusivities_mixavg1, mass_diffusivities_mixavg2
real(wp), dimension(${AMD_NUM_SPECIES_MAX}$) :: mass_diffusivities_mixavg_Cell, dXk_dxi, h_l, h_r, h_k
real(wp), dimension(${AMD_NUM_SPECIES_MAX}$) :: Mass_Diffu_Flux, dYk_dxi
#:else
real(wp), dimension(num_species) :: Xs_L, Xs_R, Xs_cell, Ys_L, Ys_R, Ys_cell
real(wp), dimension(num_species) :: mass_diffusivities_mixavg1, mass_diffusivities_mixavg2
real(wp), dimension(num_species) :: mass_diffusivities_mixavg_Cell, dXk_dxi, h_l, h_r, h_k
real(wp), dimension(num_species) :: Mass_Diffu_Flux, dYk_dxi
#:endif

real(wp) :: Mass_Diffu_Energy
real(wp) :: MW_L, MW_R, MW_cell, T_L, T_R, P_L, P_R, rho_L, rho_R, rho_cell, rho_Vic
real(wp) :: lambda_L, lambda_R, lambda_Cell, dT_dxi, grid_spacing
real(wp) :: Cp_L, Cp_R
real(wp) :: diffusivity_L, diffusivity_R, diffusivity_cell
real(wp) :: hmix_L, hmix_R, dh_dxi
integer :: x, y, z, i, n, eqn
type(int_bounds_info), intent(in) :: irx, iry, irz
integer, intent(in) :: idir
type(scalar_field), intent(in) :: q_T_sf
real(wp), dimension(${NUM_SPECIES}$) :: Xs_L, Xs_R, Xs_cell, Ys_L, Ys_R, Ys_cell
real(wp), dimension(${NUM_SPECIES}$) :: mass_diffusivities_mixavg1, mass_diffusivities_mixavg2
real(wp), dimension(${NUM_SPECIES}$) :: mass_diffusivities_mixavg_Cell, dXk_dxi, h_l, h_r, h_k
real(wp), dimension(${NUM_SPECIES}$) :: Mass_Diffu_Flux, dYk_dxi
real(wp) :: Mass_Diffu_Energy
real(wp) :: MW_L, MW_R, MW_cell, T_L, T_R, P_L, P_R, rho_L, rho_R, rho_cell, rho_Vic
real(wp) :: lambda_L, lambda_R, lambda_Cell, dT_dxi, grid_spacing
real(wp) :: Cp_L, Cp_R
real(wp) :: diffusivity_L, diffusivity_R, diffusivity_cell
real(wp) :: hmix_L, hmix_R, dh_dxi
integer :: x, y, z, i, n, eqn
integer, dimension(3) :: offsets

isc1 = irx; isc2 = iry; isc3 = irz
Expand Down
42 changes: 20 additions & 22 deletions src/common/m_variables_conversion.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,11 @@ contains
#:if USING_AMD and not MFC_CASE_OPTIMIZATION
real(wp), dimension(3) :: alpha_K, alpha_rho_K
real(wp), dimension(3) :: nRtmp
real(wp) :: rhoYks(1:${AMD_NUM_SPECIES_MAX}$)
#:else
real(wp), dimension(num_fluids) :: alpha_K, alpha_rho_K
real(wp), dimension(nb) :: nRtmp
real(wp) :: rhoYks(1:num_species)
#:endif
real(wp) :: rhoYks(1:${NUM_SPECIES}$)
real(wp), dimension(2) :: Re_K
real(wp) :: rho_K, gamma_K, pi_inf_K, qv_K, dyn_pres_K
real(wp) :: vftmp, nbub_sc
Expand Down Expand Up @@ -948,28 +947,27 @@ contains
! functions, the shear and volume Reynolds numbers and the Weber numbers

#:if not MFC_CASE_OPTIMIZATION and USING_AMD
real(wp), dimension(3) :: alpha_rho_K
real(wp), dimension(3) :: alpha_K
real(wp), dimension(3) :: vel_K
real(wp), dimension(${AMD_NUM_SPECIES_MAX}$) :: Y_K
real(wp), dimension(3) :: alpha_rho_K
real(wp), dimension(3) :: alpha_K
real(wp), dimension(3) :: vel_K
#:else
real(wp), dimension(num_fluids) :: alpha_rho_K
real(wp), dimension(num_fluids) :: alpha_K
real(wp), dimension(num_vels) :: vel_K
real(wp), dimension(num_species) :: Y_K
real(wp), dimension(num_fluids) :: alpha_rho_K
real(wp), dimension(num_fluids) :: alpha_K
real(wp), dimension(num_vels) :: vel_K
#:endif
real(wp) :: rho_K
real(wp) :: vel_K_sum
real(wp) :: pres_K
real(wp) :: E_K
real(wp) :: gamma_K
real(wp) :: pi_inf_K
real(wp) :: qv_K
real(wp), dimension(2) :: Re_K
real(wp) :: G_K
real(wp) :: blkmod1_K, blkmod2_K, K_K
real(wp) :: T_K, mix_mol_weight, R_gas
integer :: i, j, k, l !< Generic loop iterators
real(wp), dimension(${NUM_SPECIES}$) :: Y_K
real(wp) :: rho_K
real(wp) :: vel_K_sum
real(wp) :: pres_K
real(wp) :: E_K
real(wp) :: gamma_K
real(wp) :: pi_inf_K
real(wp) :: qv_K
real(wp), dimension(2) :: Re_K
real(wp) :: G_K
real(wp) :: blkmod1_K, blkmod2_K, K_K
real(wp) :: T_K, mix_mol_weight, R_gas
integer :: i, j, k, l !< Generic loop iterators

is1b = is1%beg; is1e = is1%end
is2b = is2%beg; is2e = is2%end
Expand Down
55 changes: 27 additions & 28 deletions src/simulation/m_cbc.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,36 +483,35 @@ contains
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(${AMD_NUM_SPECIES_MAX}$) :: Ys, h_k, dYs_dt, dYs_ds, Xs, Gamma_i, Cp_i
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
#: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
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
#: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) :: 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
real(wp), dimension(${NUM_SPECIES}$) :: Ys, h_k, dYs_dt, dYs_ds, Xs, Gamma_i, Cp_i
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) :: 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

Expand Down
Loading
Loading