From 6aff478b7e66adc08f2fb19c6027b8b447b5b42b Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Tue, 9 Jul 2024 09:25:02 -0400 Subject: [PATCH] split constants into riemann_constants.H (#2896) this will make it easier to use this for non-castro things (like exact_riemann) --- Source/driver/Castro.H | 2 -- Source/driver/Castro.cpp | 2 ++ Source/hydro/Make.package | 1 + Source/hydro/riemann_2shock_solvers.H | 1 + Source/hydro/riemann_constants.H | 16 ++++++++++++++++ Source/hydro/riemann_type.H | 11 ----------- Util/exact_riemann/GNUmakefile | 2 +- Util/exact_riemann/main.cpp | 4 +--- Util/exact_riemann/riemann_shock.H | 11 ++++++----- 9 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 Source/hydro/riemann_constants.H diff --git a/Source/driver/Castro.H b/Source/driver/Castro.H index f5447c0427..8c7b9c13f8 100644 --- a/Source/driver/Castro.H +++ b/Source/driver/Castro.H @@ -46,8 +46,6 @@ using namespace castro; #include -#include - using std::istream; using std::ostream; diff --git a/Source/driver/Castro.cpp b/Source/driver/Castro.cpp index adc4d97fe9..e79cf0574e 100644 --- a/Source/driver/Castro.cpp +++ b/Source/driver/Castro.cpp @@ -58,6 +58,8 @@ #include #include +#include + using namespace amrex; bool Castro::signalStopJob = false; diff --git a/Source/hydro/Make.package b/Source/hydro/Make.package index 6b6ba6c7e8..c5813e27c3 100644 --- a/Source/hydro/Make.package +++ b/Source/hydro/Make.package @@ -30,6 +30,7 @@ CEXE_sources += riemann.cpp CEXE_headers += HLL_solvers.H CEXE_headers += riemann_solvers.H CEXE_headers += riemann_2shock_solvers.H +CEXE_headers += riemann_constants.H CEXE_headers += riemann_type.H CEXE_headers += slope.H CEXE_headers += reconstruction.H diff --git a/Source/hydro/riemann_2shock_solvers.H b/Source/hydro/riemann_2shock_solvers.H index 9fc55d5839..6a70d0e117 100644 --- a/Source/hydro/riemann_2shock_solvers.H +++ b/Source/hydro/riemann_2shock_solvers.H @@ -5,6 +5,7 @@ using namespace amrex::literals; +#include #include #ifdef RADIATION #include diff --git a/Source/hydro/riemann_constants.H b/Source/hydro/riemann_constants.H new file mode 100644 index 0000000000..f06776238f --- /dev/null +++ b/Source/hydro/riemann_constants.H @@ -0,0 +1,16 @@ +#ifndef RIEMANN_CONSTANTS_H +#define RIEMANN_CONSTANTS_H + +#include + +using namespace amrex::literals; + +namespace riemann_constants { + 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; +} + +#endif diff --git a/Source/hydro/riemann_type.H b/Source/hydro/riemann_type.H index 5ca1a9778b..658befe151 100644 --- a/Source/hydro/riemann_type.H +++ b/Source/hydro/riemann_type.H @@ -5,17 +5,6 @@ using namespace amrex::literals; -namespace riemann_constants { - 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; - - -} - - struct RiemannState { amrex::Real rho; diff --git a/Util/exact_riemann/GNUmakefile b/Util/exact_riemann/GNUmakefile index 8be2709e1a..fbf934926a 100644 --- a/Util/exact_riemann/GNUmakefile +++ b/Util/exact_riemann/GNUmakefile @@ -33,6 +33,6 @@ Blocs := . # we explicitly want runtime_parameters.H so we have access to # Castro's runtime parameter system -Blocs += $(CASTRO_HOME)/Source/driver +Blocs += $(CASTRO_HOME)/Source/driver $(CASTRO_HOME)/Source/hydro include $(CASTRO_HOME)/Exec/Make.Castro diff --git a/Util/exact_riemann/main.cpp b/Util/exact_riemann/main.cpp index 7f75f6fc36..4707027763 100644 --- a/Util/exact_riemann/main.cpp +++ b/Util/exact_riemann/main.cpp @@ -41,9 +41,7 @@ int main(int argc, char *argv[]) { network_init(); #endif - amrex::Real small_temp = 1.e-200; - amrex::Real small_dens = 1.e-200; - eos_init(small_temp, small_dens); + eos_init(castro::small_temp, castro::small_dens); exact_riemann(); diff --git a/Util/exact_riemann/riemann_shock.H b/Util/exact_riemann/riemann_shock.H index 3a74b6e3d3..a6bb04eb9e 100644 --- a/Util/exact_riemann/riemann_shock.H +++ b/Util/exact_riemann/riemann_shock.H @@ -6,6 +6,7 @@ #include #include +#include AMREX_INLINE void @@ -62,7 +63,7 @@ newton_shock(amrex::Real& W_s, const amrex::Real pstar, converged = false; int iter = 1; - while (! converged && iter < riemann_solver::max_iters) { + while (! converged && iter < castro::riemann_shock_maxiter) { amrex::Real rhostar_s, f, fprime; @@ -71,7 +72,7 @@ newton_shock(amrex::Real& W_s, const amrex::Real pstar, amrex::Real dW = -f / fprime; - if (std::abs(dW) < riemann_solver::tol * W_s) { + if (std::abs(dW) < castro::riemann_pstar_tol * W_s) { converged = true; } @@ -96,7 +97,7 @@ shock(const amrex::Real pstar, amrex::ignore_unused(u_s); - amrex::Real rhostar_hist[riemann_solver::max_iters], Ws_hist[riemann_solver::max_iters]; + amrex::Real rhostar_hist[riemann_constants::HISTORY_SIZE], Ws_hist[riemann_constants::HISTORY_SIZE]; // compute the Z_s function for a shock following C&G Eq. 20 and // 23. Here the "_s" variables are the state (L or R) that we are @@ -147,7 +148,7 @@ shock(const amrex::Real pstar, amrex::Real rhostar_s; if (taustar_s < 0.0_rt) { - rhostar_s = riemann_solver::smallrho; + rhostar_s = riemann_constants::small; W_s = std::sqrt((pstar - p_s) / (1.0_rt / rho_s - 1.0_rt / rhostar_s)); } @@ -162,7 +163,7 @@ shock(const amrex::Real pstar, // now did we converge? if (! converged) { - for (int i = 0; i < riemann_solver::max_iters; ++i) { + for (int i = 0; i < castro::riemann_shock_maxiter; ++i) { std::cout << i << " " << rhostar_hist[i] << " " << Ws_hist[i] << std::endl; }