Fixes for clang-tidy-9
authorMark Abraham <mark.j.abraham@gmail.com>
Thu, 19 Mar 2020 08:42:47 +0000 (09:42 +0100)
committerM. Eric Irrgang <mei2n@virginia.edu>
Wed, 8 Apr 2020 17:37:43 +0000 (17:37 +0000)
Mostly suggestions for risky repeat branches and more readable use of
methods that use no member variables and could be static.  This means
that some bad, incompletely implemented, or excessively implemented
code is now gone or uglier than it was before.

The CPU-build classes for GPU management objects didn't use the only
member variable impl_, so they were also recommended to become
static. That doesn't work for our use case, but swapping the assertion
to be !impl_ does all jobs well enough.

eg2cHartree_e probably has had the wrong behavior ever since it
was introduced, but I don't know and it's not a big problem.

LJ12 Encad table is probably fixed, but it's unused, so who cares.

98 files changed:
src/.clang-tidy
src/gromacs/analysisdata/datamodulemanager.cpp
src/gromacs/analysisdata/tests/datatest.h
src/gromacs/applied_forces/tests/densityfittingoptions.cpp
src/gromacs/applied_forces/tests/electricfield.cpp
src/gromacs/awh/biasparams.cpp
src/gromacs/commandline/cmdlinemodulemanager.cpp
src/gromacs/commandline/cmdlineparser.cpp
src/gromacs/coordinateio/outputadapters/setatoms.cpp
src/gromacs/coordinateio/outputadapters/setatoms.h
src/gromacs/coordinateio/tests/requirements.h
src/gromacs/correlationfunctions/tests/autocorr.cpp
src/gromacs/domdec/gpuhaloexchange_impl.cpp
src/gromacs/ewald/pme_coordinate_receiver_gpu_impl.cpp
src/gromacs/ewald/pme_force_sender_gpu_impl.cpp
src/gromacs/ewald/pme_pp_comm_gpu_impl.cpp
src/gromacs/fileio/checkpoint.cpp
src/gromacs/fileio/pdbio.cpp
src/gromacs/fileio/tests/xvgio.cpp
src/gromacs/fileio/tpxio.cpp
src/gromacs/fileio/xvgr.cpp
src/gromacs/gmxana/anadih.cpp
src/gromacs/gmxana/dlist.cpp
src/gromacs/gmxana/gmx_angle.cpp
src/gromacs/gmxana/gmx_do_dssp.cpp
src/gromacs/gmxpreprocess/gen_ad.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/nm2type.cpp
src/gromacs/gmxpreprocess/pdb2top.cpp
src/gromacs/gmxpreprocess/topio.cpp
src/gromacs/gmxpreprocess/toputil.cpp
src/gromacs/gpu_utils/device_stream.cpp
src/gromacs/gpu_utils/hostallocator.h
src/gromacs/gpu_utils/tests/device_stream_manager.cpp
src/gromacs/listed_forces/gpubonded_impl.cpp
src/gromacs/math/densityfit.cpp
src/gromacs/math/multidimarray.h
src/gromacs/math/units.cpp
src/gromacs/mdlib/energyoutput.h
src/gromacs/mdlib/mdebin_bar.cpp
src/gromacs/mdlib/tests/constr.cpp
src/gromacs/mdlib/tests/leapfrog.cpp
src/gromacs/mdlib/tests/settle.cpp
src/gromacs/mdlib/tests/shake.cpp
src/gromacs/mdlib/update_constrain_gpu_impl.cpp
src/gromacs/mdlib/updategroups.cpp
src/gromacs/mdlib/vcm.cpp
src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/mimic.cpp
src/gromacs/mdrun/minimize.cpp
src/gromacs/mdrun/rerun.cpp
src/gromacs/mdrun/runner.cpp
src/gromacs/mdrunutility/tests/threadaffinity_mpi.cpp
src/gromacs/mdrunutility/tests/threadaffinitytest.h
src/gromacs/mdtypes/inputrec.cpp
src/gromacs/mdtypes/inputrec.h
src/gromacs/mdtypes/state_propagator_data_gpu_impl.cpp
src/gromacs/mimic/communicator.cpp
src/gromacs/mimic/communicator.h
src/gromacs/options/filenameoptionmanager.cpp
src/gromacs/options/tests/treesupport.cpp
src/gromacs/pulling/pull_rotation.cpp
src/gromacs/pulling/tests/pull.cpp
src/gromacs/restraint/restraintmdmodule.cpp
src/gromacs/restraint/restraintmdmodule_impl.h
src/gromacs/selection/compiler.cpp
src/gromacs/selection/compiler.h
src/gromacs/selection/evaluate.cpp
src/gromacs/selection/poscalc.cpp
src/gromacs/selection/scanner_internal.cpp
src/gromacs/selection/selectioncollection.cpp
src/gromacs/selection/selectioncollection.h
src/gromacs/selection/selectioncollection_impl.h
src/gromacs/selection/selectionoptionbehavior.cpp
src/gromacs/selection/selhelp.cpp
src/gromacs/selection/tests/nbsearch.cpp
src/gromacs/selection/tests/poscalc.cpp
src/gromacs/simd/tests/simd_math.cpp
src/gromacs/tables/forcetable.cpp
src/gromacs/taskassignment/taskassignment.h
src/gromacs/tools/mk_angndx.cpp
src/gromacs/tools/tests/dump.cpp
src/gromacs/trajectoryanalysis/analysismodule.cpp
src/gromacs/trajectoryanalysis/analysismodule.h
src/gromacs/trajectoryanalysis/modules/angle.cpp
src/gromacs/trajectoryanalysis/modules/distance.cpp
src/gromacs/trajectoryanalysis/modules/freevolume.cpp
src/gromacs/trajectoryanalysis/modules/pairdist.cpp
src/gromacs/trajectoryanalysis/modules/rdf.cpp
src/gromacs/trajectoryanalysis/modules/sasa.cpp
src/gromacs/trajectoryanalysis/modules/select.cpp
src/gromacs/trajectoryanalysis/modules/trajectory.cpp
src/gromacs/utility/filestream.cpp
src/gromacs/utility/filestream.h
src/gromacs/utility/keyvaluetree.cpp
src/gromacs/utility/smalloc.h
src/gromacs/utility/tests/inmemoryserializer.cpp
src/gromacs/utility/tests/keyvaluetreeserializer.cpp

index 6efdf2d87cbff903b029ec53f16cfcdc61c5c64e..6a7556b89ebe66054b1ed70087d62439792c00b6 100644 (file)
 # 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
+#
 Checks:  clang-diagnostic-*,-clang-analyzer-*,-clang-analyzer-security.insecureAPI.strcpy,
          bugprone-*,misc-*,readability-*,performance-*,mpi-*,
          -readability-inconsistent-declaration-parameter-name,
@@ -51,7 +55,8 @@ Checks:  clang-diagnostic-*,-clang-analyzer-*,-clang-analyzer-security.insecureA
          -readability-magic-numbers,
          -cppcoreguidelines-macro-usage,
          -cppcoreguidelines-narrowing-conversions,
-         -bugprone-narrowing-conversions
+         -bugprone-narrowing-conversions,
+         -google-readability-avoid-underscore-in-googletest-name
 HeaderFilterRegex: .*
 CheckOptions:
   - key:           cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
index a68bb85459ab48eac00383976731434b5291a36e..bd51891b02bc4aa9d2285bc43255f7c2bec169ff 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -107,7 +107,7 @@ public:
      * \param[in] bSet     Value of the property to check against.
      * \throws    APIError if \p module is not compatible with the data.
      */
-    void checkModuleProperty(const IAnalysisDataModule& module, DataProperty property, bool bSet) const;
+    static void checkModuleProperty(const IAnalysisDataModule& module, DataProperty property, bool bSet);
     /*! \brief
      * Checks whether a module is compatible with the data properties.
      *
@@ -175,7 +175,7 @@ AnalysisDataModuleManager::Impl::Impl() :
 
 void AnalysisDataModuleManager::Impl::checkModuleProperty(const IAnalysisDataModule& module,
                                                           DataProperty               property,
-                                                          bool                       bSet) const
+                                                          bool                       bSet)
 {
     bool      bOk   = true;
     const int flags = module.flags();
index 1d32c2d0ae5b2e4aed7c197d25955dd58644cd38..1e1766b58b3d06815e77c2472a32c692a143c3be 100644 (file)
@@ -102,7 +102,7 @@ public:
     //! Returns the error in column \p i.
     real error(int i) const { return values_[i].error; }
     //! Returns whether the value in column \p i is present.
-    bool present(int /*i*/) const { return true; }
+    static bool present(int /*i*/) { return true; }
     //! Returns an AnalysisDataValue for column \p i.
     AnalysisDataValue value(int i) const
     {
@@ -158,7 +158,7 @@ public:
     //! Returns x coordinate for the frame.
     real x() const { return x_; }
     //! Returns error in the x coordinate for the frame.
-    real dx() const { return 0.0; }
+    static real dx() { return 0.0; }
 
     //! Number of individual point sets in the frame.
     int pointSetCount() const { return pointSets_.size(); }
index 4dcc3c5873a399ae2e1883a3d169c362e941194e..6580498ba5caaad19f99c8db98bb0cc8a3df3f2e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -91,7 +91,7 @@ public:
         assignOptionsFromKeyValueTree(&densityFittingModuleOptions, transformedMdpValues.object(), nullptr);
     }
 
-    KeyValueTreeObject densityFittingSetActiveAsMdpValues()
+    static KeyValueTreeObject densityFittingSetActiveAsMdpValues()
     {
         // Prepare MDP inputs
         KeyValueTreeBuilder mdpValueBuilder;
index bef644480f61fe678d0b5e565622ddcce8fdeacc..62c5b3199fa2e0d13a5df4fbc0ad2b9cf1b728a1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020, 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.
@@ -81,7 +81,7 @@ namespace
 class ElectricFieldTest : public ::testing::Test
 {
 public:
-    void test(int dim, real E0, real omega, real t0, real sigma, real expectedValue)
+    static void test(int dim, real E0, real omega, real t0, real sigma, real expectedValue)
     {
         // Make the electric field module
         auto module = createElectricFieldModule();
index c28d7c615d48382ef3bc6408502f6926872d6b1a..d5afec9f5fae4a6098232c3cedfdfdfa974f1a7b 100644 (file)
@@ -184,12 +184,13 @@ double gaussianGeometryFactor(gmx::ArrayRef<const double> xArray)
         zetaTable = zetaTable1d;
     }
     else if (xArray.size() == 2)
-    {
+    { // NOLINT bugprone-branch-clone
         zetaTable = zetaTable2d;
     }
     else
     {
-        /* TODO... but this is anyway a rough estimate and > 2 dimensions is not so popular. */
+        /* TODO... but this is anyway a rough estimate and > 2 dimensions is not so popular.
+         * Remove the above NOLINT when addressing this */
         zetaTable = zetaTable2d;
     }
 
index 60522e4158cf58e23b1404886912c13608a03066..066495cd67405afb42cf59e44c136fb4661a2268 100644 (file)
@@ -277,7 +277,7 @@ public:
                                              char***                         argv);
 
     //! Prints the footer at the end of execution.
-    void printThanks(FILE* fp);
+    static void printThanks(FILE* fp);
 
     /*! \brief
      * Maps module names to module objects.
index 8f5b50e7989ae4f7d317ce9937ab48135c48e536..5f33ed552faba4ce7864812aaf0b11031daa241d 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -79,7 +79,7 @@ public:
      * \returns The beginning of the option name in \p arg, or NULL if
      *     \p arg does not look like an option.
      */
-    const char* toOptionName(const char* arg) const;
+    static const char* toOptionName(const char* arg);
 
     //! Helper object for assigning the options.
     OptionsAssigner assigner_;
@@ -100,7 +100,7 @@ CommandLineParser::Impl::Impl(Options* options) :
     assigner_.setAcceptBooleanNoPrefix(true);
 }
 
-const char* CommandLineParser::Impl::toOptionName(const char* arg) const
+const char* CommandLineParser::Impl::toOptionName(const char* arg)
 {
     // Lone '-' or '--' is not an option.
     if (arg[0] != '-' || arg[1] == '\0' || (arg[1] == '-' && arg[2] == '\0'))
index a450cf637975178462c9a37c004ec231ff579eae..5a65e621c7f6a3f21d976e6749bf461dd50af516 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -100,7 +100,7 @@ void SetAtoms::processFrame(const int /*framenumber*/, t_trxframe* input)
     }
 }
 
-bool SetAtoms::haveFrameAtoms(const t_trxframe& input) const
+bool SetAtoms::haveFrameAtoms(const t_trxframe& input)
 {
     return input.bAtoms;
 }
index 58e8a7870d89b184154e09e3bc4e88850d32c353..00d7d1af377934d99493f576aad6433c0e0a77b5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -125,7 +125,7 @@ private:
      *
      *  \param[in] input t_trxframe before we start modifying it.
      */
