Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename some Riemann runtime parameters #2893

Merged
merged 2 commits into from
Jul 1, 2024
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
6 changes: 3 additions & 3 deletions Exec/science/flame_wave/ci-benchmarks/job_info_params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
castro.plm_limiter = 2
castro.hybrid_riemann = 0
castro.riemann_solver = 0
castro.cg_maxiter = 12
castro.cg_tol = 1e-05
castro.cg_blend = 2
castro.riemann_shock_maxiter = 12
castro.riemann_pstar_tol = 1e-05
castro.riemann_cg_blend = 2
castro.use_flattening = 1
castro.transverse_use_eos = 0
castro.transverse_reset_density = 1
Expand Down
2 changes: 1 addition & 1 deletion Exec/science/wdmerger/inputs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ castro.riemann_solver = 0

# For the CG Riemann solver, we need to tell the solver not to quit when
# the iterations don't converge, but instead to do additional bisection iteration.
castro.cg_blend = 2
castro.riemann_cg_blend = 2

# Use a lagged predictor estimate of the source terms in the hydro
castro.source_term_predictor = 1
Expand Down
2 changes: 1 addition & 1 deletion Exec/science/wdmerger/tests/he_double_det/inputs_pakmor
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ castro.riemann_solver = 0

# For the CG Riemann solver, we need to tell the solver not to quit when
# the iterations don't converge, but instead to do additional bisection iteration.
castro.cg_blend = 2
castro.riemann_cg_blend = 2

# Use a lagged predictor estimate of the source terms in the hydro
castro.source_term_predictor = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ castro.riemann_solver = 0

# For the CG Riemann solver, we need to tell the solver not to quit when
# the iterations don't converge, but instead to do additional bisection iteration.
castro.cg_blend = 2
castro.riemann_cg_blend = 2

# Use a lagged predictor estimate of the source terms in the hydro
castro.source_term_predictor = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ castro.riemann_solver = 0

# For the CG Riemann solver, we need to tell the solver not to quit when
# the iterations don't converge, but instead to do additional bisection iteration.
castro.cg_blend = 2
castro.riemann_cg_blend = 2

# Use a lagged predictor estimate of the source terms in the hydro
castro.source_term_predictor = 1
Expand Down
2 changes: 1 addition & 1 deletion Exec/science/wdmerger/tests/he_double_det/inputs_scaling
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ castro.riemann_solver = 0

# For the CG Riemann solver, we need to tell the solver not to quit when
# the iterations don't converge, but instead to do additional bisection iteration.
castro.cg_blend = 2
castro.riemann_cg_blend = 2

# Use a lagged predictor estimate of the source terms in the hydro
castro.source_term_predictor = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ castro.riemann_solver = 0

# For the CG Riemann solver, we need to tell the solver not to quit when
# the iterations don't converge, but instead to do additional bisection iteration.
castro.cg_blend = 2
castro.riemann_cg_blend = 2

# Use a lagged predictor estimate of the source terms in the hydro
castro.source_term_predictor = 1
Expand Down
2 changes: 1 addition & 1 deletion Exec/science/wdmerger/tests/wdmerger_collision_1D/inputs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ castro.riemann_solver = 0

# For the CG Riemann solver, we need to tell the solver not to quit when
# the iterations don't converge, but instead to do additional bisection iteration.
castro.cg_blend = 2
castro.riemann_cg_blend = 2

# Use a lagged predictor estimate of the source terms in the hydro
castro.source_term_predictor = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ castro.riemann_solver = 0

# For the CG Riemann solver, we need to tell the solver not to quit when
# the iterations don't converge, but instead to do additional bisection iteration.
castro.cg_blend = 2
castro.riemann_cg_blend = 2

# Use a lagged predictor estimate of the source terms in the hydro
castro.source_term_predictor = 1
Expand Down
8 changes: 4 additions & 4 deletions Source/driver/Castro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,12 @@ Castro::read_params ()
#endif

