Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/documentation/case.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ It is recommended to set `weno_eps` to $10^{-6}$ for WENO-JS, and to $10^{-40}$
`riemann_solver = 1`, `2`, and `3` correspond to HLL, HLLC, and Exact Riemann solver, respectively ([Toro, 2013](references.md)).
`riemann_solver = 4` is only for MHD simulations. It resolves 5 of the full seven-wave structure of the MHD equations ([Miyoshi and Kusano, 2005](references.md)).

- `low_Mach` specifies the choice of the low Mach number correction scheme for the HLLC Riemann solver. `low_Mach = 0` is default value and does not apply any correction scheme. `low_Mach = 1` and `2` apply the anti-dissipation pressure correction method ([Chen et al., 2022](references.md)) and the improved velocity reconstruction method ([Thornber et al., 2008](references.md)). This feature requires `riemann_solver = 2` and `model_eqns = 2`.
- `low_Mach` specifies the choice of the low Mach number correction scheme for the HLLC Riemann solver. `low_Mach = 0` is default value and does not apply any correction scheme. `low_Mach = 1` and `2` apply the anti-dissipation pressure correction method ([Chen et al., 2022](references.md)) and the improved velocity reconstruction method ([Thornber et al., 2008](references.md)). This feature requires `model_eqns = 2` or `3`. `low_Mach = 1` works for `riemann_solver = 1` and `2`, but `low_Mach = 2` only works for `riemann_solver = 2`.

- `avg_state` specifies the choice of the method to compute averaged variables at the cell-boundaries from the left and the right states in the Riemann solver by an integer of 1 or 2.
`avg_state = 1` and `2` correspond to Roe- and arithmetic averages, respectively.
Expand Down
30 changes: 8 additions & 22 deletions src/post_process/m_start_up.f90
Original file line number Diff line number Diff line change
Expand Up @@ -544,31 +544,17 @@ subroutine s_save_data(t_step, varname, pres, c, H)
end if

! Adding the vorticity to the formatted database file
if (p > 0) then
do i = 1, num_vels
if (omega_wrt(i)) then
do i = 1, 3
if (omega_wrt(i)) then

call s_derive_vorticity_component(i, q_prim_vf, q_sf)
call s_derive_vorticity_component(i, q_prim_vf, q_sf)

write (varname, '(A,I0)') 'omega', i
call s_write_variable_to_formatted_database_file(varname, t_step)

varname(:) = ' '
end if
end do
elseif (n > 0) then
do i = 1, num_vels
if (omega_wrt(i)) then

call s_derive_vorticity_component(i, q_prim_vf, q_sf)

write (varname, '(A,I0)') 'omega', i
call s_write_variable_to_formatted_database_file(varname, t_step)
write (varname, '(A,I0)') 'omega', i
call s_write_variable_to_formatted_database_file(varname, t_step)

varname(:) = ' '
end if
end do
end if
varname(:) = ' '
end if
end do

if (ib) then
q_sf = real(ib_markers%sf(-offset_x%beg:m + offset_x%end, -offset_y%beg:n + offset_y%end, -offset_z%beg:p + offset_z%end))
Expand Down
37 changes: 24 additions & 13 deletions src/simulation/include/inline_riemann.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,30 @@

#:def compute_low_Mach_correction()

zcoef = min(1._wp, max(vel_L_rms**5e-1_wp/c_L, vel_R_rms**5e-1_wp/c_R))
pcorr = 0._wp

if (low_Mach == 1) then
pcorr = rho_L*rho_R* &
(s_L - vel_L(dir_idx(1)))*(s_R - vel_R(dir_idx(1)))*(vel_R(dir_idx(1)) - vel_L(dir_idx(1)))/ &
(rho_R*(s_R - vel_R(dir_idx(1))) - rho_L*(s_L - vel_L(dir_idx(1))))* &
(zcoef - 1._wp)
else if (low_Mach == 2) then
vel_L_tmp = 5e-1_wp*((vel_L(dir_idx(1)) + vel_R(dir_idx(1))) + zcoef*(vel_L(dir_idx(1)) - vel_R(dir_idx(1))))
vel_R_tmp = 5e-1_wp*((vel_L(dir_idx(1)) + vel_R(dir_idx(1))) + zcoef*(vel_R(dir_idx(1)) - vel_L(dir_idx(1))))
vel_L(dir_idx(1)) = vel_L_tmp
vel_R(dir_idx(1)) = vel_R_tmp
if (riemann_solver == 1) then