-    bool haveFrameAtoms(const t_trxframe& input) const;
+    static bool haveFrameAtoms(const t_trxframe& input);
     //! Test if the atoms data is available for writing.
     bool haveAtoms(const t_trxframe& input) const
     {
index da4dd48b157667a0c4b3ebf84ca4924c2589a7d9..9afbfbf243e4bd81465d3c6487335f9ac680260a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -126,7 +126,10 @@ public:
      * \param[in] options      Container for options.
      * \param[in] type         Need to know type of entries.
      */
-    void setModuleFlag(const std::string& optionName, const std::string& optionValues, Options* options, TestEnums type)
+    static void setModuleFlag(const std::string& optionName,
+                              const std::string& optionValues,
+                              Options*           options,
+                              TestEnums          type)
     {
         OptionsAssigner assigner(options);
         assigner.start();
index e23ace8fc122824f2f06506823ac88109d32f904..eb6e17e1c15ab72ce148b351c5351b4c2b2371de 100644 (file)
@@ -137,18 +137,20 @@ protected:
         checker_.checkReal(testResult, "Integral");
     }
 
-    int getDim(unsigned long type)
+    static int getDim(unsigned long type)
     {
         switch (type)
         {
             case eacNormal: return 1;
             case eacVector: return 3;
-            case eacCos: return 1;
-            case eacRcross: return 3;
-            case eacP0: return 3;
-            case eacP1: return 3;
-            case eacP2: return 3;
-            case eacP3: return 3;
+            case eacCos:
+                return 1;
+                // Several intended fall-throughs follow
+            case eacRcross:
+            case eacP0:
+            case eacP1:
+            case eacP2:
+            case eacP3:
             case eacP4: return 3;
             case eacIden: return 1;
             default: GMX_RELEASE_ASSERT(false, "Invalid auto correlation option"); return -1;
index 1e22b4016eef582c1ac4ba0b7e8697328ef9a1f0..e9106b7c8902a42503a6a4712831abb02be2a3d6 100644 (file)
@@ -78,7 +78,7 @@ GpuHaloExchange::~GpuHaloExchange() = default;
 void GpuHaloExchange::reinitHalo(DeviceBuffer<RVec> /* d_coordinatesBuffer */,
                                  DeviceBuffer<RVec> /* d_forcesBuffer */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for GPU Halo Exchange was called insted of the correct implementation.");
 }
 
@@ -86,7 +86,7 @@ void GpuHaloExchange::reinitHalo(DeviceBuffer<RVec> /* d_coordinatesBuffer */,
 void GpuHaloExchange::communicateHaloCoordinates(const matrix /* box */,
                                                  GpuEventSynchronizer* /*coordinatesOnDeviceEvent*/)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for GPU Halo Exchange exchange was called insted of the correct "
                "implementation.");
 }
@@ -94,14 +94,14 @@ void GpuHaloExchange::communicateHaloCoordinates(const matrix /* box */,
 /*!\brief apply F halo exchange stub. */
 void GpuHaloExchange::communicateHaloForces(bool gmx_unused accumulateForces)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for GPU Halo Exchange was called insted of the correct implementation.");
 }
 
 /*!\brief get forces ready on device event stub. */
 GpuEventSynchronizer* GpuHaloExchange::getForcesReadyOnDeviceEvent()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for GPU Halo Exchange was called insted of the correct implementation.");
     return nullptr;
 }
index b0da71cc479e543792da77de056f87a81f90ebb1..e377cb87313cb65f0e1189ff4d98babdad11d792 100644 (file)
@@ -67,7 +67,7 @@ PmeCoordinateReceiverGpu::PmeCoordinateReceiverGpu(const DeviceStream& /* pmeStr
                                                    gmx::ArrayRef<PpRanks> /* ppRanks */) :
     impl_(nullptr)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication was called instead of the correct "
                "implementation.");
 }
@@ -77,21 +77,21 @@ PmeCoordinateReceiverGpu::~PmeCoordinateReceiverGpu() = default;
 /*!\brief init PME-PP GPU communication stub */
 void PmeCoordinateReceiverGpu::sendCoordinateBufferAddressToPpRanks(DeviceBuffer<RVec> /* d_x */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication initialization was called instead of the "
                "correct implementation.");
 }
 
 void PmeCoordinateReceiverGpu::launchReceiveCoordinatesFromPpCudaDirect(int /* ppRank */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication was called instead of the correct "
                "implementation.");
 }
 
 void PmeCoordinateReceiverGpu::enqueueWaitReceiveCoordinatesFromPpCudaDirect()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication was called instead of the correct "
                "implementation.");
 }
index 3ae502ccd8373589a330ddf9c801d5490a61e221..aa046ee718d307236bbef46d82f3082284122baa 100644 (file)
@@ -66,7 +66,7 @@ PmeForceSenderGpu::PmeForceSenderGpu(const DeviceStream& /*pmeStream */,
                                      gmx::ArrayRef<PpRanks> /* ppRanks */) :
     impl_(nullptr)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication was called instead of the correct "
                "implementation.");
 }
@@ -76,14 +76,14 @@ PmeForceSenderGpu::~PmeForceSenderGpu() = default;
 /*!\brief init PME-PP GPU communication stub */
 void PmeForceSenderGpu::sendForceBufferAddressToPpRanks(rvec* /* d_f */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication initialization was called instead of the "
                "correct implementation.");
 }
 
 void PmeForceSenderGpu::sendFToPpCudaDirect(int /* ppRank */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication was called instead of the correct "
                "implementation.");
 }
index b53ce94ada0b13236bd22d2c2ed8180162665f36..d194b73c206deb2928776346770844a37d375728 100644 (file)
@@ -68,7 +68,7 @@ PmePpCommGpu::PmePpCommGpu(MPI_Comm /* comm */,
                            const DeviceStream& /* deviceStream */) :
     impl_(nullptr)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication was called instead of the correct "
                "implementation.");
 }
@@ -78,7 +78,7 @@ PmePpCommGpu::~PmePpCommGpu() = default;
 /*!\brief init PME-PP GPU communication stub */
 void PmePpCommGpu::reinit(int /* size */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication initialization was called instead of the "
                "correct implementation.");
 }
@@ -87,7 +87,7 @@ void PmePpCommGpu::receiveForceFromPmeCudaDirect(void* /* recvPtr */,
                                                  int /* recvSize */,
                                                  bool /* receivePmeForceToGpu */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication was called instead of the correct "
                "implementation.");
 }
@@ -97,14 +97,14 @@ void PmePpCommGpu::sendCoordinatesToPmeCudaDirect(void* /* sendPtr */,
                                                   bool /* sendPmeCoordinatesFromGpu */,
                                                   GpuEventSynchronizer* /* coordinatesOnDeviceEvent */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication was called instead of the correct "
                "implementation.");
 }
 
 void* PmePpCommGpu::getGpuForceStagingPtr()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication was called instead of the correct "
                "implementation.");
     return nullptr;
@@ -112,7 +112,7 @@ void* PmePpCommGpu::getGpuForceStagingPtr()
 
 void* PmePpCommGpu::getForcesReadySynchronizer()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for PME-PP GPU communication was called instead of the correct "
                "implementation.");
     return nullptr;
index ee9c72daa085c116feea500780de38dfbec228be..351d7574af228ad782fc96d5a1f8804a58a1db02 100644 (file)
@@ -1272,16 +1272,11 @@ static int do_cpt_state(XDR* xd, int fflags, t_state* state, FILE* list)
                     break;
                 /* The RNG entries are no longer written,
                  * the next 4 lines are only for reading old files.
+                 * It's OK that three case statements fall through.
                  */
                 case estLD_RNG_NOTSUPPORTED:
-                    ret = do_cpte_ints(xd, part, i, sflags, 0, nullptr, list);
-                    break;
                 case estLD_RNGI_NOTSUPPORTED:
-                    ret = do_cpte_ints(xd, part, i, sflags, 0, nullptr, list);
-                    break;
                 case estMC_RNG_NOTSUPPORTED:
-                    ret = do_cpte_ints(xd, part, i, sflags, 0, nullptr, list);
-                    break;
                 case estMC_RNGI_NOTSUPPORTED:
                     ret = do_cpte_ints(xd, part, i, sflags, 0, nullptr, list);
                     break;
index 74f776ed90bb112aa382bd4f5b4e6dfe9083619a..8e170a04df91d7337abe1d07ed88790959beb7a9 100644 (file)
@@ -730,15 +730,7 @@ gmx_bool is_hydrogen(const char* nm)
     std::strcpy(buf, nm);
     trim(buf);
 
-    if (buf[0] == 'H')
-    {
-        return TRUE;
-    }
-    else if ((std::isdigit(buf[0])) && (buf[1] == 'H'))
-    {
-        return TRUE;
-    }
-    return FALSE;
+    return ((buf[0] == 'H') || ((std::isdigit(buf[0]) != 0) && (buf[1] == 'H')));
 }
 
 gmx_bool is_dummymass(const char* nm)
