*/
static bool anyDimUsesPull(const AwhBiasParams& awhBiasParams)
{
- for (const auto& awhDimParam : awhBiasParams.dimParams())
- {
- if (awhDimParam.coordinateProvider() == AwhCoordinateProviderType::Pull)
- {
- return true;
- }
- }
- return false;
+ return std::any_of(
+ awhBiasParams.dimParams().begin(), awhBiasParams.dimParams().end(), [](const auto& awhDimParam) {
+ return awhDimParam.coordinateProvider() == AwhCoordinateProviderType::Pull;
+ });
}
/*! \brief Checks whether any dimension uses pulling as a coordinate provider.
*/
static bool anyDimUsesPull(const AwhParams& awhParams)
{
- for (const auto& awhBiasParam : awhParams.awhBiasParams())
- {
- if (anyDimUsesPull(awhBiasParam))
- {
- return true;
- }
- }
- return false;
+ return std::any_of(awhParams.awhBiasParams().begin(),
+ awhParams.awhBiasParams().end(),
+ [](const auto& awhBiasParam) { return anyDimUsesPull(awhBiasParam); });
}
/*! \brief Checks whether any dimension uses pulling as a coordinate provider.
*/
static bool anyDimUsesPull(const ArrayRef<BiasCoupledToSystem> biasCoupledToSystem)
{
- for (const auto& biasCts : biasCoupledToSystem)
- {
- if (!biasCts.pullCoordIndex_.empty())
- {
- return true;
- }
- }
- return false;
+ return std::any_of(biasCoupledToSystem.begin(), biasCoupledToSystem.end(), [](const auto& biasCts) {
+ return !biasCts.pullCoordIndex_.empty();
+ });
}
BiasCoupledToSystem::BiasCoupledToSystem(Bias bias, const std::vector<int>& pullCoordIndex) :
/* Get the total number of energy subblocks that AWH needs */
int numSubblocks = 0;
- for (auto& biasCoupledToSystem : biasCoupledToSystem_)
+ for (const auto& biasCoupledToSystem : biasCoupledToSystem_)
{
numSubblocks += biasCoupledToSystem.bias_.numEnergySubblocksToWrite();
}
/* Transfer AWH data blocks to energy sub blocks */
int energySubblockCount = 0;
- for (auto& biasCoupledToSystem : biasCoupledToSystem_)
+ for (const auto& biasCoupledToSystem : biasCoupledToSystem_)
{
energySubblockCount += biasCoupledToSystem.bias_.writeToEnergySubblocks(
&(awhEnergyBlock->sub[energySubblockCount]));
/* Check whether the bias(es) that has/have a FEP lambda dimension should sample coordinates
* this step. Since the biases may have different sampleCoordStep it is necessary to check
* this combination. */
- for (const auto& biasCts : biasCoupledToSystem_)
- {
- if (biasCts.bias_.hasFepLambdaDimension() && biasCts.bias_.isSampleCoordStep(step))
- {
- return true;
- }
- }
- return false;
+ return std::any_of(biasCoupledToSystem_.begin(), biasCoupledToSystem_.end(), [step](const auto& biasCts) {
+ return biasCts.bias_.hasFepLambdaDimension() && biasCts.bias_.isSampleCoordStep(step);
+ });
}
std::unique_ptr<Awh> prepareAwhModule(FILE* fplog,
*/
bool isOutputStep(int64_t step) const;
-private:
std::vector<BiasCoupledToSystem> biasCoupledToSystem_; /**< AWH biases and definitions of their coupling to the system. */
const int64_t seed_; /**< Random seed for MC jumping with umbrella type bias potential. */
const int nstout_; /**< Interval in steps for writing to energy file. */
{
double freeEnergyWeights = 0;
const GridPoint& point = grid.point(m);
- for (auto& neighbor : point.neighbor)
+ for (const auto& neighbor : point.neighbor)
{
/* Do not convolve the bias along a lambda axis - only use the pmf from the current point */
if (!pointsHaveDifferentLambda(grid, m, neighbor))
/* Sum up the histograms and get their normalization */
double sumVisits = 0;
double sumWeights = 0;
- for (auto& pointState : points_)
+ for (const auto& pointState : points_)
{
if (pointState.inTargetRegion())
{
/* For each neighbor point of the center point, refresh its state by adding the results of all past, skipped updates. */
const std::vector<int>& neighbors = grid.point(coordState_.gridpointIndex()).neighbor;
- for (auto& neighbor : neighbors)
+ for (const auto& neighbor : neighbors)
{
bool didUpdate = points_[neighbor].performPreviouslySkippedUpdates(
params, histogramSize_.numUpdates(), weightHistScaling, logPmfsumScaling);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*/
void prepareBiasOutput(const Bias& bias);
-private:
std::vector<AwhEnergyBlock> block_; /**< The data blocks */
std::map<AwhOutputEntryType, int> outputTypeToBlock_; /**< Start block index for each variable, -1 when variable should not be written */
};
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*/
int getNumBlocks() const;
-public:
const double dtSample; /**< Time in between samples. */
const BlockLengthMeasure blockLengthMeasure; /**< The measure for the block length. */
private:
/* Get the total weight of the total weight histogram; needed for normalization. */
double totalWeight = 0;
int numTargetPoints = 0;
- for (auto& pointState : pointStates)
+ for (const auto& pointState : pointStates)
{
if (!pointState.inTargetRegion())
{
/* Sum up weight of points that do or don't pass the check. */
double equilibratedWeight = 0;
double notEquilibratedWeight = 0;
- for (auto& pointState : pointStates)
+ for (const auto& pointState : pointStates)
{
double targetWeight = pointState.target();
double sampledWeight = pointState.weightSumTot() * inverseTotalWeight;
--- /dev/null
+# List of rationales for check suppressions (where known).
+# This have to precede the list because inline comments are not
+# supported by clang-tidy.
+#
+# -cppcoreguidelines-non-private-member-variables-in-classes,
+# -misc-non-private-member-variables-in-classes,
+# We intend a gradual transition to conform to this guideline, but it
+# is not practical to implement yet.
+#
+# -readability-isolate-declaration,
+# Declarations like "int a, b;" are readable. Some forms are not, and
+# those might reasonably be suggested against during code review.
+#
+# -cppcoreguidelines-avoid-c-arrays,
+# C arrays are still necessary in many places with legacy code
+#
+# -cppcoreguidelines-avoid-magic-numbers,
+# -readability-magic-numbers,
+# We have many legitimate use cases for magic numbers
+#
+# -cppcoreguidelines-macro-usage,
+# We do use too many macros, and we should fix many of them, but there
+# is no reasonable way to suppress the check e.g. in src/config.h and
+# configuring the build is a major legitimate use of macros.
+#
+# -cppcoreguidelines-narrowing-conversions,
+# -bugprone-narrowing-conversions
+# We have many cases where int is converted to float and we don't care
+# enough about such potential loss of precision to use explicit casts
+# in large numbers of places.
+#
+# -google-readability-avoid-underscore-in-googletest-name
+# We need to use underscores for readability for our legacy types
+# and command-line parameter names
+#
+# -misc-no-recursion
+# We have way too many functions and methods relying on recursion
+#
+# -cppcoreguidelines-avoid-non-const-global-variables
+# There are quite a lot of static variables in the test code that
+# can not be replaced.
+#
+# -modernize-avoid-bind
+# Some code needs to use std::bind and can't be modernized quickly.
+Checks: clang-diagnostic-*,-clang-analyzer-*,-clang-analyzer-security.insecureAPI.strcpy,
+ bugprone-*,misc-*,readability-*,performance-*,mpi-*,
+ -readability-inconsistent-declaration-parameter-name,
+ -readability-function-size,-readability-else-after-return,
+ modernize-use-nullptr,modernize-use-emplace,
+ modernize-make-unique,modernize-make-shared,
+ modernize-avoid-bind,
+ modernize-use-override,
+ modernize-redundant-void-arg,modernize-use-bool-literals,
+ cppcoreguidelines-*,-cppcoreguidelines-pro-*,-cppcoreguidelines-owning-memory,
+ -cppcoreguidelines-no-malloc,-cppcoreguidelines-special-member-functions,
+ -cppcoreguidelines-avoid-goto,
+ google-*,-google-build-using-namespace,-google-explicit-constructor,
+ -google-readability-function-size,-google-readability-todo,-google-runtime-int,
+ -cppcoreguidelines-non-private-member-variables-in-classes,
+ -misc-non-private-member-variables-in-classes,
+ -readability-isolate-declaration,
+ -cppcoreguidelines-avoid-c-arrays,
+ -cppcoreguidelines-avoid-magic-numbers,
+ -readability-magic-numbers,
+ -cppcoreguidelines-macro-usage,
+ -cppcoreguidelines-narrowing-conversions,
+ -bugprone-narrowing-conversions,
+ -google-readability-avoid-underscore-in-googletest-name,
+ -cppcoreguidelines-init-variables,
+ -misc-no-recursion,
+ -cppcoreguidelines-avoid-non-const-global-variables,
+ -modernize-avoid-bind
+HeaderFilterRegex: .*
+CheckOptions:
+ - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
+ value: 1
+ - key: modernize-make-unique.IncludeStyle
+ value: google
+ - key: modernize-make-shared.IncludeStyle
+ value: google
+ - key: readability-implicit-bool-conversion.AllowIntegerConditions
+ value: 1
+ - key: readability-implicit-bool-conversion.AllowPointerConditions
+ value: 1
+ - key: bugprone-dangling-handle.HandleClasses
+ value: std::basic_string_view; nonstd::sv_lite::basic_string_view
+# Permit passing shard pointers by value for sink parameters
+ - key: performance-unnecessary-copy-initialization.AllowedTypes
+ value: shared_ptr
+ - key: performance-unnecessary-value-param.AllowedTypes
+ value: shared_ptr
}
std::vector<double> pointBias, logPmfsum;
- for (auto& point : bias.state().points())
+ for (const auto& point : bias.state().points())
{
pointBias.push_back(point.bias());
logPmfsum.push_back(point.logPmfSum());
}
std::vector<double> pointBias, logPmfsum;
- for (auto& point : bias.state().points())
+ for (const auto& point : bias.state().points())
{
pointBias.push_back(point.bias());
logPmfsum.push_back(point.logPmfSum());
haveCorrectNumNeighbors = false;
}
- for (auto& j : point.neighbor)
+ for (const auto& j : point.neighbor)
{
if (j >= 0 && j < numPoints)
{
}
/* Clear the marked points in the checking grid */
- for (auto& neighbor : point.neighbor)
+ for (const auto& neighbor : point.neighbor)
{
if (neighbor >= 0 && neighbor < numPoints)
{
void setSimulationTimeStep(double timeStep) { simulationTimeStep_ = timeStep; }
//! Return the simulation time step
- double simulationTimeStep() { return simulationTimeStep_; }
+ double simulationTimeStep() const { return simulationTimeStep_; }
private:
//! The reference density to fit to
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
//! The time constant for the adaptive force scaling in ps
real adaptiveForceScalingTimeConstant_ = 4;
//! Translation of the structure, so that the coordinates that are fitted are x+translation
- std::string translationString_ = "";
+ std::string translationString_;
//! Linear transformation of the structure, so that the coordinates that are fitted are Matrix * x
- std::string transformationMatrixString_ = "";
+ std::string transformationMatrixString_;
};
/*!\brief Check if two structs holding density fitting parameters are equal.
--- /dev/null
+# List of rationales for check suppressions (where known).
+# This have to precede the list because inline comments are not
+# supported by clang-tidy.
+#
+# -cppcoreguidelines-non-private-member-variables-in-classes,
+# -misc-non-private-member-variables-in-classes,
+# We intend a gradual transition to conform to this guideline, but it
+# is not practical to implement yet.
+#
+# -readability-isolate-declaration,
+# Declarations like "int a, b;" are readable. Some forms are not, and
+# those might reasonably be suggested against during code review.
+#
+# -cppcoreguidelines-avoid-c-arrays,
+# C arrays are still necessary in many places with legacy code
+#
+# -cppcoreguidelines-avoid-magic-numbers,
+# -readability-magic-numbers,
+# We have many legitimate use cases for magic numbers
+#
+# -cppcoreguidelines-macro-usage,
+# We do use too many macros, and we should fix many of them, but there
+# is no reasonable way to suppress the check e.g. in src/config.h and
+# configuring the build is a major legitimate use of macros.
+#
+# -cppcoreguidelines-narrowing-conversions,
+# -bugprone-narrowing-conversions
+# We have many cases where int is converted to float and we don't care
+# enough about such potential loss of precision to use explicit casts
+# in large numbers of places.
+#
+# -google-readability-avoid-underscore-in-googletest-name
+# We need to use underscores for readability for our legacy types
+# and command-line parameter names
+#
+# -misc-no-recursion
+# We have way too many functions and methods relying on recursion
+#
+# -cppcoreguidelines-avoid-non-const-global-variables
+# There are quite a lot of static variables in the test code that
+# can not be replaced.
+#
+# -modernize-avoid-bind
+# Some code needs to use std::bind and can't be modernized quickly.
+Checks: clang-diagnostic-*,-clang-analyzer-*,-clang-analyzer-security.insecureAPI.strcpy,
+ bugprone-*,misc-*,readability-*,performance-*,mpi-*,
+ -readability-inconsistent-declaration-parameter-name,
+ -readability-function-size,-readability-else-after-return,
+ modernize-use-nullptr,modernize-use-emplace,
+ modernize-make-unique,modernize-make-shared,
+ modernize-avoid-bind,
+ modernize-use-override,
+ modernize-redundant-void-arg,modernize-use-bool-literals,
+ cppcoreguidelines-*,-cppcoreguidelines-pro-*,-cppcoreguidelines-owning-memory,
+ -cppcoreguidelines-no-malloc,-cppcoreguidelines-special-member-functions,
+ -cppcoreguidelines-avoid-goto,
+ google-*,-google-build-using-namespace,-google-explicit-constructor,
+ -google-readability-function-size,-google-readability-todo,-google-runtime-int,
+ -cppcoreguidelines-non-private-member-variables-in-classes,
+ -misc-non-private-member-variables-in-classes,
+ -readability-isolate-declaration,
+ -cppcoreguidelines-avoid-c-arrays,
+ -cppcoreguidelines-avoid-magic-numbers,
+ -readability-magic-numbers,
+ -cppcoreguidelines-macro-usage,
+ -cppcoreguidelines-narrowing-conversions,
+ -bugprone-narrowing-conversions,
+ -google-readability-avoid-underscore-in-googletest-name,
+ -cppcoreguidelines-init-variables,
+ -misc-no-recursion,
+ -cppcoreguidelines-avoid-non-const-global-variables,
+ -modernize-avoid-bind
+HeaderFilterRegex: .*
+CheckOptions:
+ - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
+ value: 1
+ - key: modernize-make-unique.IncludeStyle
+ value: google
+ - key: modernize-make-shared.IncludeStyle
+ value: google
+ - key: readability-implicit-bool-conversion.AllowIntegerConditions
+ value: 1
+ - key: readability-implicit-bool-conversion.AllowPointerConditions
+ value: 1
+ - key: bugprone-dangling-handle.HandleClasses
+ value: std::basic_string_view; nonstd::sv_lite::basic_string_view
+# Permit passing shard pointers by value for sink parameters
+ - key: performance-unnecessary-copy-initialization.AllowedTypes
+ value: shared_ptr
+ - key: performance-unnecessary-value-param.AllowedTypes
+ value: shared_ptr
--- /dev/null
+# List of rationales for check suppressions (where known).
+# This have to precede the list because inline comments are not
+# supported by clang-tidy.
+#
+# -cppcoreguidelines-non-private-member-variables-in-classes,
+# -misc-non-private-member-variables-in-classes,
+# We intend a gradual transition to conform to this guideline, but it
+# is not practical to implement yet.
+#
+# -readability-isolate-declaration,
+# Declarations like "int a, b;" are readable. Some forms are not, and
+# those might reasonably be suggested against during code review.
+#
+# -cppcoreguidelines-avoid-c-arrays,
+# C arrays are still necessary in many places with legacy code
+#
+# -cppcoreguidelines-avoid-magic-numbers,
+# -readability-magic-numbers,
+# We have many legitimate use cases for magic numbers
+#
+# -cppcoreguidelines-macro-usage,
+# We do use too many macros, and we should fix many of them, but there
+# is no reasonable way to suppress the check e.g. in src/config.h and
+# configuring the build is a major legitimate use of macros.
+#
+# -cppcoreguidelines-narrowing-conversions,
+# -bugprone-narrowing-conversions
+# We have many cases where int is converted to float and we don't care
+# enough about such potential loss of precision to use explicit casts
+# in large numbers of places.
+#
+# -google-readability-avoid-underscore-in-googletest-name
+# We need to use underscores for readability for our legacy types
+# and command-line parameter names
+#
+# -misc-no-recursion
+# We have way too many functions and methods relying on recursion
+#
+# -cppcoreguidelines-avoid-non-const-global-variables
+# There are quite a lot of static variables in the test code that
+# can not be replaced.
+#
+# -modernize-avoid-bind
+# Some code needs to use std::bind and can't be modernized quickly.
+Checks: clang-diagnostic-*,-clang-analyzer-*,-clang-analyzer-security.insecureAPI.strcpy,
+ bugprone-*,misc-*,readability-*,performance-*,mpi-*,
+ -readability-inconsistent-declaration-parameter-name,
+ -readability-function-size,-readability-else-after-return,
+ modernize-use-nullptr,modernize-use-emplace,
+ modernize-make-unique,modernize-make-shared,
+ modernize-avoid-bind,
+ modernize-use-override,
+ modernize-redundant-void-arg,modernize-use-bool-literals,
+ cppcoreguidelines-*,-cppcoreguidelines-pro-*,-cppcoreguidelines-owning-memory,
+ -cppcoreguidelines-no-malloc,-cppcoreguidelines-special-member-functions,
+ -cppcoreguidelines-avoid-goto,
+ google-*,-google-build-using-namespace,-google-explicit-constructor,
+ -google-readability-function-size,-google-readability-todo,-google-runtime-int,
+ -cppcoreguidelines-non-private-member-variables-in-classes,
+ -misc-non-private-member-variables-in-classes,
+ -readability-isolate-declaration,
+ -cppcoreguidelines-avoid-c-arrays,
+ -cppcoreguidelines-avoid-magic-numbers,
+ -readability-magic-numbers,
+ -cppcoreguidelines-macro-usage,
+ -cppcoreguidelines-narrowing-conversions,
+ -bugprone-narrowing-conversions,
+ -google-readability-avoid-underscore-in-googletest-name,
+ -cppcoreguidelines-init-variables,
+ -misc-no-recursion,
+ -cppcoreguidelines-avoid-non-const-global-variables,
+ -modernize-avoid-bind
+HeaderFilterRegex: .*
+CheckOptions:
+ - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
+ value: 1
+ - key: modernize-make-unique.IncludeStyle
+ value: google
+ - key: modernize-make-shared.IncludeStyle
+ value: google
+ - key: readability-implicit-bool-conversion.AllowIntegerConditions
+ value: 1
+ - key: readability-implicit-bool-conversion.AllowPointerConditions
+ value: 1
+ - key: bugprone-dangling-handle.HandleClasses
+ value: std::basic_string_view; nonstd::sv_lite::basic_string_view
+# Permit passing shard pointers by value for sink parameters
+ - key: performance-unnecessary-copy-initialization.AllowedTypes
+ value: shared_ptr
+ - key: performance-unnecessary-value-param.AllowedTypes
+ value: shared_ptr