zcoef = min(1._wp, max(vel_L_rms**5e-1_wp/c_L, vel_R_rms**5e-1_wp/c_R))
pcorr = 0._wp

if (low_Mach == 1) then
pcorr = -(s_P - s_M)*(rho_L + rho_R)/8._wp*(zcoef - 1._wp)
end if

else if (riemann_solver == 2) then
zcoef = min(1._wp, max(vel_L_rms**5e-1_wp/c_L, vel_R_rms**5e-1_wp/c_R))
pcorr = 0._wp

if (low_Mach == 1) then
pcorr = rho_L*rho_R* &
(s_L - vel_L(dir_idx(1)))*(s_R - vel_R(dir_idx(1)))*(vel_R(dir_idx(1)) - vel_L(dir_idx(1)))/ &
(rho_R*(s_R - vel_R(dir_idx(1))) - rho_L*(s_L - vel_L(dir_idx(1))))* &
(zcoef - 1._wp)
else if (low_Mach == 2) then
vel_L_tmp = 5e-1_wp*((vel_L(dir_idx(1)) + vel_R(dir_idx(1))) + zcoef*(vel_L(dir_idx(1)) - vel_R(dir_idx(1))))
vel_R_tmp = 5e-1_wp*((vel_L(dir_idx(1)) + vel_R(dir_idx(1))) + zcoef*(vel_R(dir_idx(1)) - vel_L(dir_idx(1))))
vel_L(dir_idx(1)) = vel_L_tmp
vel_R(dir_idx(1)) = vel_R_tmp
end if
end if

#:enddef compute_low_Mach_correction
4 changes: 2 additions & 2 deletions src/simulation/m_checker.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ contains
@:PROHIBIT(riemann_solver /= 3 .and. wave_speeds == dflt_int, "wave_speeds must be set if riemann_solver != 3")
@:PROHIBIT(riemann_solver /= 3 .and. avg_state == dflt_int, "avg_state must be set if riemann_solver != 3")
@:PROHIBIT(all(low_Mach /= (/0, 1, 2/)), "low_Mach must be 0, 1 or 2")
@:PROHIBIT(riemann_solver /= 2 .and. low_Mach /= 0, "low_Mach = 1 or 2 requires riemann_solver = 2")
@:PROHIBIT(low_Mach /= 0 .and. model_eqns /= 2, "low_Mach = 1 or 2 requires model_eqns = 2")
@:PROHIBIT(riemann_solver /= 2 .and. low_Mach == 2, "low_Mach = 2 requires riemann_solver = 2")
@:PROHIBIT(low_Mach /= 0 .and. all(model_eqns /= (/2, 3/)), "low_Mach = 1 or 2 requires model_eqns = 2 or 3")
end subroutine s_check_inputs_riemann_solver

!> Checks constraints on geometry and precision
Expand Down
57 changes: 46 additions & 11 deletions src/simulation/m_riemann_solvers.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,10 @@

real(wp) :: ptilde_L, ptilde_R
real(wp) :: vel_L_rms, vel_R_rms, vel_avg_rms
real(wp) :: vel_L_tmp, vel_R_tmp
real(wp) :: Ms_L, Ms_R, pres_SL, pres_SR
real(wp) :: alpha_L_sum, alpha_R_sum
real(wp) :: zcoef, pcorr !< low Mach number correction

type(riemann_states) :: c_fast, pres_mag
type(riemann_states_vec3) :: B
Expand Down Expand Up @@ -367,7 +369,8 @@
!$acc xi_field_L, xi_field_R, &
!$acc Cp_iL, Cp_iR, Xs_L, Xs_R, Gamma_iL, Gamma_iR, &
!$acc Yi_avg, Phi_avg, h_iL, h_iR, h_avg_2, &
!$acc c_fast, pres_mag, B, Ga, vdotB, B2, b4, cm)
!$acc c_fast, pres_mag, B, Ga, vdotB, B2, b4, cm, &
!$acc pcorr, zcoef, vel_L_tmp, vel_R_tmp)
do l = is3%beg, is3%end
do k = is2%beg, is2%end
do j = is1%beg, is1%end
Expand Down Expand Up @@ -748,6 +751,13 @@
+ (5e-1_wp - sign(5e-1_wp, s_L)) &
*(5e-1_wp + sign(5e-1_wp, s_R))

! Low Mach correction
if (low_Mach == 1) then
@:compute_low_Mach_correction()

Check warning on line 756 in src/simulation/m_riemann_solvers.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_riemann_solvers.fpp#L756

Added line #L756 was not covered by tests
else
pcorr = 0._wp
end if

