Skip to content

Commit

Permalink
more fabs
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Jan 28, 2024
1 parent 8ea151b commit e0f06fd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions Diagnostics/DustCollapse/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ int main(int argc, char* argv[])
#if (AMREX_SPACEDIM == 1)
int nbins = domain.length(0);
#elif (AMREX_SPACEDIM == 2)
auto x_maxdist = fmax(fabs(problo[0]), fabs(probhi[0]));
auto y_maxdist = fmax(fabs(problo[1] - yctr), fabs(probhi[1] - yctr));
auto x_maxdist = std::max(std::abs(problo[0]), std::abs(probhi[0]));
auto y_maxdist = std::max(std::abs(problo[1] - yctr), std::abs(probhi[1] - yctr));

auto max_dist = std::sqrt(x_maxdist*x_maxdist + y_maxdist*y_maxdist);

Expand Down Expand Up @@ -210,21 +210,21 @@ int main(int argc, char* argv[])
// analytic expression for the radius as a function of time t = 0.00
Real max_dens = 1.e9;

if (fabs(data.Time()) <= 1.e-8)
if (std::abs(data.Time()) <= 1.e-8)
max_dens = 1.e9;
else if (fabs(data.Time() - 0.01) <= 1.e-8)
else if (std::abs(data.Time() - 0.01) <= 1.e-8)
max_dens = 1.043345e9;
else if (fabs(data.Time() - 0.02) <= 1.e-8)
else if (std::abs(data.Time() - 0.02) <= 1.e-8)
max_dens = 1.192524e9;
else if (fabs(data.Time() - 0.03) <= 1.e-8)
else if (std::abs(data.Time() - 0.03) <= 1.e-8)
max_dens = 1.527201e9;
else if (fabs(data.Time() - 0.04) <= 1.e-8)
else if (std::abs(data.Time() - 0.04) <= 1.e-8)
max_dens = 2.312884e9;
else if (fabs(data.Time() - 0.05) <= 1.e-8)
else if (std::abs(data.Time() - 0.05) <= 1.e-8)
max_dens = 4.779133e9;
else if (fabs(data.Time() - 0.06) <= 1.e-8)
else if (std::abs(data.Time() - 0.06) <= 1.e-8)
max_dens = 24.472425e9;
else if (fabs(data.Time() - 0.065) <= 1.e-8)
else if (std::abs(data.Time() - 0.065) <= 1.e-8)
max_dens = 423.447291e9;
else {
Print() << "Dont know the maximum density at this time: " << data.Time() <<std::endl;
Expand Down
2 changes: 1 addition & 1 deletion Diagnostics/Radiation/Radiation_utils.H
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void WriteSlicefile(const int nbins, const Vector<Real> r,
slicefile << std::setw(w) << r[i];

for (auto it=vars.begin(); it!=vars.end(); ++it) {
if(fabs((*it)[i]) < SMALL) (*it)[i] = 0.0;
if(std::abs((*it)[i]) < SMALL) (*it)[i] = 0.0;
slicefile << std::setw(w) << (*it)[i];
}

Expand Down
2 changes: 1 addition & 1 deletion Diagnostics/Radiation/lgt_frnt1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int argc, char* argv[])

// compute the size of the radially-binned array -- we'll do it to
// the furtherest corner of the domain
double maxdist = fabs(probhi[0] - problo[0]);
double maxdist = std::abs(probhi[0] - problo[0]);
double dx_fine = *(std::min_element(dx.begin(), dx.end()));
int nbins = int(maxdist / dx_fine);

Expand Down
10 changes: 5 additions & 5 deletions Diagnostics/Sedov/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int main(int argc, char* argv[])

#else
double x_maxdist = amrex::max(std::abs(probhi[0] - xctr),
std::fabs(problo[0] - xctr));
std::abs(problo[0] - xctr));
double y_maxdist = amrex::max(std::abs(probhi[1] - yctr),
std::abs(problo[1] - yctr));
double z_maxdist = amrex::max(std::abs(probhi[2] - zctr),
Expand Down Expand Up @@ -342,10 +342,10 @@ int main(int argc, char* argv[])
// write the data in columns
const auto SMALL = 1.e-20;
for (auto i = 0; i < nbins; i++) {
if (fabs(dens_bin[i]) < SMALL) dens_bin[i] = 0.0;
if (fabs( vel_bin[i]) < SMALL) vel_bin[i] = 0.0;
if (fabs(pres_bin[i]) < SMALL) pres_bin[i] = 0.0;
if (fabs( e_bin[i]) < SMALL) e_bin[i] = 0.0;
if (std::abs(dens_bin[i]) < SMALL) dens_bin[i] = 0.0;
if (std::abs( vel_bin[i]) < SMALL) vel_bin[i] = 0.0;
if (std::abs(pres_bin[i]) < SMALL) pres_bin[i] = 0.0;
if (std::abs( e_bin[i]) < SMALL) e_bin[i] = 0.0;

slicefile << std::setw(w) << r[i] << std::setw(w) << dens_bin[i] << std::setw(w) << vel_bin[i] << std::setw(w) << pres_bin[i] << std::setw(w) << e_bin[i] << std::endl;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/driver/Castro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,13 +984,13 @@ Castro::initData ()
// make sure dx = dy = dz -- that's all we guarantee to support
#if (AMREX_SPACEDIM == 2)
const Real SMALL = 1.e-13;
if (fabs(dx[0] - dx[1]) > SMALL*dx[0])
if (std::abs(dx[0] - dx[1]) > SMALL*dx[0])
{
amrex::Abort("We don't support dx != dy");
}
#elif (AMREX_SPACEDIM == 3)
const Real SMALL = 1.e-13;
if ( (fabs(dx[0] - dx[1]) > SMALL*dx[0]) || (fabs(dx[0] - dx[2]) > SMALL*dx[0]) )
if ( (std::abs(dx[0] - dx[1]) > SMALL*dx[0]) || (std::abs(dx[0] - dx[2]) > SMALL*dx[0]) )
{
amrex::Abort("We don't support dx != dy != dz");
}
Expand Down

0 comments on commit e0f06fd

Please sign in to comment.