Skip to content

Commit

Permalink
split constants into riemann_constants.H (#2896)
Browse files Browse the repository at this point in the history
this will make it easier to use this for non-castro things (like
exact_riemann)
  • Loading branch information
zingale committed Jul 9, 2024
1 parent 21d7f32 commit 6aff478
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 22 deletions.
2 changes: 0 additions & 2 deletions Source/driver/Castro.H
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ using namespace castro;

#include <params_type.H>

#include <riemann_type.H>

using std::istream;
using std::ostream;

Expand Down
2 changes: 2 additions & 0 deletions Source/driver/Castro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
#include <ambient.H>
#include <castro_limits.H>

#include <riemann_constants.H>

using namespace amrex;

bool Castro::signalStopJob = false;
Expand Down
1 change: 1 addition & 0 deletions Source/hydro/Make.package
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Source/hydro/riemann_2shock_solvers.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using namespace amrex::literals;

#include <riemann_constants.H>
#include <riemann_type.H>
#ifdef RADIATION
#include <Radiation.H>
Expand Down
16 changes: 16 additions & 0 deletions Source/hydro/riemann_constants.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef RIEMANN_CONSTANTS_H
#define RIEMANN_CONSTANTS_H

#include <AMReX_REAL.H>

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
11 changes: 0 additions & 11 deletions Source/hydro/riemann_type.H
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Util/exact_riemann/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions Util/exact_riemann/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
11 changes: 6 additions & 5 deletions Util/exact_riemann/riemann_shock.H
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <eos_type.H>
#include <eos.H>

#include <riemann_constants.H>

AMREX_INLINE
void
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}

Expand All @@ -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
Expand Down Expand Up @@ -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));
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 6aff478

Please sign in to comment.