From: Berk Hess Date: Mon, 17 Sep 2018 07:37:10 +0000 (+0200) Subject: Move ifunc stuff from idef.h to ifunc.h X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=f143ec1ed6d583cd65d85e652b9bca37dee3af9c;p=alexxy%2Fgromacs.git Move ifunc stuff from idef.h to ifunc.h Interaction function definitions were spread over ifunc.h and idef.h. Also changed some macros to constexpr or inline functions. Changed interaction_function.flags to unsigned int. Added ifunc.h to installed headers, as it is now required. Change-Id: I285413f9474866b1fe52e635188763b1c9ee9f95 --- diff --git a/src/gromacs/topology/CMakeLists.txt b/src/gromacs/topology/CMakeLists.txt index e84a9da319..4c08f48425 100644 --- a/src/gromacs/topology/CMakeLists.txt +++ b/src/gromacs/topology/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2014,2015, by the GROMACS development team, led by +# Copyright (c) 2014,2015,2018, 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. @@ -40,6 +40,7 @@ gmx_install_headers( atoms.h block.h idef.h + ifunc.h index.h mtop_util.h symtab.h diff --git a/src/gromacs/topology/idef.h b/src/gromacs/topology/idef.h index f4d4f95614..3ebb53784c 100644 --- a/src/gromacs/topology/idef.h +++ b/src/gromacs/topology/idef.h @@ -43,117 +43,10 @@ #include #include "gromacs/math/vectypes.h" +#include "gromacs/topology/ifunc.h" #include "gromacs/utility/basedefinitions.h" #include "gromacs/utility/real.h" -/* check kernel/toppush.c when you change these numbers */ -#define MAXATOMLIST 6 -#define MAXFORCEPARAM 12 -#define NR_RBDIHS 6 -#define NR_CBTDIHS 6 -#define NR_FOURDIHS 4 - -typedef int t_iatom; - -/* this MUST correspond to the - t_interaction_function[F_NRE] in gmxlib/ifunc.c */ -enum { - F_BONDS, - F_G96BONDS, - F_MORSE, - F_CUBICBONDS, - F_CONNBONDS, - F_HARMONIC, - F_FENEBONDS, - F_TABBONDS, - F_TABBONDSNC, - F_RESTRBONDS, - F_ANGLES, - F_G96ANGLES, - F_RESTRANGLES, - F_LINEAR_ANGLES, - F_CROSS_BOND_BONDS, - F_CROSS_BOND_ANGLES, - F_UREY_BRADLEY, - F_QUARTIC_ANGLES, - F_TABANGLES, - F_PDIHS, - F_RBDIHS, - F_RESTRDIHS, - F_CBTDIHS, - F_FOURDIHS, - F_IDIHS, - F_PIDIHS, - F_TABDIHS, - F_CMAP, - F_GB12_NOLONGERUSED, - F_GB13_NOLONGERUSED, - F_GB14_NOLONGERUSED, - F_GBPOL_NOLONGERUSED, - F_NPSOLVATION_NOLONGERUSED, - F_LJ14, - F_COUL14, - F_LJC14_Q, - F_LJC_PAIRS_NB, - F_LJ, - F_BHAM, - F_LJ_LR_NOLONGERUSED, - F_BHAM_LR_NOLONGERUSED, - F_DISPCORR, - F_COUL_SR, - F_COUL_LR_NOLONGERUSED, - F_RF_EXCL, - F_COUL_RECIP, - F_LJ_RECIP, - F_DPD, - F_POLARIZATION, - F_WATER_POL, - F_THOLE_POL, - F_ANHARM_POL, - F_POSRES, - F_FBPOSRES, - F_DISRES, - F_DISRESVIOL, - F_ORIRES, - F_ORIRESDEV, - F_ANGRES, - F_ANGRESZ, - F_DIHRES, - F_DIHRESVIOL, - F_CONSTR, - F_CONSTRNC, - F_SETTLE, - F_VSITE2, - F_VSITE3, - F_VSITE3FD, - F_VSITE3FAD, - F_VSITE3OUT, - F_VSITE4FD, - F_VSITE4FDN, - F_VSITEN, - F_COM_PULL, - F_EQM, - F_EPOT, - F_EKIN, - F_ETOT, - F_ECONSERVED, - F_TEMP, - F_VTEMP_NOLONGERUSED, - F_PDISPCORR, - F_PRES, - F_DVDL_CONSTR, - F_DVDL, - F_DKDL, - F_DVDL_COUL, - F_DVDL_VDW, - F_DVDL_BONDED, - F_DVDL_RESTRAINT, - F_DVDL_TEMPERATURE, /* not calculated for now, but should just be the energy (NVT) or enthalpy (NPT), or 0 (NVE) */ - F_NRE /* This number is for the total number of energies */ -}; - -#define IS_RESTRAINT_TYPE(ifunc) ((((ifunc) == F_POSRES) || ((ifunc) == F_FBPOSRES) || ((ifunc) == F_DISRES) || ((ifunc) == F_RESTRBONDS) || ((ifunc) == F_DISRESVIOL) || ((ifunc) == F_ORIRES) || ((ifunc) == F_ORIRESDEV) || ((ifunc) == F_ANGRES) || ((ifunc) == F_ANGRESZ) || ((ifunc) == F_DIHRES))) - typedef union t_iparams { /* Some parameters have A and B values for free energy calculations. diff --git a/src/gromacs/topology/ifunc.h b/src/gromacs/topology/ifunc.h index cb8c431786..69a0a6db9d 100644 --- a/src/gromacs/topology/ifunc.h +++ b/src/gromacs/topology/ifunc.h @@ -37,13 +37,17 @@ #ifndef GMX_TOPOLOGY_IFUNC_H #define GMX_TOPOLOGY_IFUNC_H -#include "gromacs/topology/idef.h" +#include "gromacs/math/vectypes.h" struct t_fcdata; struct t_graph; +union t_iparams; struct t_mdatoms; struct t_pbc; +/* TODO: Remove this typedef when t_ilist is removed */ +typedef int t_iatom; + /* Real vector type with an additional, unused 4th element. * This type is used to allow aligned 4-wide SIMD loads and stores. */ @@ -71,15 +75,15 @@ typedef real t_ifunc (int nbonds, const t_iatom iatoms[], * ddgatindex is NULL when domain decomposition is not used. */ -#define IF_NULL 0 -#define IF_BOND 1 -#define IF_VSITE 1<<1 -#define IF_CONSTRAINT 1<<2 -#define IF_CHEMBOND 1<<3 -#define IF_BTYPE 1<<4 -#define IF_ATYPE 1<<5 -#define IF_TABULATED 1<<6 -#define IF_LIMZERO 1<<7 +constexpr unsigned int IF_NULL = 0; +constexpr unsigned int IF_BOND = 1 << 0; +constexpr unsigned int IF_VSITE = 1 << 1; +constexpr unsigned int IF_CONSTRAINT = 1 << 2; +constexpr unsigned int IF_CHEMBOND = 1 << 3; +constexpr unsigned int IF_BTYPE = 1 << 4; +constexpr unsigned int IF_ATYPE = 1 << 5; +constexpr unsigned int IF_TABULATED = 1 << 6; +constexpr unsigned int IF_LIMZERO = 1 << 7; /* These flags tell to some of the routines what can be done with this * item in the list. * With IF_BOND a bonded interaction will be calculated. @@ -91,7 +95,8 @@ typedef real t_ifunc (int nbonds, const t_iatom iatoms[], * it not assigned to any node by the domain decompostion, the simulation * still continue, if mdrun has been told so. */ -typedef struct // NOLINT (clang-analyzer-optin.performance.Padding) + +struct t_interaction_function // NOLINT (clang-analyzer-optin.performance.Padding) { const char *name; /* the name of this function */ const char *longname; /* The name for printing etc. */ @@ -100,10 +105,10 @@ typedef struct // NOLINT (clang-analyzer-optin.performance.Paddin /* this corresponds to the number of params in */ /* iparams struct! (see idef.h) */ /* A and B are for normal and free energy components respectively. */ - unsigned long flags; /* Flags (see above) */ + unsigned int flags; /* Flags (see above) */ int nrnb_ind; /* index for nrnb (-1 if unknown) */ t_ifunc *ifunc; /* the function it self */ -} t_interaction_function; +}; #define NRFPA(ftype) (interaction_function[(ftype)].nrfpA) #define NRFPB(ftype) (interaction_function[(ftype)].nrfpB) @@ -121,6 +126,122 @@ typedef struct // NOLINT (clang-analyzer-optin.performance.Paddin #define IS_TABULATED(ftype) (interaction_function[(ftype)].flags & IF_TABULATED) +/* this MUST correspond to the + t_interaction_function[F_NRE] in gmxlib/ifunc.c */ +enum +{ + F_BONDS, + F_G96BONDS, + F_MORSE, + F_CUBICBONDS, + F_CONNBONDS, + F_HARMONIC, + F_FENEBONDS, + F_TABBONDS, + F_TABBONDSNC, + F_RESTRBONDS, + F_ANGLES, + F_G96ANGLES, + F_RESTRANGLES, + F_LINEAR_ANGLES, + F_CROSS_BOND_BONDS, + F_CROSS_BOND_ANGLES, + F_UREY_BRADLEY, + F_QUARTIC_ANGLES, + F_TABANGLES, + F_PDIHS, + F_RBDIHS, + F_RESTRDIHS, + F_CBTDIHS, + F_FOURDIHS, + F_IDIHS, + F_PIDIHS, + F_TABDIHS, + F_CMAP, + F_GB12_NOLONGERUSED, + F_GB13_NOLONGERUSED, + F_GB14_NOLONGERUSED, + F_GBPOL_NOLONGERUSED, + F_NPSOLVATION_NOLONGERUSED, + F_LJ14, + F_COUL14, + F_LJC14_Q, + F_LJC_PAIRS_NB, + F_LJ, + F_BHAM, + F_LJ_LR_NOLONGERUSED, + F_BHAM_LR_NOLONGERUSED, + F_DISPCORR, + F_COUL_SR, + F_COUL_LR_NOLONGERUSED, + F_RF_EXCL, + F_COUL_RECIP, + F_LJ_RECIP, + F_DPD, + F_POLARIZATION, + F_WATER_POL, + F_THOLE_POL, + F_ANHARM_POL, + F_POSRES, + F_FBPOSRES, + F_DISRES, + F_DISRESVIOL, + F_ORIRES, + F_ORIRESDEV, + F_ANGRES, + F_ANGRESZ, + F_DIHRES, + F_DIHRESVIOL, + F_CONSTR, + F_CONSTRNC, + F_SETTLE, + F_VSITE2, + F_VSITE3, + F_VSITE3FD, + F_VSITE3FAD, + F_VSITE3OUT, + F_VSITE4FD, + F_VSITE4FDN, + F_VSITEN, + F_COM_PULL, + F_EQM, + F_EPOT, + F_EKIN, + F_ETOT, + F_ECONSERVED, + F_TEMP, + F_VTEMP_NOLONGERUSED, + F_PDISPCORR, + F_PRES, + F_DVDL_CONSTR, + F_DVDL, + F_DKDL, + F_DVDL_COUL, + F_DVDL_VDW, + F_DVDL_BONDED, + F_DVDL_RESTRAINT, + F_DVDL_TEMPERATURE, /* not calculated for now, but should just be the energy (NVT) or enthalpy (NPT), or 0 (NVE) */ + F_NRE /* This number is for the total number of energies */ +}; + +static inline bool IS_RESTRAINT_TYPE(int ifunc) +{ + return + ifunc == F_POSRES || ifunc == F_FBPOSRES || + ifunc == F_DISRES || ifunc == F_RESTRBONDS || ifunc == F_DISRESVIOL || + ifunc == F_ORIRES || ifunc == F_ORIRESDEV || + ifunc == F_ANGRES || ifunc == F_ANGRESZ || ifunc == F_DIHRES; +} + +/* Maximum allowed number of atoms, parameters and terms in interaction_function. + * Check kernel/toppush.c when you change these numbers. + */ +constexpr int MAXATOMLIST = 6; +constexpr int MAXFORCEPARAM = 12; +constexpr int NR_RBDIHS = 6; +constexpr int NR_CBTDIHS = 6; +constexpr int NR_FOURDIHS = 4; + extern const t_interaction_function interaction_function[F_NRE]; /* initialised interaction functions descriptor */