Skip to content

Commit

Permalink
fix std::clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Feb 12, 2025
1 parent 29891b2 commit 811f4f7
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Source/hydro/Castro_ctu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ Castro::add_sdc_source_to_states(const Box& bx, const int idir, const Real dt,

if (n >= QFS && n <= QFS-1+NumSpec) {
// mass fractions should be in [0, 1]
qleft(i,j,k,n) = std::clamp(qleft(i,j,k,n), 0.0_rt, 1.0_rt);
qright(i,j,k,n) = std::clamp(qright(i,j,k,n), 0.0_rt, 1.0_rt);
qleft(i,j,k,n) = amrex::Clamp(qleft(i,j,k,n), 0.0_rt, 1.0_rt);
qright(i,j,k,n) = amrex::Clamp(qright(i,j,k,n), 0.0_rt, 1.0_rt);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/hydro/HLL_solvers.H
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ namespace HLL {
}

Real frac = (1.0_rt + (spout + spin)/scr)*0.5_rt;
frac = std::clamp(frac, 0.0_rt, 1.0_rt);
frac = amrex::Clamp(frac, 0.0_rt, 1.0_rt);

Real qint[NQ] = {0.0};

Expand Down
12 changes: 6 additions & 6 deletions Source/hydro/flatten.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Real flatten(int i, int j, int k,

Real denom = std::max(small_pres, std::abs(q_arr(i+2,j,k,pres_comp) - q_arr(i-2,j,k,pres_comp)));
Real zeta = std::abs(dp) / denom;
Real z = std::clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);
Real z = amrex::Clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);

Real tst = 0.0_rt;
if (q_arr(i-1,j,k,QU) - q_arr(i+1,j,k,QU) >= 0.0_rt) {
Expand All @@ -43,7 +43,7 @@ Real flatten(int i, int j, int k,

denom = std::max(small_pres, std::abs(q_arr(i+2-ishft,j,k,pres_comp)-q_arr(i-2-ishft,j,k,pres_comp)));
zeta = std::abs(dp) / denom;
Real z2 = std::clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);
Real z2 = amrex::Clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);

tst = 0.0_rt;
if (q_arr(i-1-ishft,j,k,QU) - q_arr(i+1-ishft,j,k,QU) >= 0.0_rt) {
Expand All @@ -69,7 +69,7 @@ Real flatten(int i, int j, int k,

denom = std::max(small_pres, std::abs(q_arr(i,j+2,k,pres_comp) - q_arr(i,j-2,k,pres_comp)));
zeta = std::abs(dp) / denom;
z = std::clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);
z = amrex::Clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);

tst = 0.0_rt;
if (q_arr(i,j-1,k,QV) - q_arr(i,j+1,k,QV) >= 0.0_rt) {
Expand All @@ -88,7 +88,7 @@ Real flatten(int i, int j, int k,

denom = std::max(small_pres, std::abs(q_arr(i,j+2-ishft,k,pres_comp) - q_arr(i,j-2-ishft,k,pres_comp)));
zeta = std::abs(dp) / denom;
z2 = std::clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);
z2 = amrex::Clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);

tst = 0.0_rt;
if (q_arr(i,j-1-ishft,k,QV) - q_arr(i,j+1-ishft,k,QV) >= 0.0_rt) {
Expand All @@ -115,7 +115,7 @@ Real flatten(int i, int j, int k,

denom = std::max(small_pres, std::abs(q_arr(i,j,k+2,pres_comp) - q_arr(i,j,k-2,pres_comp)));
zeta = std::abs(dp) / denom;
z = std::clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);
z = amrex::Clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);

tst = 0.0_rt;
if (q_arr(i,j,k-1,QW) - q_arr(i,j,k+1,QW) >= 0.0_rt) {
Expand All @@ -134,7 +134,7 @@ Real flatten(int i, int j, int k,

denom = std::max(small_pres, std::abs(q_arr(i,j,k+2-ishft,pres_comp) - q_arr(i,j,k-2-ishft,pres_comp)));
zeta = std::abs(dp) / denom;
z2 = std::clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);
z2 = amrex::Clamp(dzcut * (zeta - zcut1), 0.0_rt, 1.0_rt);

tst = 0.0_rt;
if (q_arr(i,j,k-1-ishft,QW) - q_arr(i,j,k+1-ishft,QW) >= 0.0_rt) {
Expand Down
4 changes: 2 additions & 2 deletions Source/hydro/ppm.H
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ppm_reconstruct(const amrex::Real* s,

// Make sure sedge lies in between adjacent cell-centered values

sm = std::clamp(sm, std::min(s[i0], s[im1]), std::max(s[i0], s[im1]));
sm = amrex::Clamp(sm, std::min(s[i0], s[im1]), std::max(s[i0], s[im1]));

// Compute van Leer slopes

Expand Down Expand Up @@ -115,7 +115,7 @@ ppm_reconstruct(const amrex::Real* s,

// Make sure sedge lies in between adjacent cell-centered values

sp = std::clamp(sp, std::min(s[ip1], s[i0]), std::max(s[ip1], s[i0]));
sp = amrex::Clamp(sp, std::min(s[ip1], s[i0]), std::max(s[ip1], s[i0]));


// Flatten the parabola
Expand Down
4 changes: 2 additions & 2 deletions Source/hydro/riemann_2shock_solvers.H
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace TwoShock {

// CG Eq. 31
gstar = (pstar-p)*gdot/(pstar+p) + gam;
gstar = std::clamp(gstar, gmin, gmax);
gstar = amrex::Clamp(gstar, gmin, gmax);

// Now use that predicted value of game with the R-H jump conditions
// to compute the wave speed.
Expand Down Expand Up @@ -666,7 +666,7 @@ namespace TwoShock {

// interpolate for the case that we are in a rarefaction
amrex::Real frac = (1.0_rt + (spout + spin)/scr)*0.5_rt;
frac = std::clamp(frac, 0.0_rt, 1.0_rt);
frac = amrex::Clamp(frac, 0.0_rt, 1.0_rt);

qint.rho = frac*rstar + (1.0_rt - frac)*ro;
qint.un = frac*ustar + (1.0_rt - frac)*uo;
Expand Down
2 changes: 1 addition & 1 deletion Source/sdc/sdc_react_util.H
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ single_zone_react_source(burn_t& burn_state,
eos(eos_input_re, burn_state);

// eos_get_small_temp(&small_temp);
burn_state.T = std::clamp(burn_state.T, small_temp, integrator_rp::MAX_TEMP);
burn_state.T = amrex::Clamp(burn_state.T, small_temp, integrator_rp::MAX_TEMP);

Array1D<Real, 1, neqs> ydot;

Expand Down
2 changes: 1 addition & 1 deletion Util/exact_riemann/exact_riemann_shock.H
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ newton_shock(amrex::Real& W_s, const amrex::Real pstar,
converged = true;
}

W_s = std::clamp(W_s + dW, 0.5_rt * W_s, 2.0_rt * W_s);
W_s = amrex::Clamp(W_s + dW, 0.5_rt * W_s, 2.0_rt * W_s);

// store some history

Expand Down
2 changes: 1 addition & 1 deletion Util/exact_riemann/exact_riemann_star_state.H
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ riemann_star_state(const amrex::Real rho_l, const amrex::Real u_l, const amrex::
}

// get ready for the next iteration
pstar = std::clamp(pstar_new, 0.5 * pstar, 2.0 * pstar);
pstar = amrex::Clamp(pstar_new, 0.5 * pstar, 2.0 * pstar);

iter++;
}
Expand Down
2 changes: 1 addition & 1 deletion Util/model_parser/model_parser.H
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ interpolate(const Real r, const int var_index, const int model_index=0) {
model::profile(model_index).state(id, var_index));
Real maxvar = std::max(model::profile(model_index).state(id+1, var_index),
model::profile(model_index).state(id, var_index));
interp = std::clamp(interp, minvar, maxvar);
interp = amrex::Clamp(interp, minvar, maxvar);
}

return interp;
Expand Down

0 comments on commit 811f4f7

Please sign in to comment.