From 6603749d6dff2075408e995d9ac51dde4f96c82e Mon Sep 17 00:00:00 2001 From: Gareth Tribello <gareth.tribello@gmail.com> Date: Thu, 29 Aug 2019 21:03:54 +0100 Subject: [PATCH] Addresses issue #441. The problem with convert to fes and periodic variables --- src/gridtools/GridVessel.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gridtools/GridVessel.cpp b/src/gridtools/GridVessel.cpp index 67bfc582b..6d639faea 100644 --- a/src/gridtools/GridVessel.cpp +++ b/src/gridtools/GridVessel.cpp @@ -95,10 +95,12 @@ void GridVessel::setBounds( const std::vector<std::string>& smin, const std::vec Tools::convert( str_min[i], min[i] ); Tools::convert( str_max[i], max[i] ); if( spacing.size()==dimension && binsin.size()==dimension ) { - double range = max[i] - min[i]; unsigned spc = std::floor( range / spacing[i]); - // This check ensures that nbins is set correctly if spacing is set the same as the number of bins - if( fabs( binsin[i]*spacing[i]-range )>epsilon ) spc += 1; - if( spc>binsin[i] ) nbin[i]=spc; else nbin[i]=binsin[i]; + if( spacing[i]==0 ) nbin[i] = binsin[i]; + else { + double range = max[i] - min[i]; nbin[i] = std::ceil( range / spacing[i]); + // This check ensures that nbins is set correctly if spacing is set the same as the number of bins + if( nbin[i]!=binsin[i] ) plumed_merror("mismatch between input spacing and input number of bins"); + } } else if( binsin.size()==dimension ) nbin[i]=binsin[i]; else if( spacing.size()==dimension ) nbin[i] = std::floor(( max[i] - min[i] ) / spacing[i]) + 1; else plumed_error(); -- GitLab