Skip to content

Commit

Permalink
Qualify round() as std::round().
Browse files Browse the repository at this point in the history
  • Loading branch information
bangerth committed Oct 10, 2024
1 parent 2d52085 commit 6c3508b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions source/mesh_deformation/fastscape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ namespace aspect
if (dim == 2)
{
fastscape_dy = fastscape_dx;
fastscape_y_extent = round(fastscape_y_extent_2d/fastscape_dy)*fastscape_dy + fastscape_dy * ghost_nodes;
fastscape_y_extent = std::round(fastscape_y_extent_2d/fastscape_dy)*fastscape_dy + fastscape_dy * ghost_nodes;
fastscape_ny = 1+fastscape_y_extent/fastscape_dy;
}
else
Expand Down Expand Up @@ -637,7 +637,7 @@ namespace aspect
// same rule is used for all cell sizes, higher resolution areas will have interpolation
// points that do not correspond to a FastScape node. In which case, indx will not be a
// whole number and we can ignore the point.
if (std::abs(indx - round(indx)) >= node_tolerance)
if (std::abs(indx - std::round(indx)) >= node_tolerance)
continue;


Expand All @@ -652,7 +652,7 @@ namespace aspect
// this to correctly place the variables later on.
// Nx*ys effectively tells us what row we are in
// and then indx tells us what position in that row.
const double index = round(indx)+fastscape_nx*ys;
const double index = std::round(indx)+fastscape_nx*ys;

local_aspect_values[0].push_back(vertex(dim-1) - grid_extent[dim-1].second);
local_aspect_values[1].push_back(index-1);
Expand All @@ -670,10 +670,10 @@ namespace aspect
// Because indy only gives us the row we're in, we don't need to add 2 for the ghost node.
const double indy = 1+use_ghost_nodes+(vertex(1) - grid_extent[1].first)/fastscape_dy;

if (std::abs(indy - round(indy)) >= node_tolerance)
if (std::abs(indy - std::round(indy)) >= node_tolerance)
continue;

const double index = round((indy-1))*fastscape_nx+round(indx);
const double index = std::round((indy-1))*fastscape_nx+std::round(indx);

local_aspect_values[0].push_back(vertex(dim-1) - grid_extent[dim-1].second); //z component
local_aspect_values[1].push_back(index-1);
Expand Down Expand Up @@ -1400,7 +1400,7 @@ namespace aspect
// If we do not average the values, then use a slice near the center.
if (!average_out_of_plane_surface_topography)
{
const unsigned int index = x+fastscape_nx*(round((fastscape_ny-use_ghost_nodes)/2));
const unsigned int index = x+fastscape_nx*(std::round((fastscape_ny-use_ghost_nodes)/2));

// If we are using the ghost nodes, then the x value locations need to be shifted back 1
// e.g., given a 4x4 mesh an index of 5 would correspond to an x of 1 and y of 1 in the loop,
Expand Down
4 changes: 2 additions & 2 deletions source/particle/generator/uniform_box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ namespace aspect
for (unsigned int i = 0; i < dim; ++i)
{
#if DEAL_II_VERSION_GTE(9,6,0)
n_particles_per_direction[i] = static_cast<unsigned int>(round(std::pow(n_particles * Utilities::pow(P_diff[i],dim) / volume, 1./dim)));
n_particles_per_direction[i] = static_cast<unsigned int>(std::round(std::pow(n_particles * Utilities::pow(P_diff[i],dim) / volume, 1./dim)));
#else
n_particles_per_direction[i] = static_cast<unsigned int>(round(std::pow(n_particles * std::pow(P_diff[i],dim) / volume, 1./dim)));
n_particles_per_direction[i] = static_cast<unsigned int>(std::round(std::pow(n_particles * std::pow(P_diff[i],dim) / volume, 1./dim)));
#endif

spacing[i] = P_diff[i] / fmax(n_particles_per_direction[i] - 1,1);
Expand Down
8 changes: 4 additions & 4 deletions source/particle/generator/uniform_radial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace aspect
for (unsigned int i = 0; i < radial_layers; ++i)
{
const double radius = P_min[0] + (radial_spacing * i);
particles_per_layer[i] = static_cast<unsigned int>(round(n_particles * radius / total_radius));
particles_per_layer[i] = static_cast<unsigned int>(std::round(n_particles * radius / total_radius));
}
}
else if (dim == 3)
Expand All @@ -59,7 +59,7 @@ namespace aspect
for (unsigned int i = 0; i < radial_layers; ++i)
{
const double area = Utilities::fixed_power<2>(P_min[0] + (radial_spacing * i));
particles_per_layer[i] = static_cast<unsigned int>(round(n_particles * area / total_area));
particles_per_layer[i] = static_cast<unsigned int>(std::round(n_particles * area / total_area));
}
}
else
Expand Down Expand Up @@ -87,9 +87,9 @@ namespace aspect
else if (dim == 3)
{
const unsigned int theta_particles = static_cast<unsigned int>(
round(sqrt(particles_per_layer[i])));
std::round(sqrt(particles_per_layer[i])));
const unsigned int phi_particles = static_cast<unsigned int>(
round(
std::round(
static_cast<double>(particles_per_layer[i])
/
static_cast<double>(theta_particles)));
Expand Down
2 changes: 1 addition & 1 deletion source/simulator/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2218,7 +2218,7 @@ namespace aspect
pcout << "\nWARNING: During this computation " << nonlinear_solver_failures << " nonlinear solver failures occurred!" << std::endl;

pcout << "-- Total wallclock time elapsed including restarts: "
<< round(wall_timer.wall_time()+total_walltime_until_last_snapshot)
<< std::round(wall_timer.wall_time()+total_walltime_until_last_snapshot)
<< 's' << std::endl;

CitationInfo::print_info_block (pcout);
Expand Down
4 changes: 2 additions & 2 deletions source/simulator/helper_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ namespace aspect
{
computing_timer.print_summary ();
pcout << "-- Total wallclock time elapsed including restarts: "
<< round(wall_timer.wall_time()+total_walltime_until_last_snapshot)
<< std::round(wall_timer.wall_time()+total_walltime_until_last_snapshot)
<< 's' << std::endl;
}

Expand Down Expand Up @@ -666,7 +666,7 @@ namespace aspect
{
computing_timer.print_summary ();
pcout << "-- Total wallclock time elapsed including restarts: "
<< round(wall_timer.wall_time()+total_walltime_until_last_snapshot)
<< std::round(wall_timer.wall_time()+total_walltime_until_last_snapshot)
<< 's' << std::endl;
}
}
Expand Down

0 comments on commit 6c3508b

Please sign in to comment.