From 0bdd53b2a38043382cdb44a82ca6a9e1e7fb8797 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Wed, 16 Oct 2024 16:59:00 -0400 Subject: [PATCH] Use constexpr to define tolerance parameter in a single place --- src/colvar.cpp | 4 +--- src/colvar.h | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/colvar.cpp b/src/colvar.cpp index 88df7c45c..e19fce5fb 100644 --- a/src/colvar.cpp +++ b/src/colvar.cpp @@ -2207,12 +2207,10 @@ int colvar::set_cvc_param(std::string const ¶m_name, void const *new_value) bool colvar::periodic_boundaries(colvarvalue const &lb, colvarvalue const &ub) const { if (period > 0.0) { - if ( ((cvm::sqrt(this->dist2(lb, ub))) / this->width) - < 1.0E-10 ) { + if (((cvm::sqrt(this->dist2(lb, ub))) / this->width) < colvar_boundaries_tol) { return true; } } - return false; } diff --git a/src/colvar.h b/src/colvar.h index 65cdddee9..8a8bd72b6 100644 --- a/src/colvar.h +++ b/src/colvar.h @@ -262,7 +262,7 @@ class colvar : public colvarparse, public colvardeps { /// Init defaults for grid options int init_grid_parameters(std::string const &conf); - + /// Consistency check for the grid paramaters int check_grid_parameters(); @@ -784,4 +784,10 @@ inline void colvar::reset_bias_force() { fb_actual.reset(); } + +namespace { + // Tolerance parameter to decide when two boundaries coincide + constexpr cvm::real colvar_boundaries_tol = 1.0e-10; +} + #endif