! Mass
if (.not. relativity) then
!$acc loop seq
Expand Down Expand Up @@ -852,7 +862,8 @@
+ dir_flg(dir_idx(i))*(pres_L - ptilde_L)) &
+ s_M*s_P*(rho_L*vel_L(dir_idx(i)) &
- rho_R*vel_R(dir_idx(i)))) &
/(s_M - s_P)
/(s_M - s_P) &
+ (s_M/s_L)*(s_P/s_R)*pcorr*(vel_R(dir_idx(i)) - vel_L(dir_idx(i)))

Check warning on line 866 in src/simulation/m_riemann_solvers.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_riemann_solvers.fpp#L866

Added line #L866 was not covered by tests
end do
else if (hypoelasticity) then
!$acc loop seq
Expand Down Expand Up @@ -882,7 +893,8 @@
+ dir_flg(dir_idx(i))*pres_L) &
+ s_M*s_P*(rho_L*vel_L(dir_idx(i)) &
- rho_R*vel_R(dir_idx(i)))) &
/(s_M - s_P)
/(s_M - s_P) &
+ (s_M/s_L)*(s_P/s_R)*pcorr*(vel_R(dir_idx(i)) - vel_L(dir_idx(i)))
end do
end if

Expand All @@ -907,7 +919,8 @@
(s_M*vel_R(dir_idx(1))*(E_R + pres_R - ptilde_R) &
- s_P*vel_L(dir_idx(1))*(E_L + pres_L - ptilde_L) &
+ s_M*s_P*(E_L - E_R)) &
/(s_M - s_P)
/(s_M - s_P) &
+ (s_M/s_L)*(s_P/s_R)*pcorr*(vel_R_rms - vel_L_rms)/2._wp

Check warning on line 923 in src/simulation/m_riemann_solvers.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_riemann_solvers.fpp#L923

Added line #L923 was not covered by tests
else if (hypoelasticity) then
!TODO: simplify this so it's not split into 3
if (num_dims == 1) then
Expand Down Expand Up @@ -946,7 +959,8 @@
(s_M*vel_R(dir_idx(1))*(E_R + pres_R) &
- s_P*vel_L(dir_idx(1))*(E_L + pres_L) &
+ s_M*s_P*(E_L - E_R)) &
/(s_M - s_P)
/(s_M - s_P) &
+ (s_M/s_L)*(s_P/s_R)*pcorr*(vel_R_rms - vel_L_rms)/2._wp
end if

! Elastic Stresses
Expand Down Expand Up @@ -1287,7 +1301,8 @@
!$acc private(vel_L, vel_R, vel_K_Star, Re_L, Re_R, rho_avg, h_avg, gamma_avg, &
!$acc s_L, s_R, s_S, vel_avg_rms, alpha_L, alpha_R, Ys_L, Ys_R, Xs_L, Xs_R, &
!$acc Gamma_iL, Gamma_iR, Cp_iL, Cp_iR, Yi_avg, Phi_avg, h_iL, h_iR, h_avg_2, &
!$acc tau_e_L, tau_e_R, G_L, G_R, flux_ene_e, xi_field_L, xi_field_R)
!$acc tau_e_L, tau_e_R, G_L, G_R, flux_ene_e, xi_field_L, xi_field_R, pcorr, &
!$acc zcoef, vel_L_tmp, vel_R_tmp)
do l = is3%beg, is3%end
do k = is2%beg, is2%end
do j = is1%beg, is1%end
Expand Down Expand Up @@ -1476,6 +1491,11 @@
end do
end if

! Low Mach correction
if (low_Mach == 2) then
@:compute_low_Mach_correction()

Check warning on line 1496 in src/simulation/m_riemann_solvers.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_riemann_solvers.fpp#L1496

Added line #L1496 was not covered by tests
end if

! COMPUTING THE DIRECT WAVE SPEEDS
if (wave_speeds == 1) then
if (elasticity) then
Expand Down Expand Up @@ -1551,6 +1571,13 @@
vel_K_Star = vel_L(idx1)*(1_wp - xi_MP) + xi_MP*vel_R(idx1) + &
xi_MP*xi_PP*(s_S - vel_R(idx1))

! Low Mach correction
if (low_Mach == 1) then
@:compute_low_Mach_correction()

Check warning on line 1576 in src/simulation/m_riemann_solvers.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_riemann_solvers.fpp#L1576

Added line #L1576 was not covered by tests
else
pcorr = 0._wp
end if

