Skip to content

Commit

Permalink
move Riemann history constants to riemann_constants namespace (#2895)
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Jul 9, 2024
1 parent 79841a7 commit 21d7f32
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
6 changes: 2 additions & 4 deletions Source/driver/Castro.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ using namespace castro;

#include <fundamental_constants.H>

constexpr int HISTORY_SIZE=40;
constexpr int PSTAR_BISECT_FACTOR = 5;


#include <AMReX_BC_TYPES.H>
#include <AMReX_AmrLevel.H>
#include <AMReX_iMultiFab.H>
Expand Down Expand Up @@ -50,6 +46,8 @@ constexpr int PSTAR_BISECT_FACTOR = 5;

#include <params_type.H>

#include <riemann_type.H>

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

Expand Down
2 changes: 1 addition & 1 deletion Source/driver/Castro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
10 changes: 5 additions & 5 deletions Source/hydro/riemann_2shock_solvers.H
Original file line number Diff line number Diff line change
Expand Up @@ -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<amrex::Real, PSTAR_BISECT_FACTOR*HISTORY_SIZE>& pstar_hist_extra) {
bool& converged, amrex::GpuArray<amrex::Real, riemann_constants::PSTAR_BISECT_FACTOR * riemann_constants::HISTORY_SIZE>& pstar_hist_extra) {

// we want to zero
// f(p*) = u*_l(p*) - u*_r(p*)
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 * 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;
Expand Down Expand Up @@ -167,7 +167,7 @@ namespace TwoShock {
constexpr amrex::Real weakwv = 1.e-3_rt;

#ifndef AMREX_USE_GPU
amrex::GpuArray<amrex::Real, HISTORY_SIZE> pstar_hist;
amrex::GpuArray<amrex::Real, riemann_constants::HISTORY_SIZE> pstar_hist;
#endif


Expand Down Expand Up @@ -336,7 +336,7 @@ namespace TwoShock {
pstarl = amrex::max(pstarl, small_pres);
pstaru = amrex::max(pstaru, small_pres);

amrex::GpuArray<amrex::Real, PSTAR_BISECT_FACTOR*HISTORY_SIZE> pstar_hist_extra;
amrex::GpuArray<amrex::Real, riemann_constants::PSTAR_BISECT_FACTOR * riemann_constants::HISTORY_SIZE> pstar_hist_extra;

pstar_bisection(pstarl, pstaru,
ql.un, ql.p, taul, gamel, clsql,
Expand All @@ -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;
}

Expand Down
10 changes: 7 additions & 3 deletions Source/hydro/riemann_type.H
Original file line number Diff line number Diff line change
Expand Up @@ -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;


}


Expand Down

0 comments on commit 21d7f32

Please sign in to comment.