if (riemann_solver == 1) {
if (cg_maxiter > HISTORY_SIZE) {
amrex::Error("error in riemanncg: cg_maxiter > HISTORY_SIZE");
if (riemann_shock_maxiter > HISTORY_SIZE) {
amrex::Error("riemann_shock_maxiter > HISTORY_SIZE");
}

if (cg_blend == 2 && cg_maxiter < 5) {
amrex::Error("Error: need cg_maxiter >= 5 to do a bisection search on secant iteration failure.");
if (riemann_cg_blend == 2 && riemann_shock_maxiter < 5) {
amrex::Error("Error: need riemann_shock_maxiter >= 5 to do a bisection search on secant iteration failure.");
}
}
#endif
Expand Down
15 changes: 7 additions & 8 deletions Source/driver/_cpp_parameters
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,19 @@ hybrid_riemann bool 0
# 2: HLLC
riemann_solver int 0

# for the Colella \& Glaz Riemann solver, the maximum number
# of iterations to take when solving for the star state
cg_maxiter int 12
# maximum number of iterations to used in the Riemann solver
# when solving for the star state
riemann_shock_maxiter int 12

# for the Colella \& Glaz Riemann solver, the tolerance to
# demand in finding the star state
cg_tol Real 1.0e-5
# tolerance to use when finding the star stat
riemann_pstar_tol Real 1.0e-5

# for the Colella \& Glaz Riemann solver, what to do if
# we do not converge to a solution for the star state.
# 0 = do nothing; print iterations and exit
# 1 = revert to the original guess for p-star
# 2 = do a bisection search for another 2 * cg_maxiter iterations.
cg_blend int 2
# 2 = do a bisection search for another 2 * riemann_shock_maxiter iterations.
riemann_cg_blend int 2

# flatten the reconstructed profiles around shocks to prevent them
# from becoming too thin
Expand Down
28 changes: 14 additions & 14 deletions Source/hydro/riemann_2shock_solvers.H
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace TwoShock {
const amrex::Real ur, const amrex::Real pr, const amrex::Real taur,
const amrex::Real gamer, const amrex::Real clsqr,
const amrex::Real gdot, const amrex::Real gmin, const amrex::Real gmax,
const int lcg_maxiter, const amrex::Real lcg_tol,
const int lriemann_shock_maxiter, const amrex::Real lriemann_pstar_tol,
amrex::Real& pstar, amrex::Real& gamstar,
bool& converged, amrex::GpuArray<amrex::Real, PSTAR_BISECT_FACTOR*HISTORY_SIZE>& pstar_hist_extra) {

Expand Down Expand Up @@ -106,7 +106,7 @@ namespace TwoShock {
converged = false;
amrex::Real pstar_c = 0.0;

for (int iter = 0; iter < PSTAR_BISECT_FACTOR*lcg_maxiter; iter++) {
for (int iter = 0; iter < PSTAR_BISECT_FACTOR * lriemann_shock_maxiter; iter++) {

pstar_c = 0.5_rt * (pstar_lo + pstar_hi);
pstar_hist_extra[iter] = pstar_c;
Expand All @@ -125,7 +125,7 @@ namespace TwoShock {

amrex::Real f_c = ustar_l - ustar_r;

if ( 0.5_rt * std::abs(pstar_lo - pstar_hi) < lcg_tol * pstar_c ) {
if ( 0.5_rt * std::abs(pstar_lo - pstar_hi) < lriemann_pstar_tol * pstar_c ) {
converged = true;
break;
}
Expand Down Expand Up @@ -239,7 +239,7 @@ namespace TwoShock {
bool converged = false;

int iter = 0;
while ((iter < cg_maxiter && !converged) || iter < 2) {
while ((iter < riemann_shock_maxiter && !converged) || iter < 2) {

wsqge(ql.p, taul, gamel, gdot, gamstar,
gmin, gmax, clsql, pstar, wlsq);
Expand Down Expand Up @@ -281,7 +281,7 @@ namespace TwoShock {
pstar = amrex::max(pstar, small_pres);

amrex::Real err = std::abs(pstar - pstar_old);
if (err < cg_tol*pstar) {
if (err < riemann_pstar_tol * pstar) {
converged = true;
}

Expand All @@ -300,11 +300,11 @@ namespace TwoShock {

if (!converged) {

if (cg_blend == 0) {
if (riemann_cg_blend == 0) {

#ifndef AMREX_USE_GPU
std::cout << "pstar history: " << std::endl;
for (int iter_l=0; iter_l < cg_maxiter; iter_l++) {
for (int iter_l=0; iter_l < riemann_shock_maxiter; iter_l++) {
std::cout << iter_l << " " << pstar_hist[iter_l] << std::endl;
}

Expand All @@ -316,19 +316,19 @@ namespace TwoShock {
amrex::Error("ERROR: non-convergence in the Riemann solver");
#endif

} else if (cg_blend == 1) {
} else if (riemann_cg_blend == 1) {

pstar = ql.p + ( (qr.p - ql.p) - wr * (qr.un - ql.un) ) * wl / (wl + wr);

} else if (cg_blend == 2) {
} else if (riemann_cg_blend == 2) {

// we don't store the history if we are in CUDA, so
// we can't do this
#ifndef AMREX_USE_GPU
// first try to find a reasonable bounds
amrex::Real pstarl = 1.e200;
amrex::Real pstaru = -1.e200;
for (int n = cg_maxiter-6; n < cg_maxiter; n++) {
for (int n = riemann_shock_maxiter-6; n < riemann_shock_maxiter; n++) {
pstarl = amrex::min(pstarl, pstar_hist[n]);
pstaru = amrex::max(pstaru, pstar_hist[n]);
}
Expand All @@ -342,17 +342,17 @@ namespace TwoShock {
ql.un, ql.p, taul, gamel, clsql,
qr.un, qr.p, taur, gamer, clsqr,
gdot, gmin, gmax,
cg_maxiter, cg_tol,
riemann_shock_maxiter, riemann_pstar_tol,
pstar, gamstar, converged, pstar_hist_extra);

if (!converged) {

std::cout << "pstar history: " << std::endl;
for (int iter_l = 0; iter_l < cg_maxiter; iter_l++) {
for (int iter_l = 0; iter_l < riemann_shock_maxiter; iter_l++) {
std::cout << iter_l << " " << pstar_hist[iter_l] << std::endl;
}
std::cout << "pstar extra history: " << std::endl;
for (int iter_l = 0; iter_l < PSTAR_BISECT_FACTOR*cg_maxiter; iter_l++) {
for (int iter_l = 0; iter_l < PSTAR_BISECT_FACTOR * riemann_shock_maxiter; iter_l++) {
std::cout << iter_l << " " << pstar_hist_extra[iter_l] << std::endl;
}

Expand All @@ -368,7 +368,7 @@ namespace TwoShock {
} else {

#ifndef AMREX_USE_GPU
amrex::Error("ERROR: unrecognized cg_blend option.");
amrex::Error("ERROR: unrecognized riemann_cg_blend option.");
#endif
}

Expand Down