! COMPUTING FLUXES
! MASS FLUX.
!$acc loop seq
Expand All @@ -1566,12 +1593,14 @@
do i = 1, num_dims
idxi = dir_idx(i)
flux_rs${XYZ}$_vf(j, k, l, contxe + idxi) = rho_Star*vel_K_Star* &
(dir_flg(idxi)*vel_K_Star + (1_wp - dir_flg(idxi))*(xi_M*vel_L(idxi) + xi_P*vel_R(idxi))) + dir_flg(idxi)*p_Star
(dir_flg(idxi)*vel_K_Star + (1_wp - dir_flg(idxi))*(xi_M*vel_L(idxi) + xi_P*vel_R(idxi))) + dir_flg(idxi)*p_Star &

Check warning on line 1596 in src/simulation/m_riemann_solvers.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_riemann_solvers.fpp#L1596

Added line #L1596 was not covered by tests
+ (s_M/s_L)*(s_P/s_R)*dir_flg(idxi)*pcorr
end do

! ENERGY FLUX.
! f = u*(E-\sigma), q = E, q_star = \xi*E+(s-u)(\rho s_star - \sigma/(s-u))
flux_rs${XYZ}$_vf(j, k, l, E_idx) = (E_star + p_Star)*vel_K_Star
flux_rs${XYZ}$_vf(j, k, l, E_idx) = (E_star + p_Star)*vel_K_Star &

Check warning on line 1602 in src/simulation/m_riemann_solvers.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_riemann_solvers.fpp#L1602

Added line #L1602 was not covered by tests
+ (s_M/s_L)*(s_P/s_R)*pcorr*s_S

! ELASTICITY. Elastic shear stress additions for the momentum and energy flux
if (elasticity) then
Expand Down Expand Up @@ -1623,7 +1652,8 @@
((xi_M*qL_prim_rs${XYZ}$_vf(j, k, l, i + advxb - 1) + xi_P*qR_prim_rs${XYZ}$_vf(j + 1, k, l, i + advxb - 1))* &
(gammas(i)*p_K_Star + pi_infs(i)) + &
(xi_M*qL_prim_rs${XYZ}$_vf(j, k, l, i + contxb - 1) + xi_P*qR_prim_rs${XYZ}$_vf(j + 1, k, l, i + contxb - 1))* &
qvs(i))*vel_K_Star
qvs(i))*vel_K_Star &

Check warning on line 1655 in src/simulation/m_riemann_solvers.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_riemann_solvers.fpp#L1655

Added line #L1655 was not covered by tests
+ (s_M/s_L)*(s_P/s_R)*pcorr*s_S*(xi_M*qL_prim_rs${XYZ}$_vf(j, k, l, i + advxb - 1) + xi_P*qR_prim_rs${XYZ}$_vf(j + 1, k, l, i + advxb - 1))
end do

flux_src_rs${XYZ}$_vf(j, k, l, advxb) = vel_src_rs${XYZ}$_vf(j, k, l, idx1)
Expand Down Expand Up @@ -1703,6 +1733,7 @@
do l = is3%beg, is3%end
do k = is2%beg, is2%end
do j = is1%beg, is1%end

!$acc loop seq
do i = 1, contxe
alpha_rho_L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, i)
Expand Down Expand Up @@ -2200,6 +2231,7 @@
end do
end if

! Low Mach correction
if (low_Mach == 2) then
@:compute_low_Mach_correction()
end if
Expand Down Expand Up @@ -2250,6 +2282,7 @@
xi_M = (5e-1_wp + sign(5e-1_wp, s_S))
xi_P = (5e-1_wp - sign(5e-1_wp, s_S))

! Low Mach correction
if (low_Mach == 1) then
@:compute_low_Mach_correction()
else
Expand Down Expand Up @@ -2667,6 +2700,7 @@
end do
end if

! Low Mach correction
if (low_Mach == 2) then
@:compute_low_Mach_correction()
end if
Expand Down Expand Up @@ -2727,14 +2761,15 @@
xi_M = (5e-1_wp + sign(5e-1_wp, s_S))
xi_P = (5e-1_wp - sign(5e-1_wp, s_S))

! COMPUTING THE HLLC FLUXES
! MASS FLUX.
! Low Mach correction
if (low_Mach == 1) then
@:compute_low_Mach_correction()
else
pcorr = 0._wp
end if

! COMPUTING THE HLLC FLUXES
! MASS FLUX.
!$acc loop seq
do i = 1, contxe
flux_rs${XYZ}$_vf(j, k, l, i) = &
Expand Down
Loading
Loading