From 21d7f32f32063ea98f1fe68760276b0973cc744a Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Tue, 9 Jul 2024 09:16:10 -0400 Subject: [PATCH] move Riemann history constants to riemann_constants namespace (#2895) --- Source/driver/Castro.H | 6 ++---- Source/driver/Castro.cpp | 2 +- Source/hydro/riemann_2shock_solvers.H | 10 +++++----- Source/hydro/riemann_type.H | 10 +++++++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Source/driver/Castro.H b/Source/driver/Castro.H index 30976c248d..f5447c0427 100644 --- a/Source/driver/Castro.H +++ b/Source/driver/Castro.H @@ -16,10 +16,6 @@ using namespace castro; #include -constexpr int HISTORY_SIZE=40; -constexpr int PSTAR_BISECT_FACTOR = 5; - - #include #include #include @@ -50,6 +46,8 @@ constexpr int PSTAR_BISECT_FACTOR = 5; #include +#include + using std::istream; using std::ostream; diff --git a/Source/driver/Castro.cpp b/Source/driver/Castro.cpp index f478f8402d..adc4d97fe9 100644 --- a/Source/driver/Castro.cpp +++ b/Source/driver/Castro.cpp @@ -392,7 +392,7 @@ Castro::read_params () #endif if (riemann_solver == 1) { - if (riemann_shock_maxiter > HISTORY_SIZE) { + if (riemann_shock_maxiter > riemann_constants::HISTORY_SIZE) { amrex::Error("riemann_shock_maxiter > HISTORY_SIZE"); } diff --git a/Source/hydro/riemann_2shock_solvers.H b/Source/hydro/riemann_2shock_solvers.H index f81b495f29..9fc55d5839 100644 --- a/Source/hydro/riemann_2shock_solvers.H +++ b/Source/hydro/riemann_2shock_solvers.H @@ -60,7 +60,7 @@ namespace TwoShock { const amrex::Real gdot, const amrex::Real gmin, const amrex::Real gmax, const int lriemann_shock_maxiter, const amrex::Real lriemann_pstar_tol, amrex::Real& pstar, amrex::Real& gamstar, - bool& converged, amrex::GpuArray& pstar_hist_extra) { + bool& converged, amrex::GpuArray& pstar_hist_extra) { // we want to zero // f(p*) = u*_l(p*) - u*_r(p*) @@ -106,7 +106,7 @@ namespace TwoShock { converged = false; amrex::Real pstar_c = 0.0; - for (int iter = 0; iter < PSTAR_BISECT_FACTOR * lriemann_shock_maxiter; iter++) { + for (int iter = 0; iter < riemann_constants::PSTAR_BISECT_FACTOR * lriemann_shock_maxiter; iter++) { pstar_c = 0.5_rt * (pstar_lo + pstar_hi); pstar_hist_extra[iter] = pstar_c; @@ -167,7 +167,7 @@ namespace TwoShock { constexpr amrex::Real weakwv = 1.e-3_rt; #ifndef AMREX_USE_GPU - amrex::GpuArray pstar_hist; + amrex::GpuArray pstar_hist; #endif @@ -336,7 +336,7 @@ namespace TwoShock { pstarl = amrex::max(pstarl, small_pres); pstaru = amrex::max(pstaru, small_pres); - amrex::GpuArray pstar_hist_extra; + amrex::GpuArray pstar_hist_extra; pstar_bisection(pstarl, pstaru, ql.un, ql.p, taul, gamel, clsql, @@ -352,7 +352,7 @@ namespace TwoShock { 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 * riemann_shock_maxiter; iter_l++) { + for (int iter_l = 0; iter_l < riemann_constants::PSTAR_BISECT_FACTOR * riemann_shock_maxiter; iter_l++) { std::cout << iter_l << " " << pstar_hist_extra[iter_l] << std::endl; } diff --git a/Source/hydro/riemann_type.H b/Source/hydro/riemann_type.H index c8be48f47a..5ca1a9778b 100644 --- a/Source/hydro/riemann_type.H +++ b/Source/hydro/riemann_type.H @@ -6,9 +6,13 @@ using namespace amrex::literals; namespace riemann_constants { - const amrex::Real smlp1 = 1.e-10_rt; - const amrex::Real small = 1.e-8_rt; - const amrex::Real smallu = 1.e-12_rt; + constexpr amrex::Real smlp1 = 1.e-10_rt; + constexpr amrex::Real small = 1.e-8_rt; + constexpr amrex::Real smallu = 1.e-12_rt; + constexpr int HISTORY_SIZE=40; + constexpr int PSTAR_BISECT_FACTOR = 5; + + }