index 865d4da734c2d6bfdaaf1f321ff1ffc42e9640cb..20d82b537c5f80fd4ace34a4a7e6e0c6413d738f 100644 (file)
@@ -56,10 +56,10 @@ namespace gmx
 namespace test
 {
 
-class XvgioTester
+class XvgioTest : public ::testing::Test
 {
 public:
-    XvgioTester() { referenceFilename_ = fileManager_.getTemporaryFilePath("ref.xvg"); }
+    XvgioTest() { referenceFilename_ = fileManager_.getTemporaryFilePath("ref.xvg"); }
 
     const std::string& referenceFilename() const { return referenceFilename_; }
 
@@ -72,8 +72,8 @@ public:
         gmx::TextWriter::writeFileFromString(referenceFilename(), referenceContents());
     }
 
-    void compareValues(basic_mdspan<const double, dynamicExtents2D> ref,
-                       basic_mdspan<const double, dynamicExtents2D> test)
+    static void compareValues(basic_mdspan<const double, dynamicExtents2D> ref,
+                              basic_mdspan<const double, dynamicExtents2D> test)
     {
         // The xvg reading routines use a column-major layout, while we would
         // like to enforce row major behaviour everywhere else. This requires
@@ -97,34 +97,30 @@ private:
     std::string                referenceContents_;
 };
 
-TEST(XvgioTest, readXvgIntWorks)
+TEST_F(XvgioTest, readXvgIntWorks)
 {
-    XvgioTester xvgioTester;
-    xvgioTester.useStringAsXvgFile(
+    useStringAsXvgFile(
             "1 2 3\n"
             "4 5 6\n");
-    xvgioTester.writeXvgFile();
-    MultiDimArray<std::vector<double>, dynamicExtents2D> xvgTestData =
-            readXvgData(xvgioTester.referenceFilename());
+    writeXvgFile();
+    MultiDimArray<std::vector<double>, dynamicExtents2D> xvgTestData = readXvgData(referenceFilename());
 
     const int                                            numRows    = 2;
     const int                                            numColumns = 3;
     MultiDimArray<std::vector<double>, dynamicExtents2D> xvgRefData(numRows, numColumns);
     std::iota(begin(xvgRefData), end(xvgRefData), 1);
 
-    xvgioTester.compareValues(xvgRefData.asConstView(), xvgTestData.asConstView());
+    compareValues(xvgRefData.asConstView(), xvgTestData.asConstView());
 }
 
-TEST(XvgioTest, readXvgRealWorks)
+TEST_F(XvgioTest, readXvgRealWorks)
 {
-    XvgioTester xvgioTester;
-    xvgioTester.useStringAsXvgFile(
+    useStringAsXvgFile(
             "1.1 2.2\n"
             "3.3 4.4\n"
             "5.5 6.6\n");
-    xvgioTester.writeXvgFile();
-    MultiDimArray<std::vector<double>, dynamicExtents2D> xvgTestData =
-            readXvgData(xvgioTester.referenceFilename());
+    writeXvgFile();
+    MultiDimArray<std::vector<double>, dynamicExtents2D> xvgTestData = readXvgData(referenceFilename());
 
     const int                                            numRows    = 3;
     const int                                            numColumns = 2;
@@ -133,42 +129,39 @@ TEST(XvgioTest, readXvgRealWorks)
         n += 1.1;
         return n;
     });
-    xvgioTester.compareValues(xvgRefData.asConstView(), xvgTestData.asConstView());
+    compareValues(xvgRefData.asConstView(), xvgTestData.asConstView());
 }
 
-TEST(XvgioTest, readXvgIgnoreCommentLineWorks)
+TEST_F(XvgioTest, readXvgIgnoreCommentLineWorks)
 {
-    XvgioTester xvgioTester;
-    xvgioTester.useStringAsXvgFile(
+    useStringAsXvgFile(
             "1 2 3\n"
             "#comment\n"
             "4 5 6\n");
-    xvgioTester.writeXvgFile();
+    writeXvgFile();
 
-    MultiDimArray<std::vector<double>, dynamicExtents2D> xvgTestData =
-            readXvgData(xvgioTester.referenceFilename());
+    MultiDimArray<std::vector<double>, dynamicExtents2D> xvgTestData = readXvgData(referenceFilename());
 
     const int                                            numRows    = 2;
     const int                                            numColumns = 3;
     MultiDimArray<std::vector<double>, dynamicExtents2D> xvgRefData(numRows, numColumns);
     std::iota(begin(xvgRefData), end(xvgRefData), 1);
 
-    xvgioTester.compareValues(xvgRefData.asConstView(), xvgTestData.asConstView());
+    compareValues(xvgRefData.asConstView(), xvgTestData.asConstView());
 }
 
-// Todo: Remove this test once all calls to read_xvg have been ported to readXvgData
-TEST(XvgioTest, readXvgDeprecatedWorks)
+// TODO Remove this test once all calls to read_xvg have been ported to readXvgData
+TEST_F(XvgioTest, readXvgDeprecatedWorks)
 {
-    XvgioTester xvgioTester;
-    xvgioTester.useStringAsXvgFile(
+    useStringAsXvgFile(
             "1 2 3\n"
             "4 5 6\n");
-    xvgioTester.writeXvgFile();
+    writeXvgFile();
     std::vector<std::vector<double>> xvgData = { { 1, 4 }, { 2, 5 }, { 3, 6 } };
 
     double** xvgTestData = nullptr;
     int      testNumColumns;
-    int testNumRows = read_xvg(xvgioTester.referenceFilename().c_str(), &xvgTestData, &testNumColumns);
+    int      testNumRows = read_xvg(referenceFilename().c_str(), &xvgTestData, &testNumColumns);
 
     double** xvgRefData    = nullptr;
     int      refNumColumns = 3;
index 0e5ac9ce398023de2589c44a3b711e864fc51908..68b4f3e95c6a4a9797f30bf71a30113aff4b52cd 100644 (file)
@@ -1156,20 +1156,14 @@ static void do_inputrec(gmx::ISerializer* serializer, t_inputrec* ir, int file_v
             real dummy_rlistlong = -1;
             serializer->doReal(&dummy_rlistlong);
 
-            if (ir->rlist > 0 && (dummy_rlistlong == 0 || dummy_rlistlong > ir->rlist))
-            {
-                // Get mdrun to issue an error (regardless of
-                // ir->cutoff_scheme).
-                ir->useTwinRange = true;
-            }
-            else
-            {
-                // grompp used to set rlistlong actively. Users were
-                // probably also confused and set rlistlong == rlist.
-                // However, in all remaining cases, it is safe to let
-                // mdrun proceed normally.
-                ir->useTwinRange = false;
-            }
+            ir->useTwinRange = (ir->rlist > 0 && (dummy_rlistlong == 0 || dummy_rlistlong > ir->rlist));
+            // When true, this forces mdrun to issue an error (regardless of
+            // ir->cutoff_scheme).
+            //
+            // Otherwise, grompp used to set rlistlong actively. Users
+            // were probably also confused and set rlistlong == rlist.
+            // However, in all remaining cases, it is safe to let
+            // mdrun proceed normally.
         }
     }
     else
@@ -1352,14 +1346,6 @@ static void do_inputrec(gmx::ISerializer* serializer, t_inputrec* ir, int file_v
     if (file_version >= 79)
     {
         serializer->doBool(&ir->bExpanded);
-        if (ir->bExpanded)
-        {
-            ir->bExpanded = TRUE;
-        }
-        else
-        {
-            ir->bExpanded = FALSE;
-        }
     }
     if (ir->bExpanded)
     {
@@ -1937,9 +1923,7 @@ static void do_iparams(gmx::ISerializer* serializer, t_functype ftype, t_iparams
             break;
         case F_CBTDIHS: serializer->doRealArray(iparams->cbtdihs.cbtcA, NR_CBTDIHS); break;
         case F_RBDIHS:
-            serializer->doRealArray(iparams->rbdihs.rbcA, NR_RBDIHS);
-            serializer->doRealArray(iparams->rbdihs.rbcB, NR_RBDIHS);
-            break;
+            // Fall-through intended
         case F_FOURDIHS:
             /* Fourier dihedrals are internally represented
              * as Ryckaert-Bellemans since those are faster to compute.
index 90e207413752cf361860e2200c801dcea885a15d..4cc0794db209f054572792d7cb3866376d44ffe5 100644 (file)
@@ -512,11 +512,7 @@ static int wordcount(char* ptr)
         for (i = 0; (ptr[i] != '\0'); i++)
         {
             is[cur] = std::isspace(ptr[i]);
-            if ((0 == i) && !is[cur])
-            {
-                n++;
-            }
-            else if ((i > 0) && (!is[cur] && is[prev]))
+            if (((0 == i) && !is[cur]) || ((i > 0) && (!is[cur] && is[prev])))
             {
                 n++;
             }
index a015a329b8ef12d36a8ff9c92c9820f3ea0ddad7..3a3a952f312d2fe0d68ae31e6e6c7ae50f6c57e8 100644 (file)
@@ -724,11 +724,7 @@ static real calc_fraction(const real angles[], int nangles)
         {
             trans += 1.0;
         }
-        else if (angle > 270 && angle < 330)
-        {
-            gauche += 1.0;
-        }
-        else if (angle < 90 && angle > 30)
+        else if ((angle > 270 && angle < 330) || (angle < 90 && angle > 30))
         {
             gauche += 1.0;
         }
index 2cc84009d2d9ccbc0c0b701272f70f56ab63ac43..908f0fa8ac67848dd35d057db46d44d9b479df74 100644 (file)
@@ -127,7 +127,7 @@ t_dlist* mk_dlist(FILE*          log,
                      || (std::strcmp(*(atoms->atomname[i]), "SD") == 0)
                      || (std::strcmp(*(atoms->atomname[i]), "OD1") == 0)
                      || (std::strcmp(*(atoms->atomname[i]), "ND1") == 0))
-            {
+            { // NOLINT bugprone-branch-clone
                 atm.Cn[4] = i;
             }
             /* by grs - split the Cn[4] into 2 bits to check allowing dih to H */
index e3de075ad2480ae9f5fb0e554b5e0a30e8f48b65..70f006512aa2ec3f47278245fd1f64fe615aeb05 100644 (file)
@@ -212,7 +212,7 @@ int gmx_g_angle(int argc, char* argv[])
             mult   = 3;
             maxang = 180.0;
             break;
-        case 'd': break;
+        case 'd': // Intended fall through
         case 'i': break;
         case 'r': bRb = TRUE; break;
     }
index f030505f71cb9762239b1ac66f586337b1002e87..5dda614a9c2ec42ee0399d250ffae987df053ab1 100644 (file)
@@ -268,15 +268,9 @@ static void check_oo(t_atoms* atoms)
 
     for (i = 0; (i < atoms->nr); i++)
     {
-        if (std::strcmp(*(atoms->atomname[i]), "OXT") == 0)
-        {
-            *atoms->atomname[i] = OOO;
-        }
-        else if (std::strcmp(*(atoms->atomname[i]), "O1") == 0)
-        {
-            *atoms->atomname[i] = OOO;
-        }
-        else if (std::strcmp(*(atoms->atomname[i]), "OC1") == 0)
+        if ((std::strcmp(*(atoms->atomname[i]), "OXT") == 0)
+            || (std::strcmp(*(atoms->atomname[i]), "O1") == 0)
+            || (std::strcmp(*(atoms->atomname[i]), "OC1") == 0))
         {
             *atoms->atomname[i] = OOO;
         }
index 224057a31268fa368b3300485224915e4f3afbcb..bdc4bcc8f260633dc4dfecb7b0054fa1192d0e80 100644 (file)
@@ -78,11 +78,7 @@ static bool acomp(const InteractionOfType& a1, const InteractionOfType& a2)
 {
     int ac;
 
-    if ((ac = (a1.aj() - a2.aj())) != 0)
-    {
-        return ac < 0;
-    }
-    else if ((ac = (a1.ai() - a2.ai())) != 0)
+    if (((ac = (a1.aj() - a2.aj())) != 0) || ((ac = (a1.ai() - a2.ai())) != 0))
     {
         return ac < 0;
     }
@@ -111,12 +107,8 @@ static bool dcomp(const InteractionOfType& d1, const InteractionOfType& d2)
     int dc;
 
     /* First sort by J & K (the two central) atoms */
-    if ((dc = (d1.aj() - d2.aj())) != 0)
-    {
-        return dc < 0;
-    }
-    else if ((dc = (d1.ak() - d2.ak())) != 0)
-    {
+    if (((dc = (d1.aj() - d2.aj())) != 0) || ((dc = (d1.ak() - d2.ak())) != 0))
+    { // NOLINT bugprone-branch-clone
         return dc < 0;
     }
     /* Then make sure to put rtp dihedrals before generated ones */
@@ -129,11 +121,7 @@ static bool dcomp(const InteractionOfType& d1, const InteractionOfType& d2)
         return false;
     }
     /* Then sort by I and J (two outer) atoms */
-    else if ((dc = (d1.ai() - d2.ai())) != 0)
-    {
-        return dc < 0;
-    }
-    else if ((dc = (d1.al() - d2.al())) != 0)
+    else if (((dc = (d1.ai() - d2.ai())) != 0) || ((dc = (d1.al() - d2.al())) != 0))
     {
         return dc < 0;
     }
@@ -194,15 +182,7 @@ static bool idcomp(const InteractionOfType& a, const InteractionOfType& b)
 {
     int d;
 
-    if ((d = (a.ai() - b.ai())) != 0)
-    {
-        return d < 0;
-    }
-    else if ((d = (a.al() - b.al())) != 0)
-    {
-        return d < 0;
-    }
-    else if ((d = (a.aj() - b.aj())) != 0)
+    if (((d = (a.ai() - b.ai())) != 0) || ((d = (a.al() - b.al())) != 0) || ((d = (a.aj() - b.aj())) != 0))
     {
         return d < 0;
     }
index 20ad419a74fe14c892c317bfd89b8afc1c866ad0..93e2fc4c00b3d8c1e212484df8e682098af878b2 100644 (file)
@@ -1131,7 +1131,7 @@ static int nrdf_internal(const t_atoms* atoms)
     }
     switch (nmass)
     {
-        case 0: nrdf = 0; break;
+        case 0: // Fall through intended
         case 1: nrdf = 0; break;
         case 2: nrdf = 1; break;
         default: nrdf = nmass * 3 - 6; break;
index a4c50af094fcd4aefb76ec6c9be8c885a0009769..035daabf2a3806c9c0b9da8f97efb7b43d30788e 100644 (file)
@@ -173,7 +173,7 @@ enum
 static int match_str(const char* atom, const char* template_string)
 {
     if (!atom || !template_string)
-    {
+    { // NOLINT bugprone-branch-clone
         return ematchNone;
     }
     else if (gmx_strcasecmp(atom, template_string) == 0)
index b58dd35433077734374ea96e6167bc94ffe15355..d4df1c2718368af5f4fd43332399053fc0fe5ec1 100644 (file)
@@ -840,11 +840,7 @@ static bool pcompar(const InteractionOfType& a, const InteractionOfType& b)
 {
     int d;
 
-    if ((d = a.ai() - b.ai()) != 0)
-    {
-        return d < 0;
-    }
-    else if ((d = a.aj() - b.aj()) != 0)
+    if (((d = a.ai() - b.ai()) != 0) || ((d = a.aj() - b.aj()) != 0))
     {
         return d < 0;
     }
index c6115e8e07ef1ca6b37ae1231e788ff1ef63ed4d..8237ed1ea08dd7926f0aa478ddc43132dfd7656e 100644 (file)
@@ -634,9 +634,7 @@ static char** read_topol(const char*                           infile,
                                     bGenPairs ? &pair : nullptr, wi);
                             break;
 
-                        case Directive::d_bondtypes:
-                            push_bt(d, interactions, 2, nullptr, &bondAtomType, pline, wi);
-                            break;
+                        case Directive::d_bondtypes: // Intended to fall through
                         case Directive::d_constrainttypes:
                             push_bt(d, interactions, 2, nullptr, &bondAtomType, pline, wi);
                             break;
@@ -662,7 +660,7 @@ static char** read_topol(const char*                           infile,
                             push_nbt(d, nbparam, atypes, pline, nb_funct, wi);
                             break;
 
-                        case Directive::d_implicit_genborn_params:
+                        case Directive::d_implicit_genborn_params: // NOLINT bugprone-branch-clone
                             // Skip this line, so old topologies with
                             // GB parameters can be read.
                             break;
index 9a573af613b947739de3b0eecf8396790373918b..10ebbfce3e417c6d23309bca8db42c32dc63d2c6 100644 (file)
@@ -90,7 +90,7 @@ static void print_bt(FILE*                                   out,
     int f = 0;
     switch (ftype)
     {
-        case F_G96ANGLES: f = 1; break;
+        case F_G96ANGLES: // Intended to fall through
         case F_G96BONDS: f = 1; break;
         case F_MORSE: f = 2; break;
         case F_CUBICBONDS: f = 3; break;
@@ -99,18 +99,18 @@ static void print_bt(FILE*                                   out,
         case F_CROSS_BOND_ANGLES: f = 2; break;
         case F_CROSS_BOND_BONDS: f = 3; break;
         case F_UREY_BRADLEY: f = 4; break;
-        case F_PDIHS:
-        case F_RBDIHS:
+        case F_PDIHS:  // Intended to fall through
+        case F_RBDIHS: // Intended to fall through
         case F_FOURDIHS: bDih = TRUE; break;
         case F_IDIHS:
             f    = 1;
             bDih = TRUE;
             break;
-        case F_CONSTRNC: f = 1; break;
+        case F_CONSTRNC: // Intended to fall through
         case F_VSITE3FD: f = 1; break;
         case F_VSITE3FAD: f = 2; break;
         case F_VSITE3OUT: f = 3; break;
-        case F_VSITE4FDN: f = 1; break;
+        case F_VSITE4FDN: // Intended to fall through
         case F_CMAP: f = 1; break;
 
         default: bDih = FALSE;
index bfbe049235fdd571bf844c689047a990770532f7..ecc8f09af06618bba7005aa1d049a4e8d0cc1d8b 100644 (file)
@@ -54,6 +54,7 @@ void DeviceStream::init(const DeviceContext& /* deviceContext */,
 
 DeviceStream::~DeviceStream() = default;
 
+// NOLINTNEXTLINE readability-convert-member-functions-to-static
 bool DeviceStream::isValid() const
 {
     return false;
index 888c86062ed0013dd7feabefaf133c696d93b12b..f483f0cf286d7c954588372549a4e336deee5f46 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020, 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.
@@ -186,6 +186,7 @@ public:
     //! Propagate for move
     using propagate_on_container_swap = std::true_type;
     //! Use default allocator for copy (same as construct+copy)
+    // NOLINTNEXTLINE readability-convert-member-functions-to-static
     HostAllocationPolicy select_on_container_copy_construction() const { return {}; }
 
 private:
index e75c80bc079970e28597aa038e0fe18f775c9800..3698f290a80b6c0e041cdc34851f1b77b7aeb466 100644 (file)
@@ -69,35 +69,36 @@ const EnumerationArray<DeviceStreamType, std::string> c_deviceStreamNames = {
     { "non-bonded local", "non-bonded non-local", "PME", "PME-PP transfer", "update" }
 };
 
-//! Test fixture
-class DeviceStreamManagerTest : public GpuTest
+/*! \brief Non-GPU builds return nullptr instead of streams,
+ * so we have to expect that in such build configurations. */
+const bool c_canExpectValidStreams = (GMX_GPU != GMX_GPU_NONE);
+
+//! Helper function to implement readable testing
+void expectValidStreams(DeviceStreamManager* manager, std::initializer_list<DeviceStreamType> types)
 {
-public:
-    //! Helper function to implement readable testing
-    void expectValidStreams(DeviceStreamManager* manager, std::initializer_list<DeviceStreamType> types)
-    {
-        if (canExpectValidStreams_)
-        {
-            for (const DeviceStreamType type : types)
-            {
-                SCOPED_TRACE("Testing " + c_deviceStreamNames[type] + " stream.");
-                EXPECT_TRUE(manager->streamIsValid(type));
-            }
-        }
-    }
-    //! Helper function to implement readable testing
-    void expectInvalidStreams(DeviceStreamManager* manager, std::initializer_list<DeviceStreamType> types)
+    if (c_canExpectValidStreams)
     {
         for (const DeviceStreamType type : types)
         {
             SCOPED_TRACE("Testing " + c_deviceStreamNames[type] + " stream.");
-            EXPECT_FALSE(manager->streamIsValid(type));
+            EXPECT_TRUE(manager->streamIsValid(type));
         }
     }
+}
+//! Helper function to implement readable testing
+void expectInvalidStreams(DeviceStreamManager* manager, std::initializer_list<DeviceStreamType> types)
+{
+    for (const DeviceStreamType type : types)
+    {
+        SCOPED_TRACE("Testing " + c_deviceStreamNames[type] + " stream.");
+        EXPECT_FALSE(manager->streamIsValid(type));
+    }
+}
 
-    /*! \brief Non-GPU builds return nullptr instead of streams,
-     * so we have to expect that in such build configurations. */
-    const bool canExpectValidStreams_ = (GMX_GPU != GMX_GPU_NONE);
+//! Test fixture
+class DeviceStreamManagerTest : public GpuTest
+{
+public:
 };
 
 TEST_F(DeviceStreamManagerTest, CorrectStreamsAreReturnedOnNonbondedDevice)
index ec8e43323eac98f93617808da2bb0fd307451f4b..67eec92cacaabad58a9264039f1b603ea5669a99 100644 (file)
@@ -180,7 +180,7 @@ void GpuBonded::updateInteractionListsAndDeviceBuffers(ArrayRef<const int> /* nb
 
 bool GpuBonded::haveInteractions() const
 {
-    return false;
+    return !impl_;
 }
 
 void GpuBonded::launchKernel(const t_forcerec* /* fr */,
index a9ae79c5e72f8374e40d2785ab2e2a3e7bd7794a..3301fc73dfa5914f01c2a41a98c4114f4e140b1c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -283,7 +283,7 @@ public:
     }
 
 private:
-    real evaluatePrefactor(real comparisonSquaredSum, real referenceSquaredSum)
+    static real evaluatePrefactor(real comparisonSquaredSum, real referenceSquaredSum)
     {
         GMX_ASSERT(comparisonSquaredSum > 0,
                    "Squared sum of comparison values needs to be larger than zero.");
index 2e1a9e2eb67decb3d55c90a6619c5fa6e735fdf7..8f6047cc400f8c99ca4c6ed2fe06d2b5be8649e6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -69,6 +69,7 @@ struct is_resizable<T, void_t<decltype(std::declval<T>().resize(size_t()))>> : s
 
 //! Type has a resize member function callable with size_t argument
 template<typename T>
+// NOLINTNEXTLINE misc-definitions-in-headers
 constexpr bool is_resizable_v = is_resizable<T>::value;
 } // namespace detail
 
index 367234a7c23dabea51549b7d3f1f0441c6c3a575..6881111e60613897049147da154d70721519a11c 100644 (file)
@@ -49,7 +49,7 @@ double convert2gmx(double x, int unit)
         case eg2cNm: return x;
         case eg2cBohr: return x * BOHR2NM;
         case eg2cKcal_Mole: return x / CAL2JOULE;
-        case eg2cHartree: return x * ONE_4PI_EPS0 / BOHR2NM;
+        case eg2cHartree: return x * ONE_4PI_EPS0 / BOHR2NM; // NOLINT bugprone-branch-clone
         case eg2cHartree_e: return x * ONE_4PI_EPS0 / BOHR2NM;
         case eg2cAngstrom3: return x * A2NM * A2NM * A2NM;
         case eg2cCoulomb: return x / E_CHARGE;
@@ -69,7 +69,7 @@ double gmx2convert(double x, int unit)
         case eg2cNm: return x;
         case eg2cBohr: return x / BOHR2NM;
         case eg2cKcal_Mole: return x * CAL2JOULE;
-        case eg2cHartree: return x / (ONE_4PI_EPS0 / BOHR2NM);
+        case eg2cHartree: return x / (ONE_4PI_EPS0 / BOHR2NM); // NOLINT bugprone-branch-clone
         case eg2cHartree_e: return x / (ONE_4PI_EPS0 / BOHR2NM);
         case eg2cAngstrom3: return x / (A2NM * A2NM * A2NM);
         case eg2cCoulomb: return x * E_CHARGE;
index fe9b06f311d97a88867ca1f854472d47b3c19e37..6bfff750de79b9613eac34e42a72f545bba1e4bc 100644 (file)
@@ -216,7 +216,7 @@ public:
      * \param[in] opts    Atom temperature coupling groups options
      *                    (annealing is done by groups).
      */
-    void printAnnealingTemperatures(FILE* log, const SimulationGroups* groups, t_grpopts* opts);
+    static void printAnnealingTemperatures(FILE* log, const SimulationGroups* groups, t_grpopts* opts);
 
     /*! \brief Prints average values to log file.
      *
@@ -256,7 +256,7 @@ public:
     void restoreFromEnergyHistory(const energyhistory_t& enerhist);
 
     //! Print an output header to the log file.
-    void printHeader(FILE* log, int64_t steps, double time);
+    static void printHeader(FILE* log, int64_t steps, double time);
 
 private:
     //! Timestep
index 2c9ddb69f0e56c3d8b83d3e31481f11efeea88a4..394c225ddeb819aa704156142ed1c2f76e1a8d2d 100644 (file)
@@ -759,12 +759,5 @@ void mde_delta_h_coll_restore_energyhistory(t_mde_delta_h_coll* dhc, const delta
     {
         dhc->start_lambda = deltaH->start_lambda;
     }
-    if (dhc->dh[0].ndh > 0)
-    {
-        dhc->start_time_set = TRUE;
-    }
-    else
-    {
-        dhc->start_time_set = FALSE;
-    }
+    dhc->start_time_set = (dhc->dh[0].ndh > 0);
 }
index c8654f11365b877ce91e23910e5b017231460c77..88f5e76c8c04352cbf1031f5ebaa6a78bb5d8fb6 100644 (file)
@@ -167,7 +167,9 @@ public:
      * \param[in] testData        Test data structure.
      * \param[in] pbc             Periodic boundary data.
      */
-    void checkConstrainsLength(FloatingPointTolerance tolerance, const ConstraintsTestData& testData, t_pbc pbc)
+    static void checkConstrainsLength(FloatingPointTolerance     tolerance,
+                                      const ConstraintsTestData& testData,
+                                      t_pbc                      pbc)
     {
 
         // Test if all the constraints are satisfied
@@ -208,7 +210,7 @@ public:
      * \param[in] testData        Test data structure.
      * \param[in] pbc             Periodic boundary data.
      */
-    void checkConstrainsDirection(const ConstraintsTestData& testData, t_pbc pbc)
+    static void checkConstrainsDirection(const ConstraintsTestData& testData, t_pbc pbc)
     {
 
         for (index c = 0; c < ssize(testData.constraints_) / 3; c++)
@@ -248,7 +250,7 @@ public:
      * \param[in] tolerance       Allowed tolerance in COM coordinates.
      * \param[in] testData        Test data structure.
      */
-    void checkCOMCoordinates(FloatingPointTolerance tolerance, const ConstraintsTestData& testData)
+    static void checkCOMCoordinates(FloatingPointTolerance tolerance, const ConstraintsTestData& testData)
     {
 
         RVec comPrime0({ 0.0, 0.0, 0.0 });
@@ -278,7 +280,7 @@ public:
      * \param[in] tolerance       Allowed tolerance in COM velocity components.
      * \param[in] testData        Test data structure.
      */
-    void checkCOMVelocity(FloatingPointTolerance tolerance, const ConstraintsTestData& testData)
+    static void checkCOMVelocity(FloatingPointTolerance tolerance, const ConstraintsTestData& testData)
     {
 
         RVec comV0({ 0.0, 0.0, 0.0 });
@@ -307,7 +309,7 @@ public:
      * \param[in] tolerance       Tolerance for the tensor values.
      * \param[in] testData        Test data structure.
      */
-    void checkVirialTensor(FloatingPointTolerance tolerance, const ConstraintsTestData& testData)
+    static void checkVirialTensor(FloatingPointTolerance tolerance, const ConstraintsTestData& testData)
     {
         for (int i = 0; i < DIM; i++)
         {
index abfe31c3ab017285d38c2ec8e67c93cdcf0f0b75..1a03709ac6e3f1fb1d67e027656092c2c45df688 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -165,9 +165,9 @@ public:
      * \param[in]  testData   Test data object
      * \param[in]  totalTime  Total numerical integration time
      */
-    void testAgainstAnalyticalSolution(FloatingPointTolerance  tolerance,
-                                       const LeapFrogTestData& testData,
-                                       const real              totalTime)
+    static void testAgainstAnalyticalSolution(FloatingPointTolerance  tolerance,
+                                              const LeapFrogTestData& testData,
+                                              const real              totalTime)
     {
         for (int i = 0; i < testData.numAtoms_; i++)
         {
index bc7025c5b1e77667114c3e85b0921af4704ed8fc..3a08231685b5c66b282910157a62076bd5a95793 100644 (file)
@@ -202,9 +202,9 @@ public:
      * \param[in]  tolerance         Tolerance to compare floating point numbers.
      * \param[in]  testData          An object, containing all the data structures needed by SETTLE.
      */
-    void checkConstrainsSatisfied(const int                    numSettles,
-                                  const FloatingPointTolerance tolerance,
-                                  const SettleTestData&        testData)
+    static void checkConstrainsSatisfied(const int                    numSettles,
+                                         const FloatingPointTolerance tolerance,
+                                         const SettleTestData&        testData)
     {
         for (int i = 0; i < numSettles; ++i)
         {
@@ -234,9 +234,9 @@ public:
      * \param[in]  tolerance         Tolerance to compare floating point numbers.
      * \param[in]  testData          An object, containing all the data structures needed by SETTLE.
      */
-    void checkVirialSymmetric(const bool                   calcVirial,
-                              const FloatingPointTolerance tolerance,
-                              const SettleTestData&        testData)
+    static void checkVirialSymmetric(const bool                   calcVirial,
+                                     const FloatingPointTolerance tolerance,
+                                     const SettleTestData&        testData)
     {
         for (int d = 0; d < DIM; ++d)
         {
index 25da551d893b96ca526c5218a45dc065da3b3e0b..4d29a38f918463e1e1e34f77a84e775897f94211 100644 (file)
@@ -147,12 +147,12 @@ public:
     }
 
     //! Run the test
-    void runTest(size_t gmx_unused        numAtoms,
-                 size_t                   numConstraints,
-                 const std::vector<int>&  iatom,
-                 const std::vector<real>& constrainedDistances,
-                 const std::vector<real>& inverseMasses,
-                 const std::vector<RVec>& positions)
+    static void runTest(size_t gmx_unused        numAtoms,
+                        size_t                   numConstraints,
+                        const std::vector<int>&  iatom,
+                        const std::vector<real>& constrainedDistances,
+                        const std::vector<real>& inverseMasses,
+                        const std::vector<RVec>& positions)
     {
         // Check the test input is consistent
         assert(numConstraints * constraintStride == iatom.size());
index 76f3a0eedf6b295c0a7878cddf48fb86848bf611..e290939c09e436556d9492d28da0b9a1e5108b7f 100644 (file)
@@ -62,7 +62,7 @@ UpdateConstrainGpu::UpdateConstrainGpu(const t_inputrec& /* ir   */,
                                        GpuEventSynchronizer* /* xUpdatedOnDevice */) :
     impl_(nullptr)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
 }
 
@@ -79,13 +79,13 @@ void UpdateConstrainGpu::integrate(GpuEventSynchronizer* /* fReadyOnDevice */,
                                    const float /* dtPressureCouple */,
                                    const matrix /* prVelocityScalingMatrix*/)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
 }
 
 void UpdateConstrainGpu::scaleCoordinates(const matrix /* scalingMatrix */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
 }
 
@@ -96,19 +96,19 @@ void UpdateConstrainGpu::set(DeviceBuffer<RVec> /* d_x */,
                              const t_mdatoms& /* md */,
                              const int /* numTempScaleValues */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
 }
 
 void UpdateConstrainGpu::setPbc(const PbcType /* pbcType */, const matrix /* box */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
 }
 
 GpuEventSynchronizer* UpdateConstrainGpu::getCoordinatesReadySync()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
     return nullptr;
 }
index f33aa4cb5c6ddeb3ecbd68dca308819608fd0b63..cf4856825c432c8599f5847f3997e62cb00fae5e 100644 (file)
@@ -308,7 +308,7 @@ static int detectGroup(int                     firstAtom,
     {
         AtomIndexExtremes extremes = vsiteConstructRange(lastAtom + 1, moltype);
         if (extremes.minAtom < firstAtom)
-        {
+        { // NOLINT bugprone-branch-clone
             /* Constructing atom precedes the group */
             return 0;
         }
index b34bbdef355bca1c2f4f9c12c44720be51a48847..63a3df664a2855772605ccb429a10c131ae6b91a 100644 (file)
@@ -280,7 +280,7 @@ static void doStopComMotionLinear(const t_mdatoms& mdatoms, gmx::ArrayRef<gmx::R
         }
     }
     else if (group_id == nullptr)
-    {
+    { // NOLINT bugprone-branch-clone This is actually a clang-tidy bug
 #pragma omp for schedule(static)
         for (int i = 0; i < homenr; i++)
         {
@@ -324,6 +324,7 @@ static void doStopComMotionAccelerationCorrection(int                      homen
 {
     const real xCorrectionFactor = 0.5 * vcm.timeStep;
 
+    // NOLINTNEXTLINE bugprone-branch-clone This is actually a clang-tidy bug
     if (group_id == nullptr)
     {
 #pragma omp for schedule(static)
index fa5b0750ebee08465df2055976b2aa35e1c180c7..3971786b001ca7c082da7781b3fd5dda046bba86 100644 (file)
@@ -879,7 +879,8 @@ void gmx::LegacySimulator::do_md()
 
         if (MASTER(cr) && do_log)
         {
-            energyOutput.printHeader(fplog, step, t); /* can we improve the information printed here? */
+            gmx::EnergyOutput::printHeader(fplog, step,
+                                           t); /* can we improve the information printed here? */
         }
 
         if (ir->efep != efepNO)
@@ -1544,7 +1545,8 @@ void gmx::LegacySimulator::do_md()
 
             if (doSimulatedAnnealing)
             {
-                energyOutput.printAnnealingTemperatures(do_log ? fplog : nullptr, groups, &(ir->opts));
+                gmx::EnergyOutput::printAnnealingTemperatures(do_log ? fplog : nullptr, groups,
+                                                              &(ir->opts));
             }
             if (do_log || do_ene || do_dr || do_or)
             {
@@ -1671,7 +1673,7 @@ void gmx::LegacySimulator::do_md()
     {
         if (ir->nstcalcenergy > 0)
         {
-            energyOutput.printAnnealingTemperatures(fplog, groups, &(ir->opts));
+            gmx::EnergyOutput::printAnnealingTemperatures(fplog, groups, &(ir->opts));
             energyOutput.printAverages(fplog, groups);
         }
     }
index 2cfa7705a0e94978fa03ec39b0471b2b419c6db8..653dae965673107bb532ebe46cd3dfeadcacfa57 100644 (file)
@@ -208,13 +208,11 @@ void gmx::LegacySimulator::do_mimic()
     int        nstglobalcomm = 1;
     const bool bNS           = true;
 
-    // Communicator to interact with MiMiC
-    MimicCommunicator mimicCommunicator{};
     if (MASTER(cr))
     {
-        mimicCommunicator.init();
-        mimicCommunicator.sendInitData(top_global, state_global->x);
-        ir->nsteps = mimicCommunicator.getStepNumber();
+        MimicCommunicator::init();
+        MimicCommunicator::sendInitData(top_global, state_global->x);
+        ir->nsteps = MimicCommunicator::getStepNumber();
     }
 
     ir->nstxout_compressed                   = 0;
@@ -364,7 +362,7 @@ void gmx::LegacySimulator::do_mimic()
 
         if (MASTER(cr))
         {
-            mimicCommunicator.getCoords(&state_global->x, state_global->natoms);
+            MimicCommunicator::getCoords(&state_global->x, state_global->natoms);
         }
 
         if (ir->efep != efepNO)
@@ -396,7 +394,7 @@ void gmx::LegacySimulator::do_mimic()
 
         if (MASTER(cr))
         {
-            energyOutput.printHeader(fplog, step, t); /* can we improve the information printed here? */
+            EnergyOutput::printHeader(fplog, step, t); /* can we improve the information printed here? */
         }
 
         if (ir->efep != efepNO)
@@ -493,8 +491,8 @@ void gmx::LegacySimulator::do_mimic()
 
             if (MASTER(cr))
             {
-                mimicCommunicator.sendEnergies(enerd->term[F_EPOT]);
-                mimicCommunicator.sendForces(ftemp, state_global->natoms);
+                MimicCommunicator::sendEnergies(enerd->term[F_EPOT]);
+                MimicCommunicator::sendForces(ftemp, state_global->natoms);
             }
         }
 
@@ -526,7 +524,7 @@ void gmx::LegacySimulator::do_mimic()
             const bool do_dr  = ir->nstdisreout != 0;
             const bool do_or  = ir->nstorireout != 0;
 
-            energyOutput.printAnnealingTemperatures(do_log ? fplog : nullptr, groups, &(ir->opts));
+            EnergyOutput::printAnnealingTemperatures(do_log ? fplog : nullptr, groups, &(ir->opts));
             energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), do_ene, do_dr, do_or,
                                                do_log ? fplog : nullptr, step, t, fcd, awh);
 
@@ -570,7 +568,7 @@ void gmx::LegacySimulator::do_mimic()
 
     if (MASTER(cr))
     {
-        mimicCommunicator.finalize();
+        MimicCommunicator::finalize();
     }
 
     if (!thisRankHasDuty(cr, DUTY_PME))
index 9329d5040b0b382bda5ae6de7f94403f7cabd7b8..c6959e3643f567f4cc37fca2eca5547f81b10f8b 100644 (file)
@@ -1123,7 +1123,7 @@ void LegacySimulator::do_cg()
                                          enerd, nullptr, nullptr, nullptr, nullBox, nullptr,
                                          nullptr, vir, pres, nullptr, mu_tot, constr);
 
-        energyOutput.printHeader(fplog, step, step);
+        EnergyOutput::printHeader(fplog, step, step);
         energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), TRUE, FALSE, FALSE, fplog, step,
                                            step, fcd, nullptr);
     }
@@ -1537,7 +1537,7 @@ void LegacySimulator::do_cg()
 
             if (do_log)
             {
-                energyOutput.printHeader(fplog, step, step);
+                EnergyOutput::printHeader(fplog, step, step);
             }
             energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), do_ene, FALSE, FALSE,
                                                do_log ? fplog : nullptr, step, step, fcd, nullptr);
@@ -1577,7 +1577,7 @@ void LegacySimulator::do_cg()
         if (!do_log)
         {
             /* Write final value to log since we didn't do anything the last step */
-            energyOutput.printHeader(fplog, step, step);
+            EnergyOutput::printHeader(fplog, step, step);
         }
         if (!do_ene || !do_log)
         {
@@ -1772,7 +1772,7 @@ void LegacySimulator::do_lbfgs()
                                          enerd, nullptr, nullptr, nullptr, nullBox, nullptr,
                                          nullptr, vir, pres, nullptr, mu_tot, constr);
 
-        energyOutput.printHeader(fplog, step, step);
+        EnergyOutput::printHeader(fplog, step, step);
         energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), TRUE, FALSE, FALSE, fplog, step,
                                            step, fcd, nullptr);
     }
@@ -2263,7 +2263,7 @@ void LegacySimulator::do_lbfgs()
 
             if (do_log)
             {
-                energyOutput.printHeader(fplog, step, step);
+                EnergyOutput::printHeader(fplog, step, step);
             }
             energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), do_ene, FALSE, FALSE,
                                                do_log ? fplog : nullptr, step, step, fcd, nullptr);
@@ -2303,7 +2303,7 @@ void LegacySimulator::do_lbfgs()
      */
     if (!do_log) /* Write final value to log since we didn't do anythin last step */
     {
-        energyOutput.printHeader(fplog, step, step);
+        EnergyOutput::printHeader(fplog, step, step);
     }
     if (!do_ene || !do_log) /* Write final energy file entries */
     {
@@ -2441,7 +2441,7 @@ void LegacySimulator::do_steep()
 
         if (MASTER(cr))
         {
-            energyOutput.printHeader(fplog, count, count);
+            EnergyOutput::printHeader(fplog, count, count);
         }
 
         if (count == 0)
index dfa8d39ae499d9862d81e1a9ae5f1dda0c985da8..e3709ab4596ec72b326d4287ec91d8a3b49b77e2 100644 (file)
@@ -510,7 +510,7 @@ void gmx::LegacySimulator::do_rerun()
 
         if (MASTER(cr))
         {
-            energyOutput.printHeader(fplog, step, t); /* can we improve the information printed here? */
+            EnergyOutput::printHeader(fplog, step, t); /* can we improve the information printed here? */
         }
 
         if (ir->efep != efepNO)
@@ -618,7 +618,7 @@ void gmx::LegacySimulator::do_rerun()
             const bool do_dr  = ir->nstdisreout != 0;
             const bool do_or  = ir->nstorireout != 0;
 
-            energyOutput.printAnnealingTemperatures(do_log ? fplog : nullptr, groups, &(ir->opts));
+            EnergyOutput::printAnnealingTemperatures(do_log ? fplog : nullptr, groups, &(ir->opts));
             energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), do_ene, do_dr, do_or,
                                                do_log ? fplog : nullptr, step, t, fcd, awh);
 
index 55e34445723f0c3a989d22dbc6b80bf09ff69b82..0656ac7bfe3924a70be89f28ac5677df892abc2d 100644 (file)
@@ -1132,8 +1132,7 @@ int Mdrunner::mdrunner()
     }
 
     // Produce the task assignment for this rank - done after DD is constructed
-    GpuTaskAssignmentsBuilder gpuTaskAssignmentsBuilder;
-    GpuTaskAssignments        gpuTaskAssignments = gpuTaskAssignmentsBuilder.build(
+    GpuTaskAssignments gpuTaskAssignments = GpuTaskAssignmentsBuilder::build(
             gpuIdsToUse, userGpuTaskAssignment, *hwinfo, communicator, physicalNodeComm,
             nonbondedTarget, pmeTarget, bondedTarget, updateTarget, useGpuForNonbonded,
             useGpuForPme, thisRankHasDuty(cr, DUTY_PP),
index bc72cfaaed8ff92e2c5868adcc834244d9d58caa..9cd90ccd1e549ed281d59eac3bf2c76b54f1687a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2019, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2019,2020, 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.
@@ -114,17 +114,17 @@ TEST(ThreadAffinityMultiRankTest, HandlesTooManyThreadsWithForce)
 class ThreadAffinityHeterogeneousNodesTest : public ::testing::Test
 {
 public:
-    int  currentNode() const { return gmx_node_rank() / 2; }
-    int  indexInNode() const { return gmx_node_rank() % 2; }
-    bool isMaster() const { return gmx_node_rank() == 0; }
+    static int  currentNode() { return gmx_node_rank() / 2; }
+    static int  indexInNode() { return gmx_node_rank() % 2; }
+    static bool isMaster() { return gmx_node_rank() == 0; }
 
-    void setupNodes(ThreadAffinityTestHelper* helper, std::array<int, 2> cores)
+    static void setupNodes(ThreadAffinityTestHelper* helper, std::array<int, 2> cores)
     {
         const int node = currentNode();
         helper->setPhysicalNodeId(node);
         helper->setLogicalProcessorCount(cores[node]);
     }
-    void expectNodeAffinitySet(ThreadAffinityTestHelper* helper, int node, int core)
+    static void expectNodeAffinitySet(ThreadAffinityTestHelper* helper, int node, int core)
     {
         if (currentNode() == node)
         {
index 6720e7a682f90f7c9d937ba25caf98d76cbe544d..d760c6d4b1c3ca1b866818702c07fb812bc385b8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019,2020, 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.
@@ -108,6 +108,7 @@ public:
             expectAffinitySet(core);
         }
     }
+    // NOLINTNEXTLINE readability-convert-member-functions-to-static
     void expectAffinitySetThatFails(int core)
     {
         using ::testing::Return;
index fa25fa48751fb23258927949bb91b4aab91eca57..616abbdd0b25a775a8273cb8e8508b537aa498e9 100644 (file)
@@ -1458,7 +1458,7 @@ bool inputrecPbcXY2Walls(const t_inputrec* ir)
 bool integratorHasConservedEnergyQuantity(const t_inputrec* ir)
 {
     if (!EI_MD(ir->eI))
-    {
+    { // NOLINT bugprone-branch-clone
         // Energy minimization or stochastic integrator: no conservation
         return false;
     }
index 8dc7b07c0366adeea9b47b2ab1a0d68635b772ee..ef4302a59077b495a91053e7799be1bc3482eaea 100644 (file)
@@ -639,7 +639,11 @@ gmx_bool inputrecNphTrotter(const t_inputrec* ir);
 bool inputrecPbcXY2Walls(const t_inputrec* ir);
 
 /*! \brief Returns true for MD integator with T and/or P-coupling that supports
- * calculating the conserved energy quantity.
+ * calculating a conserved energy quantity.
+ *
+ * Note that dynamical integrators without T and P coupling (ie NVE)
+ * return false, i.e. the return value refers to whether there
+ * is a conserved quantity different than the total energy.
  */
 bool integratorHasConservedEnergyQuantity(const t_inputrec* ir);
 
index 269b6eb3778650061ccbf9c82789e9da4b357350..1600c7a062fbc9c26a162b57a0b7fa7dc99d5b0e 100644 (file)
@@ -79,14 +79,14 @@ StatePropagatorDataGpu::~StatePropagatorDataGpu() = default;
 
 void StatePropagatorDataGpu::reinit(int /* numAtomsLocal */, int /* numAtomsAll   */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
 
 std::tuple<int, int> StatePropagatorDataGpu::getAtomRangesFromAtomLocality(AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return std::make_tuple(0, 0);
@@ -94,7 +94,7 @@ std::tuple<int, int> StatePropagatorDataGpu::getAtomRangesFromAtomLocality(AtomL
 
 DeviceBuffer<RVec> StatePropagatorDataGpu::getCoordinates()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return {};
@@ -105,7 +105,7 @@ GpuEventSynchronizer* StatePropagatorDataGpu::getCoordinatesReadyOnDeviceEvent(
         const SimulationWorkload& /* simulationWork */,
         const StepWorkload& /* stepWork       */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return nullptr;
@@ -113,14 +113,14 @@ GpuEventSynchronizer* StatePropagatorDataGpu::getCoordinatesReadyOnDeviceEvent(
 
 void StatePropagatorDataGpu::waitCoordinatesCopiedToDevice(AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
 
 GpuEventSynchronizer* StatePropagatorDataGpu::xUpdatedOnDevice()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return nullptr;
@@ -129,14 +129,14 @@ GpuEventSynchronizer* StatePropagatorDataGpu::xUpdatedOnDevice()
 void StatePropagatorDataGpu::copyCoordinatesToGpu(const gmx::ArrayRef<const gmx::RVec> /* h_x */,
                                                   AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
 
 void StatePropagatorDataGpu::waitCoordinatesReadyOnHost(AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
@@ -144,7 +144,7 @@ void StatePropagatorDataGpu::waitCoordinatesReadyOnHost(AtomLocality /* atomLoca
 void StatePropagatorDataGpu::copyCoordinatesFromGpu(gmx::ArrayRef<gmx::RVec> /* h_x          */,
                                                     AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
@@ -152,7 +152,7 @@ void StatePropagatorDataGpu::copyCoordinatesFromGpu(gmx::ArrayRef<gmx::RVec> /*
 
 DeviceBuffer<RVec> StatePropagatorDataGpu::getVelocities()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return {};
@@ -161,14 +161,14 @@ DeviceBuffer<RVec> StatePropagatorDataGpu::getVelocities()
 void StatePropagatorDataGpu::copyVelocitiesToGpu(const gmx::ArrayRef<const gmx::RVec> /* h_v */,
                                                  AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
 
 GpuEventSynchronizer* StatePropagatorDataGpu::getVelocitiesReadyOnDeviceEvent(AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return nullptr;
@@ -177,14 +177,14 @@ GpuEventSynchronizer* StatePropagatorDataGpu::getVelocitiesReadyOnDeviceEvent(At
 void StatePropagatorDataGpu::copyVelocitiesFromGpu(gmx::ArrayRef<gmx::RVec> /* h_v          */,
                                                    AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
 
 void StatePropagatorDataGpu::waitVelocitiesReadyOnHost(AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
@@ -192,7 +192,7 @@ void StatePropagatorDataGpu::waitVelocitiesReadyOnHost(AtomLocality /* atomLocal
 
 DeviceBuffer<RVec> StatePropagatorDataGpu::getForces()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return {};
@@ -201,7 +201,7 @@ DeviceBuffer<RVec> StatePropagatorDataGpu::getForces()
 void StatePropagatorDataGpu::copyForcesToGpu(const gmx::ArrayRef<const gmx::RVec> /* h_f          */,
                                              AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
@@ -209,7 +209,7 @@ void StatePropagatorDataGpu::copyForcesToGpu(const gmx::ArrayRef<const gmx::RVec
 GpuEventSynchronizer* StatePropagatorDataGpu::getForcesReadyOnDeviceEvent(AtomLocality /* atomLocality */,
                                                                           bool /* useGpuFBufferOps */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return nullptr;
@@ -217,7 +217,7 @@ GpuEventSynchronizer* StatePropagatorDataGpu::getForcesReadyOnDeviceEvent(AtomLo
 
 GpuEventSynchronizer* StatePropagatorDataGpu::fReducedOnDevice()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return nullptr;
@@ -226,14 +226,14 @@ GpuEventSynchronizer* StatePropagatorDataGpu::fReducedOnDevice()
 void StatePropagatorDataGpu::copyForcesFromGpu(gmx::ArrayRef<gmx::RVec> /* h_f          */,
                                                AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
 
 void StatePropagatorDataGpu::waitForcesReadyOnHost(AtomLocality /* atomLocality */)
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
 }
@@ -241,7 +241,7 @@ void StatePropagatorDataGpu::waitForcesReadyOnHost(AtomLocality /* atomLocality
 
 const DeviceStream* StatePropagatorDataGpu::getUpdateStream()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return nullptr;
@@ -249,7 +249,7 @@ const DeviceStream* StatePropagatorDataGpu::getUpdateStream()
 
 int StatePropagatorDataGpu::numAtomsLocal()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return 0;
@@ -257,7 +257,7 @@ int StatePropagatorDataGpu::numAtomsLocal()
 
 int StatePropagatorDataGpu::numAtomsAll()
 {
-    GMX_ASSERT(false,
+    GMX_ASSERT(!impl_,
                "A CPU stub method from GPU state propagator data was called instead of one from "
                "GPU implementation.");
     return 0;
index 7c2b89ff7498af3fdc2bcfcae8ceb6e80da27770..12dcf874d3f976913149edf461766bd8eb2ca813 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020, 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.
@@ -102,7 +102,7 @@ void gmx::MimicCommunicator::init()
 {
     char path[GMX_PATH_MAX];
     gmx_getcwd(path, GMX_PATH_MAX);
-    return MCL_init_client(path);
+    MCL_init_client(path);
 }
 
 void gmx::MimicCommunicator::sendInitData(gmx_mtop_t* mtop, PaddedHostVector<gmx::RVec> coords)
index 033a11d482ce588cb3e19fd0c1cb9ea7af5a3cfb..6d2b9c276139420de2eeb25d2e539e841d7821d8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020, 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.
@@ -60,7 +60,7 @@ public:
     /*! \brief
      * Initializes the communicator
      */
-    void init();
+    static void init();
 
     /*! \brief
      * Sends the data needed for MiMiC initialization
@@ -73,14 +73,14 @@ public:
      * @param mtop global topology data
      * @param coords coordinates of all atoms
      */
-    void sendInitData(gmx_mtop_t* mtop, PaddedHostVector<gmx::RVec> coords);
+    static void sendInitData(gmx_mtop_t* mtop, PaddedHostVector<gmx::RVec> coords);
 
     /*! \brief
      * Gets the number of MD steps to perform from MiMiC
      *
      * @return nsteps the number of MD steps to perform
      */
-    int64_t getStepNumber();
+    static int64_t getStepNumber();
 
     /*! \brief
      * Receive and array of updated atomic coordinates from MiMiC
@@ -88,14 +88,14 @@ public:
      * @param x array of coordinates to fill
      * @param natoms number of atoms in the system
      */
-    void getCoords(PaddedHostVector<RVec>* x, int natoms);
+    static void getCoords(PaddedHostVector<RVec>* x, int natoms);
 
     /*! \brief
      * Send the potential energy value to MiMiC
      *
      * @param energy energy value to send
      */
-    void sendEnergies(real energy);
+    static void sendEnergies(real energy);
 
     /*! \brief
      * Send classical forces acting on all atoms in the system
@@ -104,12 +104,12 @@ public:
      * @param forces array of forces to send
      * @param natoms number of atoms in the system
      */
-    void sendForces(ArrayRef<gmx::RVec> forces, int natoms);
+    static void sendForces(ArrayRef<gmx::RVec> forces, int natoms);
 
     /*! \brief
      * Finish communications and disconnect from the server
      */
-    void finalize();
+    static void finalize();
 };
 
 } // namespace gmx
index 9d15b56c83f70baf5023e98a347cb0785b411092..54a4d407ff064101ee7a79983e18df6ac54f4806 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2017,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2017,2019,2020, 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.
@@ -198,12 +198,12 @@ std::string FileNameOptionManager::completeFileName(const std::string& value, co
                 return processedValue;
             }
             if (bAllowMissing)
-            {
+            { // NOLINT bugprone-branch-clone
                 return value + option.defaultExtension();
             }
             else if (option.isLibraryFile())
             {
-                // TODO: Treat also library files here.
+                // TODO: Treat also library files here and remove the NOLINT.
                 return value + option.defaultExtension();
             }
             else
@@ -262,12 +262,12 @@ std::string FileNameOptionManager::completeDefaultFileName(const std::string&
             return completedName;
         }
         if (option.allowMissing())
-        {
+        { // NOLINT bugprone-branch-clone
             return realPrefix + option.defaultExtension();
         }
-        else if (option.isLibraryFile())
+        else if (option.isLibraryFile()) // NOLINT bugprone-branch-clone
         {
-            // TODO: Treat also library files here.
+            // TODO: Treat also library files here and remove the NOLINT
             return realPrefix + option.defaultExtension();
         }
         else if (option.isSet())
index 8fb7069e632576d9fee31a26c6e3d868f0223666..ef4e48026704f0e2a762f7c9946b3617f5246156 100644 (file)
@@ -347,14 +347,14 @@ public:
     gmx::KeyValueTreeBuilder builder_;
 
 private:
-    std::vector<char> serializeTree(const gmx::KeyValueTreeObject& tree)
+    static std::vector<char> serializeTree(const gmx::KeyValueTreeObject& tree)
     {
         gmx::InMemorySerializer serializer;
         gmx::serializeKeyValueTree(tree, &serializer);
         return serializer.finishAndGetBuffer();
     }
 
-    std::string formatBuffer(const std::vector<char>& buffer)
+    static std::string formatBuffer(const std::vector<char>& buffer)
     {
         return gmx::formatAndJoin(buffer, " ", [](char c) {
             return gmx::formatString("%02x", static_cast<unsigned char>(c));
index 9a95f2430d967e1fe7b5fc4a15f2ec07b2d82a44..17cb7bdd8cf6e9b6e9ce0e9e4f05910d02f9f823 100644 (file)
@@ -3636,14 +3636,7 @@ std::unique_ptr<gmx::EnforcedRotation> init_rot(FILE*                       fplo
     er->restartWithAppending = (startingBehavior == gmx::StartingBehavior::RestartWithAppending);
 
     /* When appending, skip first output to avoid duplicate entries in the data files */
-    if (er->restartWithAppending)
-    {
-        er->bOut = FALSE;
-    }
-    else
-    {
-        er->bOut = TRUE;
-    }
+    er->bOut = er->restartWithAppending;
 
     if (MASTER(cr) && er->bOut)
     {
index 21956445bef1ea8203785a8eb4b925efbd1af736..fe8e604d6c656ab620a684173b69717b159e7fb8 100644 (file)
@@ -70,7 +70,7 @@ class PullTest : public ::testing::Test
 protected:
     PullTest() {}
 
-    void test(PbcType pbcType, matrix box)
+    static void test(PbcType pbcType, matrix box)
     {
         t_pbc pbc;
 
index d940a456675cb2801e1ceab3658d36bd3105529c..b1dcb03d09c0f3eef63b75d5b6e2062fc581d262 100644 (file)
@@ -158,16 +158,6 @@ RestraintMDModuleImpl::RestraintMDModuleImpl(std::shared_ptr<IRestraintPotential
     GMX_ASSERT(forceProvider_, "Class invariant implies non-null ForceProvider.");
 }
 
-IMdpOptionProvider* RestraintMDModuleImpl::mdpOptionProvider()
-{
-    return nullptr;
-}
-
-IMDOutputProvider* RestraintMDModuleImpl::outputProvider()
-{
-    return nullptr;
-}
-
 void RestraintMDModuleImpl::initForceProviders(ForceProviders* forceProviders)
 {
     GMX_ASSERT(forceProvider_, "Class invariant implies non-null ForceProvider member.");
index b1a62a9d69440782663cc74d41df7af8d595d04a..328d0ba6bc4135c49c5a8923b5b146ce91ad32b2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020, 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.
@@ -290,16 +290,6 @@ public:
 
     ~RestraintMDModuleImpl();
 
-    /*!
-     * \brief Unused implementation of IMDModule aspect
-     */
-    IMdpOptionProvider* mdpOptionProvider();
-
-    /*!
-     * \brief Unused implementation of IMDModule aspect
-     */
-    IMDOutputProvider* outputProvider();
-
     /*!
      * \brief Implement IMDModule interface.
      *
index e6d458d89c5986e073621076c3dd613219b68f60..bf9fd86f9afd770058a81ddedf096dc45f07ad9d 100644 (file)
@@ -2586,11 +2586,8 @@ static void free_item_compilerdata(const SelectionTreeElementPointer& sel)
 namespace gmx
 {
 
-SelectionCompiler::SelectionCompiler() {}
-
 /*!
  * \param[in,out] coll Selection collection to be compiled.
- * \returns       0 on successful compilation, a non-zero error code on error.
  *
  * Before compilation, the selection collection should have been initialized
  * with gmx_ana_selcollection_parse_*().
@@ -2601,7 +2598,7 @@ SelectionCompiler::SelectionCompiler() {}
  * The covered fraction information in \p sc is initialized to
  * \ref CFRAC_NONE.
  */
-void SelectionCompiler::compile(SelectionCollection* coll)
+void compileSelection(SelectionCollection* coll)
 {
     gmx_ana_selcollection_t*    sc = &coll->impl_->sc_;
     gmx_sel_evaluate_t          evaldata;
index 08ff2c51a608c4843f603e7a9b1928fc16851638..6602835a7516411c8bf07bc195f1e1c332835825 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2013,2019, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2013,2019,2020, 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.
@@ -51,7 +51,7 @@ class SelectionCollection;
  * \brief
  * Implements selection compilation.
  *
- * This class is used to implement SelectionCollection::compile().
+ * This function is used to implement SelectionCollection::compile().
  * It prepares the selections in a selection collection for evaluation and
  * performs some optimizations.
  *
@@ -59,15 +59,7 @@ class SelectionCollection;
  *
  * \ingroup module_selection
  */
-class SelectionCompiler
-{
-public:
-    //! Creates a selection compiler.
-    SelectionCompiler();
-
-    //! Compiles the given selection collection.
-    void compile(SelectionCollection* coll);
-};
+void compileSelection(SelectionCollection* coll);
 
 } // namespace gmx
 
index bf211d566806839c2eae6903d9252d0d537c0493..fd2be1443437a43bf7c4dee377c195985ed0b1c8 100644 (file)
@@ -419,6 +419,7 @@ SelectionEvaluator::SelectionEvaluator() {}
  * This is the only function that user code should call if they want to
  * evaluate a selection for a new frame.
  */
+// NOLINTNEXTLINE readability-convert-member-functions-to-static
 void SelectionEvaluator::evaluate(SelectionCollection* coll, t_trxframe* fr, t_pbc* pbc)
 {
     gmx_ana_selcollection_t* sc = &coll->impl_->sc_;
@@ -464,6 +465,7 @@ void SelectionEvaluator::evaluate(SelectionCollection* coll, t_trxframe* fr, t_p
  * \param[in,out] coll  The selection collection to evaluate.
  * \param[in]     nframes Total number of frames.
  */
+// NOLINTNEXTLINE readability-convert-member-functions-to-static
 void SelectionEvaluator::evaluateFinal(SelectionCollection* coll, int nframes)
 {
     gmx_ana_selcollection_t* sc = &coll->impl_->sc_;
index fafc654a058fec1d5d193e7d484fcc308a84ef87..38b8bb67ea73cf0132c5a972db564988fb8662c7 100644 (file)
@@ -255,7 +255,7 @@ static e_index_t index_type_for_poscalc(e_poscalc_t type)
         case POS_ATOM: return INDEX_ATOM;
         case POS_RES: return INDEX_RES;
         case POS_MOL: return INDEX_MOL;
-        case POS_ALL: return INDEX_ALL;
+        case POS_ALL: // Intended fall through
         case POS_ALL_PBC: return INDEX_ALL;
     }
     return INDEX_UNKNOWN;
index b1c345ee06d678e128b22c988be70a09a72beadb..ff040fe8546adefee741d11fb4e8e62b795af99f 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2009-2018, The GROMACS development team.
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -167,7 +167,7 @@ static int init_method_token(YYSTYPE*                          yylval,
         }
         switch (method->type)
         {
-            case INT_VALUE: return METHOD_NUMERIC;
+            case INT_VALUE: // Intended fall through
             case REAL_VALUE: return METHOD_NUMERIC;
             case POS_VALUE: return METHOD_POS;
             case GROUP_VALUE: return METHOD_GROUP;
@@ -304,7 +304,7 @@ int _gmx_sel_lexer_process_identifier(YYSTYPE* yylval, YYLTYPE* yylloc, char* yy
         yylval->sel = new gmx::SelectionTreeElementPointer(var);
         switch (var->v.type)
         {
-            case INT_VALUE: return VARIABLE_NUMERIC;
+            case INT_VALUE: // Intended fall through
             case REAL_VALUE: return VARIABLE_NUMERIC;
             case POS_VALUE: return VARIABLE_POS;
             case GROUP_VALUE: return VARIABLE_GROUP;
index 197f0962c941bac78aad14919340ad8a6bb6c545..a9c6e6825aea95cfa26d8577b2915cc9d9c11983 100644 (file)
@@ -503,7 +503,7 @@ bool SelectionCollection::Impl::areForcesRequested() const
 
 
 SelectionTopologyProperties
-SelectionCollection::Impl::requiredTopologyPropertiesForPositionType(const std::string& post, bool forces) const
+SelectionCollection::Impl::requiredTopologyPropertiesForPositionType(const std::string& post, bool forces)
 {
     SelectionTopologyProperties props;
     if (!post.empty())
@@ -687,7 +687,8 @@ bool SelectionCollection::requiresIndexGroups() const
 
 SelectionList SelectionCollection::parseFromStdin(int count, bool bInteractive, const std::string& context)
 {
-    return parseInteractive(count, &StandardInputStream::instance(),
+    StandardInputStream inputStream;
+    return parseInteractive(count, &inputStream,
                             bInteractive ? &TextOutputFile::standardError() : nullptr, context);
 }
 
@@ -764,8 +765,7 @@ void SelectionCollection::compile()
         printTree(stderr, false);
     }
 
-    SelectionCompiler compiler;
-    compiler.compile(this);
+    compileSelection(this);
 
     if (impl_->debugLevel_ != Impl::DebugLevel::None)
     {
index 7e3d3daef54aeb1a882bcf49cdc4c68c8a9139d4..886bb898a0491580c5093f57bb118db91de3cf0c 100644 (file)
@@ -419,7 +419,7 @@ private:
     /*! \brief
      * Needed for the compiler to freely modify the collection.
      */
-    friend class SelectionCompiler;
+    friend void compileSelection(SelectionCollection* /*coll*/);
     /*! \brief
      * Needed for the evaluator to freely modify the collection.
      */
index 4c79e66c6f6110e4c6fae0d1564e6ad2f7e7dc2f..f5cec6b3a00b9ee3ed4e112799b86cad102c48a3 100644 (file)
@@ -160,8 +160,8 @@ public:
     /*! \brief
      * Returns topology properties needed for a certain position type.
      */
-    SelectionTopologyProperties requiredTopologyPropertiesForPositionType(const std::string& post,
-                                                                          bool forces) const;
+    static SelectionTopologyProperties requiredTopologyPropertiesForPositionType(const std::string& post,
+                                                                                 bool forces);
 
     //! Describes the available debugging levels
     enum class DebugLevel : int
index c6c68d8805a3946dfecbc78e55023a1e39000654..5419a6bb876ae1cf1ef4f2a80e28039d6171bf16 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020, 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.
@@ -92,7 +92,7 @@ public:
 
     void promptSelections()
     {
-        const bool isInteractive = StandardInputStream::instance().isInteractive();
+        const bool isInteractive = StandardInputStream::isInteractive();
         initIndexGroups();
         manager_.parseRequestedFromStdin(isInteractive);
         doneIndexGroups();
index e93a3cc129babc16ac73afa3465749ccda3fac9e..ec96ec50fdf868f6d48db210e7154bd89188a33c 100644 (file)
@@ -588,11 +588,11 @@ private:
     /*! \brief
      * Prints markup for starting a list of keywords.
      */
-    void writeKeywordListStart(const HelpWriterContext& context, const char* heading) const;
+    static void writeKeywordListStart(const HelpWriterContext& context, const char* heading);
     /*! \brief
      * Prints markup for ending a list of keywords.
      */
-    void writeKeywordListEnd(const HelpWriterContext& context, const char* extraInfo) const;
+    static void writeKeywordListEnd(const HelpWriterContext& context, const char* extraInfo);
 
     /*! \brief
      * Prints a brief list of keywords (selection methods) available.
@@ -667,7 +667,7 @@ void KeywordsHelpTopic::writeHelp(const HelpWriterContext& context) const
     writeKeywordSubTopics(context);
 }
 
-void KeywordsHelpTopic::writeKeywordListStart(const HelpWriterContext& context, const char* heading) const
+void KeywordsHelpTopic::writeKeywordListStart(const HelpWriterContext& context, const char* heading)
 {
     context.paragraphBreak();
     std::string fullHeading("* ");
@@ -681,7 +681,7 @@ void KeywordsHelpTopic::writeKeywordListStart(const HelpWriterContext& context,
     }
 }
 
-void KeywordsHelpTopic::writeKeywordListEnd(const HelpWriterContext& context, const char* extraInfo) const
+void KeywordsHelpTopic::writeKeywordListEnd(const HelpWriterContext& context, const char* extraInfo)
 {
     if (context.outputFormat() == eHelpOutputFormat_Rst)
     {
index ab8d19566ecbba58a3d6cbf52575fe8cb7441968..d0f61f30f7d934a480198c574a3c12e382fe3c7f 100644 (file)
@@ -149,13 +149,13 @@ public:
         GMX_RELEASE_ASSERT(testPos_.empty(), "Cannot add positions after testPositions() call");
         testPositions_.emplace_back(x);
     }
-    gmx::RVec        generateRandomPosition();
-    std::vector<int> generateIndex(int count, uint64_t seed) const;
-    void             generateRandomRefPositions(int count);
-    void             generateRandomTestPositions(int count);
-    void             useRefPositionsAsTestPositions();
-    void             computeReferences(t_pbc* pbc) { computeReferencesInternal(pbc, false); }
-    void             computeReferencesXY(t_pbc* pbc) { computeReferencesInternal(pbc, true); }
+    gmx::RVec               generateRandomPosition();
+    static std::vector<int> generateIndex(int count, uint64_t seed);
+    void                    generateRandomRefPositions(int count);
+    void                    generateRandomTestPositions(int count);
+    void                    useRefPositionsAsTestPositions();
+    void                    computeReferences(t_pbc* pbc) { computeReferencesInternal(pbc, false); }
+    void computeReferencesXY(t_pbc* pbc) { computeReferencesInternal(pbc, true); }
 
     bool containsPair(int testIndex, const RefPair& pair) const
     {
@@ -217,7 +217,7 @@ gmx::RVec NeighborhoodSearchTestData::generateRandomPosition()
     return x;
 }
 
-std::vector<int> NeighborhoodSearchTestData::generateIndex(int count, uint64_t seed) const
+std::vector<int> NeighborhoodSearchTestData::generateIndex(int count, uint64_t seed)
 {
     gmx::DefaultRandomEngine           rngIndex(seed);
     gmx::UniformRealDistribution<real> dist;
@@ -389,21 +389,24 @@ void ExclusionsHelper::generateExclusions()
 class NeighborhoodSearchTest : public ::testing::Test
 {
 public:
-    void testIsWithin(gmx::AnalysisNeighborhoodSearch* search, const NeighborhoodSearchTestData& data);
-    void testMinimumDistance(gmx::AnalysisNeighborhoodSearch*  search,
+    static void testIsWithin(gmx::AnalysisNeighborhoodSearch*  search,
                              const NeighborhoodSearchTestData& data);
-    void testNearestPoint(gmx::AnalysisNeighborhoodSearch* search, const NeighborhoodSearchTestData& data);
-    void testPairSearch(gmx::AnalysisNeighborhoodSearch* search, const NeighborhoodSearchTestData& data);
-    void testPairSearchIndexed(gmx::AnalysisNeighborhood*        nb,
-                               const NeighborhoodSearchTestData& data,
-                               uint64_t                          seed);
-    void testPairSearchFull(gmx::AnalysisNeighborhoodSearch*          search,
-                            const NeighborhoodSearchTestData&         data,
-                            const gmx::AnalysisNeighborhoodPositions& pos,
-                            const gmx::ListOfLists<int>*              excls,
-                            const gmx::ArrayRef<const int>&           refIndices,
-                            const gmx::ArrayRef<const int>&           testIndices,
-                            bool                                      selfPairs);
+    static void testMinimumDistance(gmx::AnalysisNeighborhoodSearch*  search,
+                                    const NeighborhoodSearchTestData& data);
+    static void testNearestPoint(gmx::AnalysisNeighborhoodSearch*  search,
+                                 const NeighborhoodSearchTestData& data);
+    static void testPairSearch(gmx::AnalysisNeighborhoodSearch*  search,
+                               const NeighborhoodSearchTestData& data);
+    static void testPairSearchIndexed(gmx::AnalysisNeighborhood*        nb,
+                                      const NeighborhoodSearchTestData& data,
+                                      uint64_t                          seed);
+    static void testPairSearchFull(gmx::AnalysisNeighborhoodSearch*          search,
+                                   const NeighborhoodSearchTestData&         data,
+                                   const gmx::AnalysisNeighborhoodPositions& pos,
+                                   const gmx::ListOfLists<int>*              excls,
+                                   const gmx::ArrayRef<const int>&           refIndices,
+                                   const gmx::ArrayRef<const int>&           testIndices,
+                                   bool                                      selfPairs);
 
     gmx::AnalysisNeighborhood nb_;
 };
index 63698881e2290dbf62955e97354f90ad04a4ce06..9748909eb1e31ff202b75071062dc5776989e656 100644 (file)
@@ -123,8 +123,11 @@ private:
 
     typedef std::vector<PositionTest> PositionTestList;
 
-    void setTopologyIfRequired();
-    void checkPositions(gmx::test::TestReferenceChecker* checker, const char* name, gmx_ana_pos_t* p, bool bCoordinates);
+    void        setTopologyIfRequired();
+    static void checkPositions(gmx::test::TestReferenceChecker* checker,
+                               const char*                      name,
+                               gmx_ana_pos_t*                   p,
+                               bool                             bCoordinates);
 
     std::vector<gmx_ana_poscalc_t*> pcList_;
     PositionTestList                posList_;
index f5e9f74e3855324a2bb72bfdd8a0ed8688a3ed85..20d7b916dbdf47b26b305a2806a8b3d355de9db4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2017,2018,2019,2020, 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.
@@ -149,11 +149,11 @@ public:
      *        to avoid altering any value the user has set on the command line; since
      *        it's a static member, changing it would have permanent effect.
      */
-    std::vector<real> generateTestPoints(Range range, std::size_t points);
+    static std::vector<real> generateTestPoints(Range range, std::size_t points);
 
     /*! \brief Test routine for the test point vector generation
      */
-    void generateTestPointsTest();
+    static void generateTestPointsTest();
 };
 
 /*! \brief Test approximate equality of SIMD vs reference version of a function.
index 920966ebd01987a875452435898be88b7b08b9a9..20aa4bd3e99024e54603b42a348bcb6d1ac95be7 100644 (file)
@@ -1031,8 +1031,8 @@ static void fill_table(t_tabledata* td, int tp, const interaction_const_t* ic, g
             case etabLJ12Encad:
                 if (r < rc)
                 {
-                    Vtab = -(r6 - 6.0 * (rc - r) * rc6 / rc - rc6);
-                    Ftab = -(6.0 * r6 / r - 6.0 * rc6 / rc);
+                    Vtab = -(r12 - 12.0 * (rc - r) * rc12 / rc - rc12);
+                    Ftab = -(12.0 * r12 / r - 12.0 * rc12 / rc);
                 }
                 else /* r>rc */
                 {
index 7e661e21668ca91f6f6d6dda19f28ef5bc52f7de..f709f24e4067e0a6813bc36bb9266ec03a297f0d 100644 (file)
@@ -159,19 +159,19 @@ public:
      * \throws   std::bad_alloc          If out of memory.
      *           InconsistentInputError  If user and/or detected inputs are inconsistent.
      */
-    GpuTaskAssignments build(const std::vector<int>&         gpuIdsToUse,
-                             const std::vector<int>&         userGpuTaskAssignment,
-                             const gmx_hw_info_t&            hardwareInfo,
-                             MPI_Comm                        gromacsWorldComm,
-                             const PhysicalNodeCommunicator& physicalNodeComm,
-                             TaskTarget                      nonbondedTarget,
-                             TaskTarget                      pmeTarget,
-                             TaskTarget                      bondedTarget,
-                             TaskTarget                      updateTarget,
-                             bool                            useGpuForNonbonded,
-                             bool                            useGpuForPme,
-                             bool                            rankHasPpTask,
-                             bool                            rankHasPmeTask);
+    static GpuTaskAssignments build(const std::vector<int>&         gpuIdsToUse,
+                                    const std::vector<int>&         userGpuTaskAssignment,
+                                    const gmx_hw_info_t&            hardwareInfo,
+                                    MPI_Comm                        gromacsWorldComm,
+                                    const PhysicalNodeCommunicator& physicalNodeComm,
+                                    TaskTarget                      nonbondedTarget,
+                                    TaskTarget                      pmeTarget,
+                                    TaskTarget                      bondedTarget,
+                                    TaskTarget                      updateTarget,
+                                    bool                            useGpuForNonbonded,
+                                    bool                            useGpuForPme,
+                                    bool                            rankHasPpTask,
+                                    bool                            rankHasPmeTask);
 };
 
 /*! \libinternal
index e6ddbce86a2b345a5b563249cc20efba8ea0f590..ad7a15459c53303224f196eb201e3b8ab7b14063 100644 (file)
@@ -120,9 +120,7 @@ static void fill_ft_ind(int nft, const int* ft, const t_idef* idef, int ft_ind[]
                         sprintf(buf, "RB-A1=%.2f", idef->iparams[i].rbdihs.rbcA[1]);
                         break;
                     case F_RESTRANGLES:
-                        sprintf(buf, "Theta=%.1f_%.2f", idef->iparams[i].harmonic.rA,
-                                idef->iparams[i].harmonic.krA);
-                        break;
+                        // Fall through intended
                     case F_RESTRDIHS:
                         sprintf(buf, "Theta=%.1f_%.2f", idef->iparams[i].harmonic.rA,
                                 idef->iparams[i].harmonic.krA);
index 05982fa110c25ce7c3892a3adbc291ec83cdd699..26f07d25bbc0e38ea758053faea9c767720ec375 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -59,7 +59,7 @@ class DumpTest : public ::testing::Test
 {
 public:
     //! Run test case.
-    void runTest(CommandLine* cmdline);
+    static void runTest(CommandLine* cmdline);
 
 protected:
     // TODO this is changed in newer googletest versions
index 06e289a4a46d4b6a5879589ec370c83fcf9d0ed1..263fa1cbe88be0e3acb6e1cb4ca933f3b369d97b 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -105,7 +105,7 @@ public:
          const SelectionCollection&         selections);
 
     //! Checks whether the given AnalysisData has been initialized.
-    bool isInitialized(const AnalysisData& data) const;
+    static bool isInitialized(const AnalysisData& data);
 
     //! Keeps a data handle for each AnalysisData object.
     HandleContainer handles_;
@@ -130,7 +130,7 @@ TrajectoryAnalysisModuleData::Impl::Impl(TrajectoryAnalysisModule*          modu
     }
 }
 
-bool TrajectoryAnalysisModuleData::Impl::isInitialized(const AnalysisData& data) const
+bool TrajectoryAnalysisModuleData::Impl::isInitialized(const AnalysisData& data)
 {
     for (int i = 0; i < data.dataSetCount(); ++i)
     {
index d53d24143bc020ffc0c4a4980182ad6d78b60a9c..7462f19badb02604ef287afe0524015bc4c2d57e 100644 (file)
@@ -130,7 +130,7 @@ public:
      *
      * Does not throw.
      */
-    Selection parallelSelection(const Selection& selection);
+    static Selection parallelSelection(const Selection& selection);
     /*! \brief
      * Returns a set of selection that corresponds to the given selections.
      *
@@ -140,7 +140,7 @@ public:
      *
      * \see parallelSelection()
      */
-    SelectionList parallelSelections(const SelectionList& selections);
+    static SelectionList parallelSelections(const SelectionList& selections);
 
 protected:
     /*! \brief
index f5ab6c7944e2e8e605e6226b0c8e04186b85c418..d4a8f18c0261f0f3dda03ee1a3b381e04b89abab 100644 (file)
@@ -684,8 +684,8 @@ void calc_vec(int natoms, rvec x[], t_pbc* pbc, rvec xout, rvec cout)
 void Angle::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, TrajectoryAnalysisModuleData* pdata)
 {
     AnalysisDataHandle   dh   = pdata->dataHandle(angles_);
-    const SelectionList& sel1 = pdata->parallelSelections(sel1_);
-    const SelectionList& sel2 = pdata->parallelSelections(sel2_);
+    const SelectionList& sel1 = TrajectoryAnalysisModuleData::parallelSelections(sel1_);
+    const SelectionList& sel2 = TrajectoryAnalysisModuleData::parallelSelections(sel2_);
 
     checkSelections(sel1, sel2);
 
index b23cd8ff27e5a87d7f8926c6b2b6c7457d1405bc..6acf73ab1d2a344614b13634fa0c0ed342b42014 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -324,7 +324,7 @@ void Distance::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, Trajecto
 {
     AnalysisDataHandle   distHandle = pdata->dataHandle(distances_);
     AnalysisDataHandle   xyzHandle  = pdata->dataHandle(xyz_);
-    const SelectionList& sel        = pdata->parallelSelections(sel_);
+    const SelectionList& sel        = TrajectoryAnalysisModuleData::parallelSelections(sel_);
 
     checkSelections(sel);
 
index 3077ea136ffec5d1ad5e5e53541f70f73adc42a1..2597e359ea3306133075e9a7ffbaa7b782a17761 100644 (file)
@@ -303,7 +303,7 @@ void FreeVolume::initAnalysis(const TrajectoryAnalysisSettings& settings, const
 void FreeVolume::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, TrajectoryAnalysisModuleData* pdata)
 {
     AnalysisDataHandle                 dh  = pdata->dataHandle(data_);
-    const Selection&                   sel = pdata->parallelSelection(sel_);
+    const Selection&                   sel = TrajectoryAnalysisModuleData::parallelSelection(sel_);
     gmx::UniformRealDistribution<real> dist;
 
     GMX_RELEASE_ASSERT(nullptr != pbc, "You have no periodic boundary conditions");
index d3f36ff5be66a3b04634c43ee48c488c714e737d..f1d470779a7d743d5a5f15617fbb7bba056cbf71 100644 (file)
@@ -410,8 +410,8 @@ TrajectoryAnalysisModuleDataPointer PairDistance::startFrames(const AnalysisData
 void PairDistance::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, TrajectoryAnalysisModuleData* pdata)
 {
     AnalysisDataHandle      dh         = pdata->dataHandle(distances_);
-    const Selection&        refSel     = pdata->parallelSelection(refSel_);
-    const SelectionList&    sel        = pdata->parallelSelections(sel_);
+    const Selection&        refSel     = TrajectoryAnalysisModuleData::parallelSelection(refSel_);
+    const SelectionList&    sel        = TrajectoryAnalysisModuleData::parallelSelections(sel_);
     PairDistanceModuleData& frameData  = *static_cast<PairDistanceModuleData*>(pdata);
     std::vector<real>&      distArray  = frameData.distArray_;
     std::vector<int>&       countArray = frameData.countArray_;
index 438ba85a8704f783f062b7226fab9403d370f65a..bc088be33f9083172c1da5ab25d694ce18a2793a 100644 (file)
@@ -478,8 +478,8 @@ void Rdf::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, TrajectoryAna
 {
     AnalysisDataHandle   dh        = pdata->dataHandle(pairDist_);
     AnalysisDataHandle   nh        = pdata->dataHandle(normFactors_);
-    const Selection&     refSel    = pdata->parallelSelection(refSel_);
-    const SelectionList& sel       = pdata->parallelSelections(sel_);
+    const Selection&     refSel    = TrajectoryAnalysisModuleData::parallelSelection(refSel_);
+    const SelectionList& sel       = TrajectoryAnalysisModuleData::parallelSelections(sel_);
     RdfModuleData&       frameData = *static_cast<RdfModuleData*>(pdata);
     const bool           bSurface  = !frameData.surfaceDist2_.empty();
 
index 9b581dad9d0a453ebb80d01b21432ddba5beafdc..502f51d07300fce28869d575e297d99cb69741a6 100644 (file)
@@ -116,12 +116,12 @@ struct t_conect
 void add_rec(t_conect c[], int i, int j, real d2)
 {
     if (c[i].aa == -1)
-    {
+    { // NOLINT bugprone-branch-clone
         c[i].aa  = j;
         c[i].d2a = d2;
     }
     else if (c[i].ab == -1)
-    {
+    { // NOLINT bugprone-branch-clone
         c[i].ab  = j;
         c[i].d2b = d2;
     }
@@ -906,8 +906,8 @@ void Sasa::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, TrajectoryAn
     AnalysisDataHandle   aah        = pdata->dataHandle(atomArea_);
     AnalysisDataHandle   rah        = pdata->dataHandle(residueArea_);
     AnalysisDataHandle   vh         = pdata->dataHandle(volume_);
-    const Selection&     surfaceSel = pdata->parallelSelection(surfaceSel_);
-    const SelectionList& outputSel  = pdata->parallelSelections(outputSel_);
+    const Selection&     surfaceSel = TrajectoryAnalysisModuleData::parallelSelection(surfaceSel_);
+    const SelectionList& outputSel  = TrajectoryAnalysisModuleData::parallelSelections(outputSel_);
     SasaModuleData&      frameData  = *static_cast<SasaModuleData*>(pdata);
 
     const bool bResAt    = !frameData.res_a_.empty();
index f3aefd8c4a60863ce6ae73ea24d6e9e81ef131b8..77fec1d469a62519c7d188f265c728308ce54775 100644 (file)
@@ -626,7 +626,7 @@ void Select::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* /* pbc */, Traj
     AnalysisDataHandle   cdh = pdata->dataHandle(cdata_);
     AnalysisDataHandle   idh = pdata->dataHandle(idata_);
     AnalysisDataHandle   mdh = pdata->dataHandle(mdata_);
-    const SelectionList& sel = pdata->parallelSelections(sel_);
+    const SelectionList& sel = TrajectoryAnalysisModuleData::parallelSelections(sel_);
 
     sdh.startFrame(frnr, fr.time);
     for (size_t g = 0; g < sel.size(); ++g)
index 303d5dd7920a045c3369bc72e582172a83879600..1247ea9b8b5aa22f400e03d93a286e9d57712993 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2016,2018,2019,2020, 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.
@@ -253,7 +253,7 @@ void analyzeFrameImpl(int frnr, const t_trxframe& fr, AnalysisDataHandle* dh, co
 void Trajectory::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* /* pbc */, TrajectoryAnalysisModuleData* pdata)
 {
     AnalysisDataHandle   dh  = pdata->dataHandle(xdata_);
-    const SelectionList& sel = pdata->parallelSelections(sel_);
+    const SelectionList& sel = TrajectoryAnalysisModuleData::parallelSelections(sel_);
     analyzeFrameImpl(frnr, fr, &dh, sel, [](const SelectionPosition& pos) { return pos.x(); });
     if (fr.bV)
     {
index 4893c509fe1cda87cf94c9bbc6cc2075aad0a6ae..4773b5c2c8ba886b5271b614b66252cd969c0489 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2015,2017,2018,2019,2020, 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.
@@ -153,7 +153,8 @@ using internal::FileStreamImpl;
  * StandardInputStream
  */
 
-bool StandardInputStream::isInteractive() const
+// static
+bool StandardInputStream::isInteractive()
 {
 #ifdef HAVE_UNISTD_H
     return isatty(fileno(stdin)) != 0;
@@ -167,13 +168,6 @@ bool StandardInputStream::readLine(std::string* line)
     return readLineImpl(stdin, line);
 }
 
-// static
-StandardInputStream& StandardInputStream::instance()
-{
-    static StandardInputStream stdinObject;
-    return stdinObject;
-}
-
 /********************************************************************
  * TextInputFile
  */
index 26c240a6bf8ce1efd1038f68eeac771134e41cc8..5309fb217822938478e17823ab2d83c415584649 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2015,2018,2019,2020, 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.
@@ -78,18 +78,11 @@ public:
      *
      * Does not throw.
      */
-    bool isInteractive() const;
+    static bool isInteractive();
 
     // From TextInputStream
     bool readLine(std::string* line) override;
     void close() override {}
-
-    /*! \brief
-     * Returns a stream for accessing `stdin`.
-     *
-     * Does not throw.
-     */
-    static StandardInputStream& instance();
 };
 
 /*! \libinternal \brief
index 3d5b32abf0eb2d02f5a46ed3aeaf7d2b7c65a27f..2d49c09448ead4caff0eea692aa103a907a4baf0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019,2020, 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.
@@ -275,7 +275,7 @@ private:
         writer_->writeLine(message);
     }
 
-    std::string formatValueForMissingMessage(const KeyValueTreeValue& value)
+    static std::string formatValueForMissingMessage(const KeyValueTreeValue& value)
     {
         if (value.isObject() || value.isArray())
         {
index adb5c9a0babf407c127ef763568b32f74ddbc1f5..bf7fa34c9ce9e37de1233b94b4ee41733500839d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2018,2019,2020, 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.
@@ -203,6 +203,7 @@ template<typename T>
 static inline void gmx_snew_impl(const char* name, const char* file, int line, T*& ptr, size_t nelem)
 {
     static_assert(std::is_pod<T>::value, "snew() called on C++ type");
+    // NOLINTNEXTLINE bugprone-sizeof-expression
     ptr = static_cast<T*>(save_calloc(name, file, line, nelem, sizeof(T)));
 }
 /** C++ helper for srenew(). */
@@ -210,6 +211,7 @@ template<typename T>
 static inline void gmx_srenew_impl(const char* name, const char* file, int line, T*& ptr, size_t nelem)
 {
     static_assert(std::is_pod<T>::value, "srenew() called on C++ type");
+    // NOLINTNEXTLINE bugprone-sizeof-expression
     ptr = static_cast<T*>(save_realloc(name, file, line, ptr, nelem, sizeof(T)));
 }
 /** C++ helper for smalloc(). */
index 06b3d0e23683b8d4fd6fec95df76cb98d89051a6..1a450900033d976408e776d809c68e58547e154e 100644 (file)
@@ -109,13 +109,13 @@ public:
         real           realValue_;
     };
 
-    void serialize(ISerializer* serializer, SerializerValues* values)
+    static void serialize(ISerializer* serializer, SerializerValues* values)
     {
         EXPECT_FALSE(serializer->reading());
         doValues(serializer, values);
     }
 
-    SerializerValues deserialize(ISerializer* serializer)
+    static SerializerValues deserialize(ISerializer* serializer)
     {
         EXPECT_TRUE(serializer->reading());
         SerializerValues result;
@@ -123,7 +123,7 @@ public:
         return result;
     }
 
-    void checkSerializerValuesforEquality(const SerializerValues& lhs, const SerializerValues& rhs)
+    static void checkSerializerValuesforEquality(const SerializerValues& lhs, const SerializerValues& rhs)
     {
         EXPECT_EQ(lhs.boolValue_, rhs.boolValue_);
         EXPECT_EQ(lhs.unsignedCharValue_, rhs.unsignedCharValue_);
@@ -138,7 +138,7 @@ public:
     }
 
 private:
-    void doValues(ISerializer* serializer, SerializerValues* values)
+    static void doValues(ISerializer* serializer, SerializerValues* values)
     {
         serializer->doBool(&values->boolValue_);
         serializer->doUChar(&values->unsignedCharValue_);
index dea592d38f52bd2fe25e5234eaaadcab44273fe9..4d24c608ad301cefa57e7d9bd5ac0b94487b10f2 100644 (file)
@@ -108,7 +108,7 @@ public:
     gmx::KeyValueTreeBuilder builder_;
 
 private:
-    std::vector<char> serializeTree(const gmx::KeyValueTreeObject& tree)
+    static std::vector<char> serializeTree(const gmx::KeyValueTreeObject& tree)
     {
         gmx::InMemorySerializer serializer;
         gmx::serializeKeyValueTree(tree, &serializer);