Skip to content

Commit

Permalink
use std for math functions (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored Mar 26, 2024
1 parent 43923dd commit 63d649a
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 106 deletions.
4 changes: 2 additions & 2 deletions Source/BaseStateGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ void BaseStateGeometry::Init(const int max_radial_level_in,
const Real* dx_fine = geom[max_level].CellSize();
// nr_fine = nr_irreg + 1
for (auto i = 0; i < nr_fine; ++i) {
r_cc_loc(0, i) = sqrt(0.75 + 2.0 * Real(i)) * dx_fine[0];
r_cc_loc(0, i) = std::sqrt(0.75 + 2.0 * Real(i)) * dx_fine[0];
}
r_edge_loc(0) = 0.0;
for (auto i = 0; i < nr_fine; ++i) {
r_edge_loc(0, i + 1) =
sqrt(0.75 + 2.0 * (Real(i) + 0.5)) * dx_fine[0];
std::sqrt(0.75 + 2.0 * (Real(i) + 0.5)) * dx_fine[0];
}
} else {
for (auto i = 0; i < nr_fine; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions Source/MaestroAverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void Maestro::Average(const Vector<MultiFab>& phi, BaseState<Real>& phibar,

if (cell_valid) {
// compute distance to center
Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);

// figure out which radii index this point maps into
auto index = (int)amrex::Math::round(
Expand Down Expand Up @@ -444,7 +444,7 @@ void Maestro::Average(const Vector<MultiFab>& phi, BaseState<Real>& phibar,
amrex::min(stencil_coord, max_rcoord(which_lev(r)) - 1);

bool limit =
(r <= nrf - 1 - drdxfac_loc * pow(2.0, (fine_lev - 2)));
(r <= nrf - 1 - drdxfac_loc * std::pow(2.0, (fine_lev - 2)));

phibar_arr(0, r) =
QuadInterp(radius, radii(which_lev(r), stencil_coord),
Expand Down
6 changes: 3 additions & 3 deletions Source/MaestroBurner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ void Maestro::Burner(const Vector<MultiFab>& s_in, Vector<MultiFab>& s_out,

// check if sum{X_k} = 1
Real sumX = 0.0;
for (int n = 0; n < NumSpec; ++n) {
sumX += x_out[n];
for (auto X : x_out) {
sumX += X;
}

if (fabs(sumX - 1.0) > reaction_sum_tol) {
if (std::abs(sumX - 1.0) > reaction_sum_tol) {
#ifndef AMREX_USE_GPU
amrex::Print() << "ERROR: abundances do not sum to 1";
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/MaestroDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void Maestro::DiagFile(const int step, const Real t_in,
// weight is the factor by which the volume of a cell at the current level
// relates to the volume of a cell at the coarsest level of refinement.
const auto weight =
AMREX_SPACEDIM == 2 ? 1.0 / pow(4.0, lev) : 1.0 / pow(8.0, lev);
AMREX_SPACEDIM == 2 ? 1.0 / std::pow(4.0, lev) : 1.0 / std::pow(8.0, lev);

#if (AMREX_SPACEDIM == 3)
// for non-spherical we have to set these to be a valid array as
Expand Down
2 changes: 1 addition & 1 deletion Source/MaestroEnforceHSE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void Maestro::EnforceHSE(const BaseState<Real>& rho0_s, BaseState<Real>& p0_s,
if (r_end_coord(n, i) != base_geom.nr(n) - 1) {
for (auto l = n - 1; l >= 0; --l) {
for (auto r = (int)amrex::Math::round(
(r_end_coord(n, i) + 1) / pow(2, n - l));
(r_end_coord(n, i) + 1) / std::pow(2, n - l));
r <= base_geom.nr(l) - 1; ++r) {
p0(l, r) -= offset;
}
Expand Down
42 changes: 21 additions & 21 deletions Source/MaestroFill3dData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void Maestro::Put1dArrayOnCart(const int lev, const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
int index = cc_to_r(i, j, k);

Real rfac;
Expand Down Expand Up @@ -175,7 +175,7 @@ void Maestro::Put1dArrayOnCart(const int lev, const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
int index = cc_to_r(i, j, k);

Real s0_cart_val = s0_arr(0, index);
Expand Down Expand Up @@ -210,7 +210,7 @@ void Maestro::Put1dArrayOnCart(const int lev, const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);

auto index = int(radius / drf);
Real rfac = (radius - Real(index) * drf) / drf;
Expand Down Expand Up @@ -272,7 +272,7 @@ void Maestro::Put1dArrayOnCart(const int lev, const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);

Real s0_cart_val = 0.0;
Expand Down Expand Up @@ -513,7 +513,7 @@ void Maestro::MakeW0mac(Vector<std::array<MultiFab, AMREX_SPACEDIM> >& w0mac) {
Real y = prob_lo[1] + Real(j) * dx[1] - center_p[1];
Real z = prob_lo[2] + Real(k) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);
Real rfac = (radius - Real(index) * drf) / drf;

Expand Down Expand Up @@ -574,7 +574,7 @@ void Maestro::MakeW0mac(Vector<std::array<MultiFab, AMREX_SPACEDIM> >& w0mac) {
Real y = prob_lo[1] + (Real(j) + 0.5) * dx[1] - center_p[1];
Real z = prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);
Real w0_cart_val;

Expand Down Expand Up @@ -612,7 +612,7 @@ void Maestro::MakeW0mac(Vector<std::array<MultiFab, AMREX_SPACEDIM> >& w0mac) {
Real y = prob_lo[1] + Real(j) * dx[1] - center_p[1];
Real z = prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);
Real w0_cart_val;

Expand Down Expand Up @@ -650,7 +650,7 @@ void Maestro::MakeW0mac(Vector<std::array<MultiFab, AMREX_SPACEDIM> >& w0mac) {
Real y = prob_lo[1] + (Real(j) + 0.5) * dx[1] - center_p[1];
Real z = prob_lo[2] + Real(k) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);
Real w0_cart_val;

Expand Down Expand Up @@ -789,7 +789,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = (int)amrex::Math::round(
radius * radius / (dx[0] * dx[0]) - 0.375);
// closest radial index to edge-centered point
Expand Down Expand Up @@ -831,7 +831,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = (int)amrex::Math::round(
radius * radius / (dx[1] * dx[1]) - 0.375);
// closest radial index to edge-centered point
Expand Down Expand Up @@ -873,7 +873,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
prob_lo[1] + (Real(j) + 0.5) * dx[1] - center_p[1];
Real z = prob_lo[2] + Real(k) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = (int)amrex::Math::round(
radius * radius / (dx[2] * dx[2]) - 0.375);
// closest radial index to edge-centered point
Expand Down Expand Up @@ -916,7 +916,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = (int)amrex::Math::round(
radius * radius / (dx[0] * dx[0]) - 0.375);
// closest radial index to edge-centered point
Expand All @@ -942,7 +942,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = (int)amrex::Math::round(
radius * radius / (dx[1] * dx[1]) - 0.375);
// closest radial index to edge-centered point
Expand All @@ -968,7 +968,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
prob_lo[1] + (Real(j) + 0.5) * dx[1] - center_p[1];
Real z = prob_lo[2] + Real(k) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = (int)amrex::Math::round(
radius * radius / (dx[2] * dx[2]) - 0.375);
// closest radial index to edge-centered point
Expand Down Expand Up @@ -1014,7 +1014,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);

if (radius >= r_cc_loc(0, index)) {
Expand Down Expand Up @@ -1050,7 +1050,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);

if (radius >= r_cc_loc(0, index)) {
Expand Down Expand Up @@ -1086,7 +1086,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
prob_lo[1] + (Real(j) + 0.5) * dx[1] - center_p[1];
Real z = prob_lo[2] + Real(k) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);

if (radius >= r_cc_loc(0, index)) {
Expand Down Expand Up @@ -1123,7 +1123,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);

if (index == 0) {
Expand All @@ -1145,7 +1145,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
Real z =
prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);

if (index == 0) {
Expand All @@ -1167,7 +1167,7 @@ void Maestro::MakeS0mac(const BaseState<Real>& s0,
prob_lo[1] + (Real(j) + 0.5) * dx[1] - center_p[1];
Real z = prob_lo[2] + Real(k) * dx[2] - center_p[2];

Real radius = sqrt(x * x + y * y + z * z);
Real radius = std::sqrt(x * x + y * y + z * z);
auto index = int(radius / drf);

if (index == 0) {
Expand Down Expand Up @@ -1220,7 +1220,7 @@ void Maestro::MakeNormal() {
Real y = prob_lo[1] + (Real(j) + 0.5) * dx[1] - center_p[1];
Real z = prob_lo[2] + (Real(k) + 0.5) * dx[2] - center_p[2];

Real inv_radius = 1.0 / sqrt(x * x + y * y + z * z);
Real inv_radius = 1.0 / std::sqrt(x * x + y * y + z * z);

normal_arr(i, j, k, 0) = x * inv_radius;
normal_arr(i, j, k, 1) = y * inv_radius;
Expand Down
27 changes: 13 additions & 14 deletions Source/MaestroMakeBeta0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,12 @@ void Maestro::MakeBeta0(BaseState<Real>& beta0_s, const BaseState<Real>& rho0_s,
Real coeff3 = kappa * lambda / (mu * nu);

integral =
coeff1 * log((gamma1bar(n, r) +
0.5 * mu * dr(n)) /
(gamma1bar(n, r) -
0.5 * mu * dr(n))) +
coeff2 *
log((p0(n, r) + 0.5 * nu * dr(n)) /
(p0(n, r) - 0.5 * nu * dr(n))) -
coeff1 * std::log((gamma1bar(n, r) +
0.5 * mu * dr(n)) /
(gamma1bar(n, r) -
0.5 * mu * dr(n))) +
coeff2 * std::log((p0(n, r) + 0.5 * nu * dr(n)) /
(p0(n, r) - 0.5 * nu * dr(n))) -
coeff3 * dr(n);

} else {
Expand All @@ -211,12 +210,12 @@ void Maestro::MakeBeta0(BaseState<Real>& beta0_s, const BaseState<Real>& rho0_s,
integral =
(amrex::Math::abs(grav_cell(n, r)) /
denom) *
(coeff1 * log((gamma1bar(n, r) +
0.5 * mu * drp) /
(gamma1bar(n, r) -
0.5 * mu * drm)) -
coeff2 * log((p0(n, r) + 0.5 * nu * drp) /
(p0(n, r) - 0.5 * nu * drm)));
(coeff1 * std::log((gamma1bar(n, r) +
0.5 * mu * drp) /
(gamma1bar(n, r) -
0.5 * mu * drm)) -
coeff2 * std::log((p0(n, r) + 0.5 * nu * drp) /
(p0(n, r) - 0.5 * nu * drm)));
}
}

Expand Down Expand Up @@ -247,7 +246,7 @@ void Maestro::MakeBeta0(BaseState<Real>& beta0_s, const BaseState<Real>& rho0_s,
(base_geom.r_end_coord(n, j) + 1) / 2);

for (int i = n - 1; i >= 0; --i) {
auto refrat = (int)amrex::Math::round(pow(2, n - i));
auto refrat = (int)amrex::Math::round(std::pow(2, n - i));

// Offset the centered beta on level i above this point so the total
// integral is consistent
Expand Down
12 changes: 6 additions & 6 deletions Source/MaestroMakeEdgeState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void Maestro::MakeEdgeState1dSphr(BaseState<Real>& s_state,
if (sgn * (delam - alpham) >= 1.e-10) {
alphap = (-2.0 * delam -
2.0 * sgn *
sqrt(delam * delam - delam * alpham));
std::sqrt(delam * delam - delam * alpham));
} else {
alphap = -2.0 * alpham;
}
Expand All @@ -329,7 +329,7 @@ void Maestro::MakeEdgeState1dSphr(BaseState<Real>& s_state,
if (sgn * (delap - alphap) >= 1.e-10) {
alpham = (-2.0 * delap -
2.0 * sgn *
sqrt(delap * delap - delap * alphap));
std::sqrt(delap * delap - delap * alphap));
} else {
alpham = -2.0 * alphap;
}
Expand Down Expand Up @@ -861,8 +861,8 @@ void Maestro::MakeEdgeState1dPlanar(BaseState<Real>& s_state,
if (sgn * (delam - alpham) >= 1.e-10) {
alphap = (-2.0 * delam -
2.0 * sgn *
sqrt(delam * delam -
delam * alpham));
std::sqrt(delam * delam -
delam * alpham));
} else {
alphap = -2.0 * alpham;
}
Expand All @@ -877,8 +877,8 @@ void Maestro::MakeEdgeState1dPlanar(BaseState<Real>& s_state,
if (sgn * (delap - alphap) >= 1.e-10) {
alpham = (-2.0 * delap -
2.0 * sgn *
sqrt(delap * delap -
delap * alphap));
std::sqrt(delap * delap -
delap * alphap));
} else {
alpham = -2.0 * alphap;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/MaestroMakew0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void Maestro::Makew0Planar(
w0_arr(n - 1, (base_geom.r_end_coord(n, j) + 1) / 2);

for (auto i = n - 1; i >= 0; --i) {
auto refrat = (int)amrex::Math::round(pow(2, n - i));
auto refrat = (int)amrex::Math::round(std::pow(2, n - i));

// Restrict w0 from level n to level i
for (auto r = base_geom.r_start_coord(n, j);
Expand Down
Loading

0 comments on commit 63d649a

Please sign in to comment.