using namespace gmx; // TODO: Remove when this file is moved into gmx namespace
-const char* const c_ljcrNames[ljcrNR + 1] = { "none", "geometric", "Lorentz-Berthelot", nullptr };
+
+const char* enumValueToString(LJCombinationRule enumValue)
+{
+ static constexpr gmx::EnumerationArray<LJCombinationRule, const char*> s_ljCombinationRuleNames = {
+ "Geometric", "Lorentz-Berthelot", "None"
+ };
+ return s_ljCombinationRuleNames[enumValue];
+}
void nbnxn_atomdata_t::resizeCoordinateBuffer(int numAtoms)
{
* not per pair of atom types.
*/
params->nbfp_comb.resize(nt * 2);
- switch (params->comb_rule)
+ switch (params->ljCombinationRule)
{
- case ljcrGEOM:
- params->comb_rule = ljcrGEOM;
-
+ case LJCombinationRule::Geometric:
for (int i = 0; i < nt; i++)
{
/* Store the sqrt of the diagonal from the nbfp matrix */
params->nbfp_comb[i * 2 + 1] = std::sqrt(params->nbfp[(i * nt + i) * 2 + 1]);
}
break;
- case ljcrLB:
+ case LJCombinationRule::LorentzBerthelot:
for (int i = 0; i < nt; i++)
{
/* Get 6*C6 and 12*C12 from the diagonal of the nbfp matrix */
}
}
break;
- case ljcrNONE:
+ case LJCombinationRule::None:
/* We always store the full matrix (see code above) */
break;
default: gmx_incons("Unknown combination rule");
*/
if (bCombGeom)
{
- params->comb_rule = ljcrGEOM;
+ params->ljCombinationRule = LJCombinationRule::Geometric;
}
else if (bCombLB)
{
- params->comb_rule = ljcrLB;
+ params->ljCombinationRule = LJCombinationRule::LorentzBerthelot;
}
else
{
- params->comb_rule = ljcrNONE;
+ params->ljCombinationRule = LJCombinationRule::None;
params->nbfp_comb.clear();
}
{
std::string mesg;
- if (params->comb_rule == ljcrNONE)
+ if (params->ljCombinationRule == LJCombinationRule::None)
{
mesg = "Using full Lennard-Jones parameter combination matrix";
}
else
{
mesg = gmx::formatString("Using %s Lennard-Jones combination rule",
- enum_name(params->comb_rule, ljcrNR, c_ljcrNames));
+ enumValueToString(params->ljCombinationRule));
}
GMX_LOG(mdlog.info).asParagraph().appendText(mesg);
}
break;
- case enbnxninitcombruleGEOM: params->comb_rule = ljcrGEOM; break;
- case enbnxninitcombruleLB: params->comb_rule = ljcrLB; break;
+ case enbnxninitcombruleGEOM:
+ params->ljCombinationRule = LJCombinationRule::Geometric;
+ break;
+ case enbnxninitcombruleLB:
+ params->ljCombinationRule = LJCombinationRule::LorentzBerthelot;
+ break;
case enbnxninitcombruleNONE:
- params->comb_rule = ljcrNONE;
+ params->ljCombinationRule = LJCombinationRule::None;
params->nbfp_comb.clear();
break;
{
params->lj_comb.resize(gridSet.numGridAtomsTotal() * 2);
- if (params->comb_rule != ljcrNONE)
+ if (params->ljCombinationRule != LJCombinationRule::None)
{
for (const Nbnxm::Grid& grid : gridSet.grids())
{
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2012,2013,2014,2015,2016 by the GROMACS development team.
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#define NBNXN_BUFFERFLAG_MAX_THREADS (BITMASK_SIZE)
-/*! \brief LJ combination rules: geometric, Lorentz-Berthelot, none */
-enum
+//! LJ combination rules
+enum class LJCombinationRule : int
{
- ljcrGEOM,
- ljcrLB,
- ljcrNONE,
- ljcrNR
+ //! Geometric
+ Geometric,
+ //! Lorentz-Berthelot
+ LorentzBerthelot,
+ //! No rule
+ None,
+ //! Size of the enum
+ Count
};
//! String corresponding to LJ combination rule
-extern const char* const c_ljcrNames[ljcrNR + 1];
+const char* enumValueToString(LJCombinationRule enumValue);
/*! \internal
* \brief Struct that stores atom related data for the nbnxn module
//! Lennard-Jone 6*C6 and 12*C12 parameters, size numTypes*2*2
gmx::HostVector<real> nbfp;
//! Combination rule, see enum defined above
- int comb_rule;
+ LJCombinationRule ljCombinationRule;
//! LJ parameters per atom type, size numTypes*2
gmx::HostVector<real> nbfp_comb;
//! As nbfp, but with a stride for the present SIMD architecture
* combination is rarely used. LJ force-switch with LB rule is more common,
* but gives only 1% speed-up.
*/
- nbp->vdwType = nbnxmGpuPickVdwKernelType(ic, nbatParams.comb_rule);
+ nbp->vdwType = nbnxmGpuPickVdwKernelType(ic, nbatParams.ljCombinationRule);
nbp->elecType = nbnxmGpuPickElectrostaticsKernelType(ic, deviceContext.deviceInfo());
/* generate table for PME */
/** Return the enum value of VdW kernel type for given \p ic and \p combRule. */
GPU_FUNC_QUALIFIER
-enum VdwType nbnxmGpuPickVdwKernelType(const interaction_const_t gmx_unused* ic, int gmx_unused combRule)
+enum VdwType nbnxmGpuPickVdwKernelType(const interaction_const_t gmx_unused* ic,
+ LJCombinationRule gmx_unused ljCombinationRule)
GPU_FUNC_TERM_WITH_RETURN(VdwType::Count);
/** Returns an opaque pointer to the GPU command stream
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2012,2013,2014,2015,2016 by the GROMACS development team.
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
{
case eintmodNONE:
case eintmodPOTSHIFT:
- switch (nbatParams.comb_rule)
+ switch (nbatParams.ljCombinationRule)
{
- case ljcrGEOM: vdwkt = vdwktLJCUT_COMBGEOM; break;
- case ljcrLB: vdwkt = vdwktLJCUT_COMBLB; break;
- case ljcrNONE: vdwkt = vdwktLJCUT_COMBNONE; break;
+ case LJCombinationRule::Geometric: vdwkt = vdwktLJCUT_COMBGEOM; break;
+ case LJCombinationRule::LorentzBerthelot: vdwkt = vdwktLJCUT_COMBLB; break;
+ case LJCombinationRule::None: vdwkt = vdwktLJCUT_COMBNONE; break;
default: GMX_RELEASE_ASSERT(false, "Unknown combination rule");
}
break;
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2012,2013,2014,2015,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
struct NbnxmGpu;
struct gmx_wallcycle;
struct interaction_const_t;
+enum class LJCombinationRule;
struct nbnxn_atomdata_t;
struct nonbonded_verlet_t;
class PairSearch;
}
-enum VdwType nbnxmGpuPickVdwKernelType(const interaction_const_t* ic, int combRule)
+enum VdwType nbnxmGpuPickVdwKernelType(const interaction_const_t* ic, LJCombinationRule ljCombinationRule)
{
if (ic->vdwtype == evdwCUT)
{
{
case eintmodNONE:
case eintmodPOTSHIFT:
- switch (combRule)
+ switch (ljCombinationRule)
{
- case ljcrNONE: return VdwType::Cut;
- case ljcrGEOM: return VdwType::CutCombGeom;
- case ljcrLB: return VdwType::CutCombLB;
+ case LJCombinationRule::None: return VdwType::Cut;
+ case LJCombinationRule::Geometric: return VdwType::CutCombGeom;
+ case LJCombinationRule::LorentzBerthelot: return VdwType::CutCombLB;
default:
GMX_THROW(gmx::InconsistentInputError(gmx::formatString(
- "The requested LJ combination rule %s (%d) is not implemented in "
+ "The requested LJ combination rule %s is not implemented in "
"the GPU accelerated kernels!",
- enum_name(combRule, ljcrNR, c_ljcrNames),
- combRule)));
+ enumValueToString(ljCombinationRule))));
}
case eintmodFORCESWITCH: return VdwType::FSwitch;
case eintmodPOTSWITCH: return VdwType::PSwitch;
}
else if (ic->vdwtype == evdwPME)
{
- if (ic->ljpme_comb_rule == ljcrGEOM)
+ if (ic->ljpme_comb_rule == eljpmeGEOM)
{
- assert(combRule == ljcrGEOM);
+ assert(ljCombinationRule == LJCombinationRule::Geometric);
return VdwType::EwaldGeom;
}
else
{
- assert(combRule == ljcrLB);
+ assert(ljCombinationRule == LJCombinationRule::LorentzBerthelot);
return VdwType::EwaldLB;
}
}
{
set_cutoff_parameters(nbp, ic, listParams);
- nbp->vdwType = nbnxmGpuPickVdwKernelType(ic, nbatParams.comb_rule);
+ nbp->vdwType = nbnxmGpuPickVdwKernelType(ic, nbatParams.ljCombinationRule);
nbp->elecType = nbnxmGpuPickElectrostaticsKernelType(ic, deviceContext.deviceInfo());
if (ic->vdwtype == evdwPME)
{
- if (ic->ljpme_comb_rule == ljcrGEOM)
+ if (ic->ljpme_comb_rule == eljpmeGEOM)
{
- GMX_ASSERT(nbatParams.comb_rule == ljcrGEOM, "Combination rule mismatch!");
+ GMX_ASSERT(nbatParams.ljCombinationRule == LJCombinationRule::Geometric,
+ "Combination rule mismatch!");
}
else
{
- GMX_ASSERT(nbatParams.comb_rule == ljcrLB, "Combination rule mismatch!");
+ GMX_ASSERT(nbatParams.ljCombinationRule == LJCombinationRule::LorentzBerthelot,
+ "Combination rule mismatch!");
}
}
/* generate table for PME */