# 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,
-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
* 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.
* \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.
*
void AnalysisDataModuleManager::Impl::checkModuleProperty(const IAnalysisDataModule& module,
DataProperty property,
- bool bSet) const
+ bool bSet)
{
bool bOk = true;
const int flags = module.flags();
//! 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
{
//! 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(); }
/*
* 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.
assignOptionsFromKeyValueTree(&densityFittingModuleOptions, transformedMdpValues.object(), nullptr);
}
- KeyValueTreeObject densityFittingSetActiveAsMdpValues()
+ static KeyValueTreeObject densityFittingSetActiveAsMdpValues()
{
// Prepare MDP inputs
KeyValueTreeBuilder mdpValueBuilder;
/*
* 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.
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();
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;
}
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.
* 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.
* \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_;
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'))
/*
* 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.
}
}
-bool SetAtoms::haveFrameAtoms(const t_trxframe& input) const
+bool SetAtoms::haveFrameAtoms(const t_trxframe& input)
{
return input.bAtoms;
}
/*
* 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.
*
* \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
{
/*
* 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.
* \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();
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;
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.");
}
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.");
}
/*!\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;
}
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.");
}
/*!\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.");
}
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.");
}
/*!\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.");
}
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.");
}
/*!\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.");
}
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.");
}
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;
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;
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;
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)
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_; }
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
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;
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;
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
if (file_version >= 79)
{
serializer->doBool(&ir->bExpanded);
- if (ir->bExpanded)
- {
- ir->bExpanded = TRUE;
- }
- else
- {
- ir->bExpanded = FALSE;
- }
}
if (ir->bExpanded)
{
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.
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++;
}
{
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;
}
|| (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 */
mult = 3;
maxang = 180.0;
break;
- case 'd': break;
+ case 'd': // Intended fall through
case 'i': break;
case 'r': bRb = TRUE; break;
}
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;
}
{
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;
}
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 */
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;
}
{
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;
}
}
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;
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)
{
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;
}
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;
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;
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;
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;
DeviceStream::~DeviceStream() = default;
+// NOLINTNEXTLINE readability-convert-member-functions-to-static
bool DeviceStream::isValid() const
{
return false;
/*
* 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.
//! 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:
{ "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)
bool GpuBonded::haveInteractions() const
{
- return false;
+ return !impl_;
}
void GpuBonded::launchKernel(const t_forcerec* /* fr */,
/*
* 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.
}
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.");
/*
* 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.
//! 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
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;
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;
* \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.
*
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
{
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);
}
* \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
* \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++)
* \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 });
* \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 });
* \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++)
{
/*
* 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.
* \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++)
{
* \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)
{
* \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)
{
}
//! 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());
GpuEventSynchronizer* /* xUpdatedOnDevice */) :
impl_(nullptr)
{
- GMX_ASSERT(false,
+ GMX_ASSERT(!impl_,
"A CPU stub for UpdateConstrain was called instead of the correct implementation.");
}
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.");
}
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;
}
{
AtomIndexExtremes extremes = vsiteConstructRange(lastAtom + 1, moltype);
if (extremes.minAtom < firstAtom)
- {
+ { // NOLINT bugprone-branch-clone
/* Constructing atom precedes the group */
return 0;
}
}
}
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++)
{
{
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)
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)
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)
{
{
if (ir->nstcalcenergy > 0)
{
- energyOutput.printAnnealingTemperatures(fplog, groups, &(ir->opts));
+ gmx::EnergyOutput::printAnnealingTemperatures(fplog, groups, &(ir->opts));
energyOutput.printAverages(fplog, groups);
}
}
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;
if (MASTER(cr))
{
- mimicCommunicator.getCoords(&state_global->x, state_global->natoms);
+ MimicCommunicator::getCoords(&state_global->x, state_global->natoms);
}
if (ir->efep != efepNO)
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)
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);
}
}
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);
if (MASTER(cr))
{
- mimicCommunicator.finalize();
+ MimicCommunicator::finalize();
}
if (!thisRankHasDuty(cr, DUTY_PME))
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);
}
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);
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)
{
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);
}
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);
*/
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 */
{
if (MASTER(cr))
{
- energyOutput.printHeader(fplog, count, count);
+ EnergyOutput::printHeader(fplog, count, count);
}
if (count == 0)
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)
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);
}
// 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),
/*
* 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.
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)
{
/*
* 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.
expectAffinitySet(core);
}
}
+ // NOLINTNEXTLINE readability-convert-member-functions-to-static
void expectAffinitySetThatFails(int core)
{
using ::testing::Return;
bool integratorHasConservedEnergyQuantity(const t_inputrec* ir)
{
if (!EI_MD(ir->eI))
- {
+ { // NOLINT bugprone-branch-clone
// Energy minimization or stochastic integrator: no conservation
return false;
}
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);
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);
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 {};
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;
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;
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.");
}
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.");
}
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 {};
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;
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.");
}
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 {};
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.");
}
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;
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;
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.");
}
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;
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;
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;
/*
* 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.
{
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)
/*
* 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.
/*! \brief
* Initializes the communicator
*/
- void init();
+ static void init();
/*! \brief
* Sends the data needed for MiMiC initialization
* @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
* @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
* @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
/*
* 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.
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
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())
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));
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)
{
protected:
PullTest() {}
- void test(PbcType pbcType, matrix box)
+ static void test(PbcType pbcType, matrix box)
{
t_pbc pbc;
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.");
/*
* 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.
~RestraintMDModuleImpl();
- /*!
- * \brief Unused implementation of IMDModule aspect
- */
- IMdpOptionProvider* mdpOptionProvider();
-
- /*!
- * \brief Unused implementation of IMDModule aspect
- */
- IMDOutputProvider* outputProvider();
-
/*!
* \brief Implement IMDModule interface.
*
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_*().
* 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;
/*
* 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.
* \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.
*
*
* \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
* 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_;
* \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_;
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;
* 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.
}
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;
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;
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())
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);
}
printTree(stderr, false);
}
- SelectionCompiler compiler;
- compiler.compile(this);
+ compileSelection(this);
if (impl_->debugLevel_ != Impl::DebugLevel::None)
{
/*! \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.
*/
/*! \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
/*
* 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.
void promptSelections()
{
- const bool isInteractive = StandardInputStream::instance().isInteractive();
+ const bool isInteractive = StandardInputStream::isInteractive();
initIndexGroups();
manager_.parseRequestedFromStdin(isInteractive);
doneIndexGroups();
/*! \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.
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("* ");
}
}
-void KeywordsHelpTopic::writeKeywordListEnd(const HelpWriterContext& context, const char* extraInfo) const
+void KeywordsHelpTopic::writeKeywordListEnd(const HelpWriterContext& context, const char* extraInfo)
{
if (context.outputFormat() == eHelpOutputFormat_Rst)
{
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
{
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;
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_;
};
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_;
/*
* 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.
* 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.
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 */
{
* \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
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);
/*
* 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.
{
public:
//! Run test case.
- void runTest(CommandLine* cmdline);
+ static void runTest(CommandLine* cmdline);
protected:
// TODO this is changed in newer googletest versions
* 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.
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_;
}
}
-bool TrajectoryAnalysisModuleData::Impl::isInitialized(const AnalysisData& data) const
+bool TrajectoryAnalysisModuleData::Impl::isInitialized(const AnalysisData& data)
{
for (int i = 0; i < data.dataSetCount(); ++i)
{
*
* 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.
*
*
* \see parallelSelection()
*/
- SelectionList parallelSelections(const SelectionList& selections);
+ static SelectionList parallelSelections(const SelectionList& selections);
protected:
/*! \brief
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);
* 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.
{
AnalysisDataHandle distHandle = pdata->dataHandle(distances_);
AnalysisDataHandle xyzHandle = pdata->dataHandle(xyz_);
- const SelectionList& sel = pdata->parallelSelections(sel_);
+ const SelectionList& sel = TrajectoryAnalysisModuleData::parallelSelections(sel_);
checkSelections(sel);
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");
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_;
{
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();
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;
}
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();
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)
/*
* 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.
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)
{
/*
* 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.
* StandardInputStream
*/
-bool StandardInputStream::isInteractive() const
+// static
+bool StandardInputStream::isInteractive()
{
#ifdef HAVE_UNISTD_H
return isatty(fileno(stdin)) != 0;
return readLineImpl(stdin, line);
}
-// static
-StandardInputStream& StandardInputStream::instance()
-{
- static StandardInputStream stdinObject;
- return stdinObject;
-}
-
/********************************************************************
* TextInputFile
*/
/*
* 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.
*
* 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
/*
* 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.
writer_->writeLine(message);
}
- std::string formatValueForMissingMessage(const KeyValueTreeValue& value)
+ static std::string formatValueForMissingMessage(const KeyValueTreeValue& value)
{
if (value.isObject() || value.isArray())
{
*
* 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.
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(). */
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(). */
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;
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_);
}
private:
- void doValues(ISerializer* serializer, SerializerValues* values)
+ static void doValues(ISerializer* serializer, SerializerValues* values)
{
serializer->doBool(&values->boolValue_);
serializer->doUChar(&values->unsignedCharValue_);
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);