update a few more rounding cases with std::lround()
This commit is contained in:
@ -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; }
|
||||
|
||||
|
||||
@ -3113,9 +3113,9 @@ void FixSRD::setup_velocity_bins()
|
||||
{
|
||||
// require integer # of bins across global domain
|
||||
|
||||
nbin1x = static_cast<int>(domain->xprd / gridsrd + 0.5);
|
||||
nbin1y = static_cast<int>(domain->yprd / gridsrd + 0.5);
|
||||
nbin1z = static_cast<int>(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;
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
#ifndef LMP_TABULAR_FUNCTION_H
|
||||
#define LMP_TABULAR_FUNCTION_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user