diff --git a/src/LATBOLTZ/fix_lb_fluid.cpp b/src/LATBOLTZ/fix_lb_fluid.cpp index d5161bba42..4352e5ca18 100644 --- a/src/LATBOLTZ/fix_lb_fluid.cpp +++ b/src/LATBOLTZ/fix_lb_fluid.cpp @@ -438,9 +438,9 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) : //-------------------------------------------------------------------------- // Set the total number of grid points in each direction. //-------------------------------------------------------------------------- - Nbx = (int) (domain->xprd / dx_lb + 0.5); - Nby = (int) (domain->yprd / dx_lb + 0.5); - Nbz = (int) (domain->zprd / dx_lb + 0.5); + Nbx = std::lround(domain->xprd / dx_lb); + Nby = std::lround(domain->yprd / dx_lb); + Nbz = std::lround(domain->zprd / dx_lb); //-------------------------------------------------------------------------- // Set the number of grid points in each dimension for the local subgrids. @@ -739,9 +739,9 @@ void FixLbFluid::init() // between runs. //-------------------------------------------------------------------------- int Nbx_now, Nby_now, Nbz_now; - Nbx_now = (int) (domain->xprd / dx_lb + 0.5); - Nby_now = (int) (domain->yprd / dx_lb + 0.5); - Nbz_now = (int) (domain->zprd / dx_lb + 0.5); + Nbx_now = std::lround(domain->xprd / dx_lb); + Nby_now = std::lround(domain->yprd / dx_lb); + Nbz_now = std::lround(domain->zprd / dx_lb); // If there are walls in the z-direction add an extra grid point. if (domain->periodicity[2] == 0) { Nbz_now += 1; } diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index 6b8ce1e9d6..7c34d142e9 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -3113,9 +3113,9 @@ void FixSRD::setup_velocity_bins() { // require integer # of bins across global domain - nbin1x = static_cast(domain->xprd / gridsrd + 0.5); - nbin1y = static_cast(domain->yprd / gridsrd + 0.5); - nbin1z = static_cast(domain->zprd / gridsrd + 0.5); + nbin1x = std::lround(domain->xprd / gridsrd); + nbin1y = std::lround(domain->yprd / gridsrd); + nbin1z = std::lround(domain->zprd / gridsrd); if (dimension == 2) nbin1z = 1; if (nbin1x == 0) nbin1x = 1; diff --git a/src/tabular_function.h b/src/tabular_function.h index 05f75a31e4..3531a1972b 100644 --- a/src/tabular_function.h +++ b/src/tabular_function.h @@ -14,6 +14,8 @@ #ifndef LMP_TABULAR_FUNCTION_H #define LMP_TABULAR_FUNCTION_H +#include + namespace LAMMPS_NS { class TabularFunction { public: @@ -35,7 +37,7 @@ class TabularFunction { void value(double x, double &y, int ny, double &y1, int ny1) { double ps = (x - xmin) * rdx; - int ks = ps + 0.5; + int ks = std::lround(ps); if (ks > size - 1) ks = size - 1; if (ks < 0) ks = 0; ps = ps - ks;