From 0242703c9a11b84b0b07b2eca76d59d00b399cea Mon Sep 17 00:00:00 2001 From: Paul Bauer Date: Tue, 12 Mar 2019 12:17:11 +0100 Subject: [PATCH] Refactor t_pindex Also change naming of containers for interaction types to better reflect what is actually stored in the container. Refs #2833 Change-Id: I581fb2a436528c00770b98ba6e5d45af7c7d9a0c --- src/gromacs/gmxpreprocess/add_par.cpp | 36 ++-- src/gromacs/gmxpreprocess/add_par.h | 20 +-- src/gromacs/gmxpreprocess/convparm.cpp | 22 +-- src/gromacs/gmxpreprocess/convparm.h | 12 +- src/gromacs/gmxpreprocess/gen_ad.cpp | 76 ++++---- src/gromacs/gmxpreprocess/gen_ad.h | 4 +- src/gromacs/gmxpreprocess/gen_vsite.cpp | 26 +-- src/gromacs/gmxpreprocess/gen_vsite.h | 6 +- src/gromacs/gmxpreprocess/gpp_atomtype.cpp | 66 +++---- src/gromacs/gmxpreprocess/gpp_atomtype.h | 32 ++-- src/gromacs/gmxpreprocess/gpp_nextnb.cpp | 6 +- src/gromacs/gmxpreprocess/gpp_nextnb.h | 6 +- src/gromacs/gmxpreprocess/grompp.cpp | 80 ++++----- src/gromacs/gmxpreprocess/grompp_impl.h | 26 +-- src/gromacs/gmxpreprocess/nm2type.cpp | 4 +- src/gromacs/gmxpreprocess/nm2type.h | 4 +- src/gromacs/gmxpreprocess/pdb2top.cpp | 14 +- src/gromacs/gmxpreprocess/pdb2top.h | 4 +- src/gromacs/gmxpreprocess/resall.cpp | 2 +- .../gmxpreprocess/tests/gpp_atomtype.cpp | 8 +- src/gromacs/gmxpreprocess/tomorse.cpp | 14 +- src/gromacs/gmxpreprocess/topio.cpp | 50 +++--- src/gromacs/gmxpreprocess/topio.h | 4 +- src/gromacs/gmxpreprocess/toppush.cpp | 170 +++++++++--------- src/gromacs/gmxpreprocess/toppush.h | 26 +-- src/gromacs/gmxpreprocess/topshake.cpp | 14 +- src/gromacs/gmxpreprocess/topshake.h | 4 +- src/gromacs/gmxpreprocess/toputil.cpp | 10 +- src/gromacs/gmxpreprocess/toputil.h | 8 +- src/gromacs/gmxpreprocess/vsite_parm.cpp | 148 ++++++++------- src/gromacs/gmxpreprocess/vsite_parm.h | 6 +- src/gromacs/gmxpreprocess/x2top.cpp | 20 +-- 32 files changed, 478 insertions(+), 450 deletions(-) diff --git a/src/gromacs/gmxpreprocess/add_par.cpp b/src/gromacs/gmxpreprocess/add_par.cpp index 046eecceb5..7d220c1707 100644 --- a/src/gromacs/gmxpreprocess/add_par.cpp +++ b/src/gromacs/gmxpreprocess/add_par.cpp @@ -52,7 +52,7 @@ #include "hackblock.h" -void add_param(InteractionTypeParameters *ps, +void add_param(InteractionsOfType *ps, int ai, int aj, gmx::ArrayRef c, @@ -65,56 +65,56 @@ void add_param(InteractionTypeParameters *ps, std::vector atoms = {ai, aj}; std::vector forceParm(c.begin(), c.end()); - ps->interactionTypes.emplace_back(InteractionType(atoms, forceParm, s ? s : "")); + ps->interactionTypes.emplace_back(InteractionOfType(atoms, forceParm, s ? s : "")); } -void add_imp_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, real c0, real c1, +void add_imp_param(InteractionsOfType *ps, int ai, int aj, int ak, int al, real c0, real c1, const char *s) { std::vector atoms = {ai, aj, ak, al}; std::vector forceParm = {c0, c1}; - ps->interactionTypes.emplace_back(InteractionType(atoms, forceParm, s ? s : "")); + ps->interactionTypes.emplace_back(InteractionOfType(atoms, forceParm, s ? s : "")); } -void add_dih_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, real c0, real c1, +void add_dih_param(InteractionsOfType *ps, int ai, int aj, int ak, int al, real c0, real c1, real c2, const char *s) { std::vector atoms = {ai, aj, ak, al}; std::vector forceParm = {c0, c1, c2}; - ps->interactionTypes.emplace_back(InteractionType(atoms, forceParm, s ? s : "")); + ps->interactionTypes.emplace_back(InteractionOfType(atoms, forceParm, s ? s : "")); } -void add_cmap_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, int am, const char *s) +void add_cmap_param(InteractionsOfType *ps, int ai, int aj, int ak, int al, int am, const char *s) { std::vector atoms = {ai, aj, ak, al, am}; - ps->interactionTypes.emplace_back(InteractionType(atoms, {}, s ? s : "")); + ps->interactionTypes.emplace_back(InteractionOfType(atoms, {}, s ? s : "")); } -void add_vsite2_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak) +void add_vsite2_atoms(InteractionsOfType *ps, int ai, int aj, int ak) { std::vector atoms = {ai, aj, ak}; - ps->interactionTypes.emplace_back(InteractionType(atoms, {})); + ps->interactionTypes.emplace_back(InteractionOfType(atoms, {})); } -void add_vsite2_param(InteractionTypeParameters *ps, int ai, int aj, int ak, real c0) +void add_vsite2_param(InteractionsOfType *ps, int ai, int aj, int ak, real c0) { std::vector atoms = {ai, aj, ak}; std::vector forceParm = {c0}; - ps->interactionTypes.emplace_back(InteractionType(atoms, forceParm)); + ps->interactionTypes.emplace_back(InteractionOfType(atoms, forceParm)); } -void add_vsite3_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, +void add_vsite3_param(InteractionsOfType *ps, int ai, int aj, int ak, int al, real c0, real c1) { std::vector atoms = {ai, aj, ak, al}; std::vector forceParm = {c0, c1}; - ps->interactionTypes.emplace_back(InteractionType(atoms, forceParm)); + ps->interactionTypes.emplace_back(InteractionOfType(atoms, forceParm)); } -void add_vsite3_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, bool bSwapParity) +void add_vsite3_atoms(InteractionsOfType *ps, int ai, int aj, int ak, int al, bool bSwapParity) { std::vector atoms = {ai, aj, ak, al}; - ps->interactionTypes.emplace_back(InteractionType(atoms, {})); + ps->interactionTypes.emplace_back(InteractionOfType(atoms, {})); if (bSwapParity) { @@ -122,10 +122,10 @@ void add_vsite3_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int } } -void add_vsite4_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, int am) +void add_vsite4_atoms(InteractionsOfType *ps, int ai, int aj, int ak, int al, int am) { std::vector atoms = {ai, aj, ak, al, am}; - ps->interactionTypes.emplace_back(InteractionType(atoms, {})); + ps->interactionTypes.emplace_back(InteractionOfType(atoms, {})); } int search_jtype(const PreprocessResidue &localPpResidue, const char *name, bool bNterm) diff --git a/src/gromacs/gmxpreprocess/add_par.h b/src/gromacs/gmxpreprocess/add_par.h index afc517c1be..f26fc891cf 100644 --- a/src/gromacs/gmxpreprocess/add_par.h +++ b/src/gromacs/gmxpreprocess/add_par.h @@ -41,35 +41,35 @@ #include "gromacs/utility/arrayref.h" #include "gromacs/utility/real.h" -struct InteractionTypeParameters; +struct InteractionsOfType; struct PreprocessResidue; -void add_param(InteractionTypeParameters *ps, +void add_param(InteractionsOfType *ps, int ai, int aj, gmx::ArrayRef c, const char *s); -void add_imp_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, +void add_imp_param(InteractionsOfType *ps, int ai, int aj, int ak, int al, real c0, real c1, const char *s); -void add_dih_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, +void add_dih_param(InteractionsOfType *ps, int ai, int aj, int ak, int al, real c0, real c1, real c2, const char *s); -void add_cmap_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, int am, +void add_cmap_param(InteractionsOfType *ps, int ai, int aj, int ak, int al, int am, const char *s); -void add_vsite2_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak); +void add_vsite2_atoms(InteractionsOfType *ps, int ai, int aj, int ak); -void add_vsite3_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, +void add_vsite3_atoms(InteractionsOfType *ps, int ai, int aj, int ak, int al, bool bSwapParity); -void add_vsite2_param(InteractionTypeParameters *ps, int ai, int aj, int ak, real c0); +void add_vsite2_param(InteractionsOfType *ps, int ai, int aj, int ak, real c0); -void add_vsite3_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, +void add_vsite3_param(InteractionsOfType *ps, int ai, int aj, int ak, int al, real c0, real c1); -void add_vsite4_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, +void add_vsite4_atoms(InteractionsOfType *ps, int ai, int aj, int ak, int al, int am); int search_jtype(const PreprocessResidue &localPpResidue, const char *name, bool bFirstRes); diff --git a/src/gromacs/gmxpreprocess/convparm.cpp b/src/gromacs/gmxpreprocess/convparm.cpp index f3e6fb9c56..16c77479cd 100644 --- a/src/gromacs/gmxpreprocess/convparm.cpp +++ b/src/gromacs/gmxpreprocess/convparm.cpp @@ -496,7 +496,7 @@ static void append_interaction(InteractionList *ilist, } } -static void enter_function(const InteractionTypeParameters *p, t_functype ftype, int comb, real reppow, +static void enter_function(const InteractionsOfType *p, t_functype ftype, int comb, real reppow, gmx_ffparams_t *ffparams, InteractionList *il, bool bNB, bool bAppend) { @@ -515,11 +515,11 @@ static void enter_function(const InteractionTypeParameters *p, t_functype ftype, } } -void convertInteractionTypeParameters(int atnr, gmx::ArrayRef nbtypes, - gmx::ArrayRef mi, - const MoleculeInformation *intermolecular_interactions, - int comb, double reppow, real fudgeQQ, - gmx_mtop_t *mtop) +void convertInteractionsOfType(int atnr, gmx::ArrayRef nbtypes, + gmx::ArrayRef mi, + const MoleculeInformation *intermolecular_interactions, + int comb, double reppow, real fudgeQQ, + gmx_mtop_t *mtop) { int i; unsigned long flags; @@ -544,14 +544,14 @@ void convertInteractionTypeParameters(int atnr, gmx::ArrayRefilist[i].iatoms.clear(); - gmx::ArrayRef plist = mi[mt].plist; + gmx::ArrayRef interactions = mi[mt].interactions; flags = interaction_function[i].flags; if ((i != F_LJ) && (i != F_BHAM) && ((flags & IF_BOND) || (flags & IF_VSITE) || (flags & IF_CONSTRAINT))) { - enter_function(&(plist[i]), static_cast(i), comb, reppow, + enter_function(&(interactions[i]), static_cast(i), comb, reppow, ffp, &molt->ilist[i], FALSE, (i == F_POSRES || i == F_FBPOSRES)); } @@ -568,9 +568,9 @@ void convertInteractionTypeParameters(int atnr, gmx::ArrayRefintermolecular_ilist)[i].iatoms.clear(); - gmx::ArrayRef plist = intermolecular_interactions->plist; + gmx::ArrayRef interactions = intermolecular_interactions->interactions; - if (!plist[i].interactionTypes.empty()) + if (!interactions[i].interactionTypes.empty()) { flags = interaction_function[i].flags; /* For intermolecular interactions we (currently) @@ -592,7 +592,7 @@ void convertInteractionTypeParameters(int atnr, gmx::ArrayRef(i), comb, reppow, + enter_function(&(interactions[i]), static_cast(i), comb, reppow, ffp, &(*mtop->intermolecular_ilist)[i], FALSE, FALSE); diff --git a/src/gromacs/gmxpreprocess/convparm.h b/src/gromacs/gmxpreprocess/convparm.h index bcc82b83c5..a245f6f01b 100644 --- a/src/gromacs/gmxpreprocess/convparm.h +++ b/src/gromacs/gmxpreprocess/convparm.h @@ -43,12 +43,12 @@ struct gmx_mtop_t; struct MoleculeInformation; -struct InteractionTypeParameters; +struct InteractionsOfType; -void convertInteractionTypeParameters(int atnr, gmx::ArrayRef nbtypes, - gmx::ArrayRef mi, - const MoleculeInformation *intermolecular_interactions, - int comb, double reppow, real fudgeQQ, - gmx_mtop_t *mtop); +void convertInteractionsOfType(int atnr, gmx::ArrayRef nbtypes, + gmx::ArrayRef mi, + const MoleculeInformation *intermolecular_interactions, + int comb, double reppow, real fudgeQQ, + gmx_mtop_t *mtop); #endif diff --git a/src/gromacs/gmxpreprocess/gen_ad.cpp b/src/gromacs/gmxpreprocess/gen_ad.cpp index 98d5031625..e176622074 100644 --- a/src/gromacs/gmxpreprocess/gen_ad.cpp +++ b/src/gromacs/gmxpreprocess/gen_ad.cpp @@ -64,16 +64,16 @@ #include "resall.h" #define DIHEDRAL_WAS_SET_IN_RTP 0 -static bool was_dihedral_set_in_rtp(const InteractionType &dih) +static bool was_dihedral_set_in_rtp(const InteractionOfType &dih) { // This is a bad way to check this, but I don't know how to make this better now. gmx::ArrayRef forceParam = dih.forceParam(); return forceParam[MAXFORCEPARAM-1] == DIHEDRAL_WAS_SET_IN_RTP; } -typedef bool (*peq)(const InteractionType &p1, const InteractionType &p2); +typedef bool (*peq)(const InteractionOfType &p1, const InteractionOfType &p2); -static bool acomp(const InteractionType &a1, const InteractionType &a2) +static bool acomp(const InteractionOfType &a1, const InteractionOfType &a2) { int ac; @@ -91,7 +91,7 @@ static bool acomp(const InteractionType &a1, const InteractionType &a2) } } -static bool pcomp(const InteractionType &a1, const InteractionType &a2) +static bool pcomp(const InteractionOfType &a1, const InteractionOfType &a2) { int pc; @@ -105,7 +105,7 @@ static bool pcomp(const InteractionType &a1, const InteractionType &a2) } } -static bool dcomp(const InteractionType &d1, const InteractionType &d2) +static bool dcomp(const InteractionOfType &d1, const InteractionOfType &d2) { int dc; @@ -150,19 +150,19 @@ static bool dcomp(const InteractionType &d1, const InteractionType &d2) } -static bool is_dihedral_on_same_bond(const InteractionType &p1, const InteractionType &p2) +static bool is_dihedral_on_same_bond(const InteractionOfType &p1, const InteractionOfType &p2) { return ((p1.aj() == p2.aj()) && (p1.ak() == p2.ak())) || ((p1.aj() == p2.ak()) && (p1.ak() == p2.aj())); } -static bool preq(const InteractionType &p1, const InteractionType &p2) +static bool preq(const InteractionOfType &p1, const InteractionOfType &p2) { return (p1.ai() == p2.ai()) && (p1.aj() == p2.aj()); } -static void rm2par(std::vector *p, peq eq) +static void rm2par(std::vector *p, peq eq) { if (p->empty()) { @@ -183,9 +183,9 @@ static void rm2par(std::vector *p, peq eq) } } -static void cppar(gmx::ArrayRef types, - gmx::ArrayRef plist, - int ftype) +static void cppar(gmx::ArrayRef types, + gmx::ArrayRef plist, + int ftype) { /* Keep old stuff */ for (const auto &type : types) @@ -194,7 +194,7 @@ static void cppar(gmx::ArrayRef types, } } -static bool idcomp(const InteractionType &a, const InteractionType &b) +static bool idcomp(const InteractionOfType &a, const InteractionOfType &b) { int d; @@ -216,7 +216,7 @@ static bool idcomp(const InteractionType &a, const InteractionType &b) } } -static void sort_id(gmx::ArrayRef ps) +static void sort_id(gmx::ArrayRef ps) { if (ps.size() > 1) { @@ -254,21 +254,21 @@ static int n_hydro(gmx::ArrayRef a, char ***atomname) /* Clean up the dihedrals (both generated and read from the .rtp * file). */ -static std::vector clean_dih(gmx::ArrayRef dih, - gmx::ArrayRef improper, - t_atoms *atoms, bool bKeepAllGeneratedDihedrals, - bool bRemoveDihedralIfWithImproper) +static std::vector clean_dih(gmx::ArrayRef dih, + gmx::ArrayRef improper, + t_atoms *atoms, bool bKeepAllGeneratedDihedrals, + bool bRemoveDihedralIfWithImproper) { /* Construct the list of the indices of the dihedrals * (i.e. generated or read) that might be kept. */ - std::vector < std::pair < InteractionType, int>> newDihedrals; + std::vector < std::pair < InteractionOfType, int>> newDihedrals; if (bKeepAllGeneratedDihedrals) { fprintf(stderr, "Keeping all generated dihedrals\n"); int i = 0; for (const auto &dihedral : dih) { - newDihedrals.emplace_back(std::pair(dihedral, i++)); + newDihedrals.emplace_back(std::pair(dihedral, i++)); } } else @@ -288,7 +288,7 @@ static std::vector clean_dih(gmx::ArrayRef(*dihedral, i++)); + newDihedrals.emplace_back(std::pair(*dihedral, i++)); } } } @@ -351,7 +351,7 @@ static std::vector clean_dih(gmx::ArrayRef finalDihedrals; + std::vector finalDihedrals; finalDihedrals.reserve(newDihedrals.size()); for (const auto ¶m : newDihedrals) { @@ -360,11 +360,11 @@ static std::vector clean_dih(gmx::ArrayRef get_impropers(t_atoms *atoms, - gmx::ArrayRef globalPatches, - bool bAllowMissing) +static std::vector get_impropers(t_atoms *atoms, + gmx::ArrayRef globalPatches, + bool bAllowMissing) { - std::vector improper; + std::vector improper; /* Add all the impropers from the residue database to the list. */ int start = 0; @@ -394,7 +394,7 @@ static std::vector get_impropers(t_atoms if (!bStop) { /* Not broken out */ - improper.emplace_back(InteractionType(ai, {}, bondeds.s)); + improper.emplace_back(InteractionOfType(ai, {}, bondeds.s)); } } while ((start < atoms->nr) && (atoms->atom[start].resind == i)) @@ -614,19 +614,19 @@ void generate_excls(t_nextnb *nnb, int nrexcl, t_excls excls[]) /* Generate pairs, angles and dihedrals from .rtp settings */ void gen_pad(t_nextnb *nnb, t_atoms *atoms, gmx::ArrayRef rtpFFDB, - gmx::ArrayRef plist, t_excls excls[], gmx::ArrayRef globalPatches, + gmx::ArrayRef plist, t_excls excls[], gmx::ArrayRef globalPatches, bool bAllowMissing) { /* These are the angles, dihedrals and pairs that we generate * from the bonds. The ones that are already there from the rtp file * will be retained. */ - std::vector ang; - std::vector dih; - std::vector pai; - std::vector improper; + std::vector ang; + std::vector dih; + std::vector pai; + std::vector improper; - std::array anm; + std::array anm; if (!globalPatches.empty()) { @@ -701,7 +701,7 @@ void gen_pad(t_nextnb *nnb, t_atoms *atoms, gmx::ArrayRef atoms = {i, j1, k1, l1}; - dih.push_back(InteractionType(atoms, {}, "")); + dih.push_back(InteractionOfType(atoms, {}, "")); } int nbd = nb_dist(nnb, i, l1); @@ -785,7 +785,7 @@ void gen_pad(t_nextnb *nnb, t_atoms *atoms, gmx::ArrayRef atoms = {i1, i2}; - pai.push_back(InteractionType(atoms, {}, "")); + pai.push_back(InteractionOfType(atoms, {}, "")); } } } @@ -840,7 +840,7 @@ void gen_pad(t_nextnb *nnb, t_atoms *atoms, gmx::ArrayRef rtpFFDB, - gmx::ArrayRef plist, + gmx::ArrayRef plist, t_excls excls[], gmx::ArrayRef globalPatches, bool bAllowMissing); diff --git a/src/gromacs/gmxpreprocess/gen_vsite.cpp b/src/gromacs/gmxpreprocess/gen_vsite.cpp index d7acf13224..38537e1a4c 100644 --- a/src/gromacs/gmxpreprocess/gen_vsite.cpp +++ b/src/gromacs/gmxpreprocess/gen_vsite.cpp @@ -469,7 +469,7 @@ static real get_ddb_angle(gmx::ArrayRef vsitetop, } -static void count_bonds(int atom, InteractionTypeParameters *psb, char ***atomname, +static void count_bonds(int atom, InteractionsOfType *psb, char ***atomname, int *nrbonds, int *nrHatoms, int Hatoms[], int *Heavy, int *nrheavies, int heavies[]) { @@ -606,7 +606,7 @@ static real get_amass(int atom, t_atoms *at, gmx::ArrayRef plist, int vsite_type[], +static void add_vsites(gmx::ArrayRef plist, int vsite_type[], int Heavy, int nrHatoms, int Hatoms[], int nrheavies, int heavies[]) { @@ -722,7 +722,7 @@ static void add_vsites(gmx::ArrayRef plist, int vsite /* get cos(alpha) when a, b and c are given: */ #define acosrule(a, b, c) ( (gmx::square(b)+gmx::square(c)-gmx::square(a))/(2*(b)*(c)) ) -static int gen_vsites_6ring(t_atoms *at, int *vsite_type[], gmx::ArrayRef plist, +static int gen_vsites_6ring(t_atoms *at, int *vsite_type[], gmx::ArrayRef plist, int nrfound, int *ats, real bond_cc, real bond_ch, real xcom, bool bDoZ) { @@ -813,7 +813,7 @@ static int gen_vsites_6ring(t_atoms *at, int *vsite_type[], gmx::ArrayRef plist, +static int gen_vsites_phe(t_atoms *at, int *vsite_type[], gmx::ArrayRef plist, int nrfound, int *ats, gmx::ArrayRef vsitetop) { real bond_cc, bond_ch; @@ -879,7 +879,7 @@ static int gen_vsites_trp(PreprocessingAtomTypes *atype, t_symtab *symtab, int *nadd, gmx::ArrayRef x, int *cgnr[], t_atoms *at, int *vsite_type[], - gmx::ArrayRef plist, + gmx::ArrayRef plist, int nrfound, int *ats, int add_shift, gmx::ArrayRef vsitetop) { @@ -1153,7 +1153,7 @@ static int gen_vsites_tyr(PreprocessingAtomTypes *atype, t_symtab *symtab, int *nadd, gmx::ArrayRef x, int *cgnr[], t_atoms *at, int *vsite_type[], - gmx::ArrayRef plist, + gmx::ArrayRef plist, int nrfound, int *ats, int add_shift, gmx::ArrayRef vsitetop) { @@ -1298,7 +1298,7 @@ static int gen_vsites_tyr(PreprocessingAtomTypes *atype, } static int gen_vsites_his(t_atoms *at, int *vsite_type[], - gmx::ArrayRef plist, + gmx::ArrayRef plist, int nrfound, int *ats, gmx::ArrayRef vsitetop) { int nvsite, i; @@ -1553,7 +1553,7 @@ static char atomnamesuffix[] = "1234"; void do_vsites(gmx::ArrayRef rtpFFDB, PreprocessingAtomTypes *atype, t_atoms *at, t_symtab *symtab, std::vector *x, - gmx::ArrayRef plist, int *vsite_type[], int *cgnr[], + gmx::ArrayRef plist, int *vsite_type[], int *cgnr[], real mHmult, bool bVsiteAromatics, const char *ffdir) { @@ -2135,7 +2135,7 @@ void do_vsites(gmx::ArrayRef rtpFFDB, PreprocessingAtom /* now renumber all the interactions because of the added atoms */ for (int ftype = 0; ftype < F_NRE; ftype++) { - InteractionTypeParameters *params = &(plist[ftype]); + InteractionsOfType *params = &(plist[ftype]); if (debug) { fprintf(debug, "Renumbering %zu %s\n", params->size(), @@ -2167,7 +2167,7 @@ void do_vsites(gmx::ArrayRef rtpFFDB, PreprocessingAtom newAtomNumber.emplace_back(o2n[atomNumbers[j]]); } } - *parm = InteractionType(newAtomNumber, parm->forceParam(), parm->interactionTypeName()); + *parm = InteractionOfType(newAtomNumber, parm->forceParam(), parm->interactionTypeName()); if (debug) { fprintf(debug, "\n"); @@ -2175,7 +2175,7 @@ void do_vsites(gmx::ArrayRef rtpFFDB, PreprocessingAtom } } /* sort constraint parameters */ - InteractionTypeParameters *params = &(plist[F_CONSTRNC]); + InteractionsOfType *params = &(plist[F_CONSTRNC]); for (auto &type : params->interactionTypes) { type.sortAtomIds(); @@ -2190,7 +2190,7 @@ void do_vsites(gmx::ArrayRef rtpFFDB, PreprocessingAtom fprintf(stderr, "Added %zu new constraints\n", plist[F_CONSTRNC].size()); } -void do_h_mass(InteractionTypeParameters *psb, int vsite_type[], t_atoms *at, real mHmult, +void do_h_mass(InteractionsOfType *psb, int vsite_type[], t_atoms *at, real mHmult, bool bDeuterate) { /* loop over all atoms */ diff --git a/src/gromacs/gmxpreprocess/gen_vsite.h b/src/gromacs/gmxpreprocess/gen_vsite.h index 532d6b79e6..580d1dbe5c 100644 --- a/src/gromacs/gmxpreprocess/gen_vsite.h +++ b/src/gromacs/gmxpreprocess/gen_vsite.h @@ -44,7 +44,7 @@ class PreprocessingAtomTypes; struct t_atoms; -struct InteractionTypeParameters; +struct InteractionsOfType; struct PreprocessResidue; struct t_symtab; @@ -52,11 +52,11 @@ struct t_symtab; void do_vsites(gmx::ArrayRef rtpFFDB, PreprocessingAtomTypes *atype, t_atoms *at, t_symtab *symtab, std::vector *x, - gmx::ArrayRef plist, int *dummy_type[], int *cgnr[], + gmx::ArrayRef plist, int *dummy_type[], int *cgnr[], real mHmult, bool bVSiteAromatics, const char *ffdir); -void do_h_mass(InteractionTypeParameters *psb, int vsite_type[], t_atoms *at, real mHmult, +void do_h_mass(InteractionsOfType *psb, int vsite_type[], t_atoms *at, real mHmult, bool bDeuterate); #endif diff --git a/src/gromacs/gmxpreprocess/gpp_atomtype.cpp b/src/gromacs/gmxpreprocess/gpp_atomtype.cpp index 1023c0ae43..1cf8bad2c4 100644 --- a/src/gromacs/gmxpreprocess/gpp_atomtype.cpp +++ b/src/gromacs/gmxpreprocess/gpp_atomtype.cpp @@ -58,26 +58,26 @@ struct AtomTypeData { //! Explicit constructor. - AtomTypeData(const t_atom &a, - char **name, - const InteractionType &nb, - const int bondAtomType, - const int atomNumber) : + AtomTypeData(const t_atom &a, + char **name, + const InteractionOfType &nb, + const int bondAtomType, + const int atomNumber) : atom_(a), name_(name), nb_(nb), bondAtomType_(bondAtomType), atomNumber_(atomNumber) { } //! Actual atom data. - t_atom atom_; + t_atom atom_; //! Atom name. - char **name_; + char **name_; //! Nonbonded data. - InteractionType nb_; + InteractionOfType nb_; //! Bonded atomtype for the type. - int bondAtomType_; + int bondAtomType_; //! Atom number for the atom type. - int atomNumber_; + int atomNumber_; }; class PreprocessingAtomTypes::Impl @@ -176,12 +176,12 @@ PreprocessingAtomTypes &PreprocessingAtomTypes::operator=(PreprocessingAtomTypes PreprocessingAtomTypes::~PreprocessingAtomTypes() {} -int PreprocessingAtomTypes::addType(t_symtab *tab, - const t_atom &a, - const std::string &name, - const InteractionType &nb, - int bondAtomType, - int atomNumber) +int PreprocessingAtomTypes::addType(t_symtab *tab, + const t_atom &a, + const std::string &name, + const InteractionOfType &nb, + int bondAtomType, + int atomNumber) { int position = atomTypeFromName(name); if (position == NOTSET) @@ -199,13 +199,13 @@ int PreprocessingAtomTypes::addType(t_symtab *tab, } } -int PreprocessingAtomTypes::setType(int nt, - t_symtab *tab, - const t_atom &a, - const std::string &name, - const InteractionType &nb, - int bondAtomType, - int atomNumber) +int PreprocessingAtomTypes::setType(int nt, + t_symtab *tab, + const t_atom &a, + const std::string &name, + const InteractionOfType &nb, + int bondAtomType, + int atomNumber) { if (!isSet(nt)) { @@ -236,12 +236,12 @@ void PreprocessingAtomTypes::printTypes(FILE * out) fprintf (out, "\n"); } -static int search_atomtypes(const PreprocessingAtomTypes *ga, - int *n, - gmx::ArrayRef typelist, - int thistype, - gmx::ArrayRef interactionTypes, - int ftype) +static int search_atomtypes(const PreprocessingAtomTypes *ga, + int *n, + gmx::ArrayRef typelist, + int thistype, + gmx::ArrayRef interactionTypes, + int ftype) { int nn = *n; int nrfp = NRFP(ftype); @@ -294,7 +294,7 @@ static int search_atomtypes(const PreprocessingAtomTypes *ga, return i; } -void PreprocessingAtomTypes::renumberTypes(gmx::ArrayRef plist, +void PreprocessingAtomTypes::renumberTypes(gmx::ArrayRef plist, gmx_mtop_t *mtop, int *wall_atomtype, bool bVerbose) @@ -359,15 +359,15 @@ void PreprocessingAtomTypes::renumberTypes(gmx::ArrayRef nbsnew; + std::vector nbsnew; for (int i = 0; (i < nat); i++) { int mi = typelist[i]; for (int j = 0; (j < nat); j++) { - int mj = typelist[j]; - const InteractionType &interactionType = plist[ftype].interactionTypes[ntype*mi+mj]; + int mj = typelist[j]; + const InteractionOfType &interactionType = plist[ftype].interactionTypes[ntype*mi+mj]; nbsnew.emplace_back(interactionType.atoms(), interactionType.forceParam(), interactionType.interactionTypeName()); } new_types.push_back(impl_->types[mi]); diff --git a/src/gromacs/gmxpreprocess/gpp_atomtype.h b/src/gromacs/gmxpreprocess/gpp_atomtype.h index a6ed9e24f0..8869f72702 100644 --- a/src/gromacs/gmxpreprocess/gpp_atomtype.h +++ b/src/gromacs/gmxpreprocess/gpp_atomtype.h @@ -55,8 +55,8 @@ struct gmx_mtop_t; struct t_atom; struct t_atomtypes; -class InteractionType; -struct InteractionTypeParameters; +class InteractionOfType; +struct InteractionsOfType; struct t_symtab; /*! \libinternal \brief @@ -173,13 +173,13 @@ class PreprocessingAtomTypes * \param[in] atomNumber Atomic number of the entry. * \returns Number of the type set or NOTSET */ - int setType(int nt, - t_symtab *tab, - const t_atom &a, - const std::string &name, - const InteractionType &nb, - int bondAtomType, - int atomNumber); + int setType(int nt, + t_symtab *tab, + const t_atom &a, + const std::string &name, + const InteractionOfType &nb, + int bondAtomType, + int atomNumber); /*! \brief * Add new atom type to database. @@ -192,12 +192,12 @@ class PreprocessingAtomTypes * \param[in] atomNumber Atomic number of the entry. * \returns Number of entries in database. */ - int addType(t_symtab *tab, - const t_atom &a, - const std::string &name, - const InteractionType &nb, - int bondAtomType, - int atomNumber); + int addType(t_symtab *tab, + const t_atom &a, + const std::string &name, + const InteractionOfType &nb, + int bondAtomType, + int atomNumber); /*! \brief * Renumber existing atom type entries. @@ -207,7 +207,7 @@ class PreprocessingAtomTypes * \param[inout] wallAtomType Atom types of wall atoms, which may also be renumbered * \param[in] verbose If we want to print additional info. */ - void renumberTypes(gmx::ArrayRef plist, + void renumberTypes(gmx::ArrayRef plist, gmx_mtop_t *mtop, int *wallAtomType, bool verbose); diff --git a/src/gromacs/gmxpreprocess/gpp_nextnb.cpp b/src/gromacs/gmxpreprocess/gpp_nextnb.cpp index 394c026e60..f544dfae50 100644 --- a/src/gromacs/gmxpreprocess/gpp_nextnb.cpp +++ b/src/gromacs/gmxpreprocess/gpp_nextnb.cpp @@ -340,7 +340,7 @@ static void do_gen(int nrbonds, /* total number of bonds in s */ } -static void add_b(InteractionTypeParameters *bonds, int *nrf, sortable *s) +static void add_b(InteractionsOfType *bonds, int *nrf, sortable *s) { int i = 0; for (const auto &bond : bonds->interactionTypes) @@ -361,7 +361,7 @@ static void add_b(InteractionTypeParameters *bonds, int *nrf, sortable *s) } } -void gen_nnb(t_nextnb *nnb, gmx::ArrayRef plist) +void gen_nnb(t_nextnb *nnb, gmx::ArrayRef plist) { sortable *s; int nrbonds, nrf; @@ -442,7 +442,7 @@ sort_and_purge_nnb(t_nextnb *nnb) void generate_excl (int nrexcl, int nratoms, - gmx::ArrayRef plist, t_nextnb *nnb, t_blocka *excl) + gmx::ArrayRef plist, t_nextnb *nnb, t_blocka *excl) { if (nrexcl < 0) { diff --git a/src/gromacs/gmxpreprocess/gpp_nextnb.h b/src/gromacs/gmxpreprocess/gpp_nextnb.h index 1e6f8a420a..1cf6ce1893 100644 --- a/src/gromacs/gmxpreprocess/gpp_nextnb.h +++ b/src/gromacs/gmxpreprocess/gpp_nextnb.h @@ -41,7 +41,7 @@ #include "gromacs/utility/arrayref.h" struct t_blocka; -struct InteractionTypeParameters; +struct InteractionsOfType; struct t_nextnb { @@ -68,7 +68,7 @@ void print_nnb(t_nextnb *nnb, char *s); #define print_nnb(nnb, s) #endif -void gen_nnb(t_nextnb *nnb, gmx::ArrayRef plist); +void gen_nnb(t_nextnb *nnb, gmx::ArrayRef plist); /* Generate a t_nextnb structure from bond information. * With the structure you can either generate exclusions * or generate angles and dihedrals. The structure must be @@ -76,7 +76,7 @@ void gen_nnb(t_nextnb *nnb, gmx::ArrayRef plist); */ void generate_excl (int nrexcl, int nratoms, - gmx::ArrayRef plist, t_nextnb *nnb, t_blocka *excl); + gmx::ArrayRef plist, t_nextnb *nnb, t_blocka *excl); /* Generate an exclusion block from bonds and constraints in * plist. */ diff --git a/src/gromacs/gmxpreprocess/grompp.cpp b/src/gromacs/gmxpreprocess/grompp.cpp index 5852c03a6a..1c8b99d808 100644 --- a/src/gromacs/gmxpreprocess/grompp.cpp +++ b/src/gromacs/gmxpreprocess/grompp.cpp @@ -105,9 +105,9 @@ #include "gromacs/utility/snprintf.h" /* TODO The implementation details should move to their own source file. */ -InteractionType::InteractionType(gmx::ArrayRef atoms, - gmx::ArrayRef params, - const std::string &name) +InteractionOfType::InteractionOfType(gmx::ArrayRef atoms, + gmx::ArrayRef params, + const std::string &name) : atoms_(atoms.begin(), atoms.end()), interactionTypeName_(name) { @@ -124,57 +124,57 @@ InteractionType::InteractionType(gmx::ArrayRef atoms, } } -const int &InteractionType::ai() const +const int &InteractionOfType::ai() const { GMX_RELEASE_ASSERT(!atoms_.empty(), "Need to have at least one atom set"); return atoms_[0]; } -const int &InteractionType::aj() const +const int &InteractionOfType::aj() const { GMX_RELEASE_ASSERT(atoms_.size() > 1, "Need to have at least two atoms set"); return atoms_[1]; } -const int &InteractionType::ak() const +const int &InteractionOfType::ak() const { GMX_RELEASE_ASSERT(atoms_.size() > 2, "Need to have at least three atoms set"); return atoms_[2]; } -const int &InteractionType::al() const +const int &InteractionOfType::al() const { GMX_RELEASE_ASSERT(atoms_.size() > 3, "Need to have at least four atoms set"); return atoms_[3]; } -const int &InteractionType::am() const +const int &InteractionOfType::am() const { GMX_RELEASE_ASSERT(atoms_.size() > 4, "Need to have at least five atoms set"); return atoms_[4]; } -const real &InteractionType::c0() const +const real &InteractionOfType::c0() const { return forceParam_[0]; } -const real &InteractionType::c1() const +const real &InteractionOfType::c1() const { return forceParam_[1]; } -const real &InteractionType::c2() const +const real &InteractionOfType::c2() const { return forceParam_[2]; } -const std::string &InteractionType::interactionTypeName() const +const std::string &InteractionOfType::interactionTypeName() const { return interactionTypeName_; } -void InteractionType::sortBondAtomIds() +void InteractionOfType::sortBondAtomIds() { if (aj() < ai()) { @@ -182,7 +182,7 @@ void InteractionType::sortBondAtomIds() } } -void InteractionType::sortAngleAtomIds() +void InteractionOfType::sortAngleAtomIds() { if (ak() < ai()) { @@ -190,7 +190,7 @@ void InteractionType::sortAngleAtomIds() } } -void InteractionType::sortDihedralAtomIds() +void InteractionOfType::sortDihedralAtomIds() { if (al() < ai()) { @@ -199,7 +199,7 @@ void InteractionType::sortDihedralAtomIds() } } -void InteractionType::sortAtomIds() +void InteractionOfType::sortAtomIds() { if (isBond()) { @@ -219,7 +219,7 @@ void InteractionType::sortAtomIds() } }; -void InteractionType::setForceParameter(int pos, real value) +void InteractionOfType::setForceParameter(int pos, real value) { GMX_RELEASE_ASSERT(pos < MAXFORCEPARAM, "Can't set parameter beyond the maximum number of parameters"); forceParam_[pos] = value; @@ -251,8 +251,8 @@ static int rm_interactions(int ifunc, gmx::ArrayRef mols) /* For all the molecule types */ for (auto &mol : mols) { - n += mol.plist[ifunc].size(); - mol.plist[ifunc].interactionTypes.clear(); + n += mol.interactions[ifunc].size(); + mol.interactions[ifunc].interactionTypes.clear(); } return n; } @@ -550,7 +550,7 @@ static int nint_ftype(gmx_mtop_t *mtop, gmx::ArrayRef int nint = 0; for (const gmx_molblock_t &molb : mtop->molblock) { - nint += molb.nmol*mi[molb.type].plist[ftype].size(); + nint += molb.nmol*mi[molb.type].interactions[ftype].size(); } return nint; @@ -627,7 +627,7 @@ new_status(const char *topfile, const char *topppfile, const char *confin, PreprocessingAtomTypes *atypes, gmx_mtop_t *sys, std::vector *mi, std::unique_ptr *intermolecular_interactions, - gmx::ArrayRef plist, + gmx::ArrayRef interactions, int *comb, double *reppow, real *fudgeQQ, gmx_bool bMorse, warninp *wi) @@ -640,7 +640,7 @@ new_status(const char *topfile, const char *topppfile, const char *confin, /* TOPOLOGY processing */ sys->name = do_top(bVerbose, topfile, topppfile, opts, bZero, &(sys->symtab), - plist, comb, reppow, fudgeQQ, + interactions, comb, reppow, fudgeQQ, atypes, mi, intermolecular_interactions, ir, &molblock, @@ -988,8 +988,8 @@ static void read_posres(gmx_mtop_t *mtop, for (gmx_molblock_t &molb : mtop->molblock) { nat_molb = molb.nmol*mtop->moltype[molb.type].atoms.nr; - const InteractionTypeParameters *pr = &(molinfo[molb.type].plist[F_POSRES]); - const InteractionTypeParameters *prfb = &(molinfo[molb.type].plist[F_FBPOSRES]); + const InteractionsOfType *pr = &(molinfo[molb.type].interactions[F_POSRES]); + const InteractionsOfType *prfb = &(molinfo[molb.type].interactions[F_FBPOSRES]); if (pr->size() > 0 || prfb->size() > 0) { atom = mtop->moltype[molb.type].atoms.atom; @@ -1331,17 +1331,17 @@ static int count_constraints(const gmx_mtop_t *mtop, for (const gmx_molblock_t &molb : mtop->molblock) { count_mol = 0; - gmx::ArrayRef plist = mi[molb.type].plist; + gmx::ArrayRef interactions = mi[molb.type].interactions; for (int i = 0; i < F_NRE; i++) { if (i == F_SETTLE) { - count_mol += 3*plist[i].size(); + count_mol += 3*interactions[i].size(); } else if (interaction_function[i].flags & IF_CONSTRAINT) { - count_mol += plist[i].size(); + count_mol += interactions[i].size(); } } @@ -1913,9 +1913,9 @@ int gmx_grompp(int argc, char *argv[]) warning_error(wi, warn_buf); } - std::array plist; - gmx_mtop_t sys; - PreprocessingAtomTypes atypes; + std::array interactions; + gmx_mtop_t sys; + PreprocessingAtomTypes atypes; if (debug) { pr_symtab(debug, 0, "Just opened", &sys.symtab); @@ -1931,7 +1931,7 @@ int gmx_grompp(int argc, char *argv[]) new_status(fn, opt2fn_null("-pp", NFILE, fnm), opt2fn("-c", NFILE, fnm), opts, ir, bZero, bGenVel, bVerbose, &state, &atypes, &sys, &mi, &intermolecular_interactions, - plist, &comb, &reppow, &fudgeQQ, + interactions, &comb, &reppow, &fudgeQQ, opts->bMorse, wi); @@ -1945,7 +1945,7 @@ int gmx_grompp(int argc, char *argv[]) for (size_t mt = 0; mt < sys.moltype.size(); mt++) { nvsite += - set_vsites(bVerbose, &sys.moltype[mt].atoms, &atypes, mi[mt].plist); + set_vsites(bVerbose, &sys.moltype[mt].atoms, &atypes, mi[mt].interactions); } /* now throw away all obsolete bonds, angles and dihedrals: */ /* note: constraints are ALWAYS removed */ @@ -1953,7 +1953,7 @@ int gmx_grompp(int argc, char *argv[]) { for (size_t mt = 0; mt < sys.moltype.size(); mt++) { - clean_vsite_bondeds(mi[mt].plist, sys.moltype[mt].atoms.nr, bRmVSBds); + clean_vsite_bondeds(mi[mt].interactions, sys.moltype[mt].atoms.nr, bRmVSBds); } } @@ -2068,16 +2068,16 @@ int gmx_grompp(int argc, char *argv[]) } /* If we are using CMAP, setup the pre-interpolation grid */ - if (plist[F_CMAP].ncmap() > 0) + if (interactions[F_CMAP].ncmap() > 0) { - init_cmap_grid(&sys.ffparams.cmap_grid, plist[F_CMAP].cmapAngles, plist[F_CMAP].cmakeGridSpacing); - setup_cmap(plist[F_CMAP].cmakeGridSpacing, plist[F_CMAP].cmapAngles, plist[F_CMAP].cmap, &sys.ffparams.cmap_grid); + init_cmap_grid(&sys.ffparams.cmap_grid, interactions[F_CMAP].cmapAngles, interactions[F_CMAP].cmakeGridSpacing); + setup_cmap(interactions[F_CMAP].cmakeGridSpacing, interactions[F_CMAP].cmapAngles, interactions[F_CMAP].cmap, &sys.ffparams.cmap_grid); } set_wall_atomtype(&atypes, opts, ir, wi); if (bRenum) { - atypes.renumberTypes(plist, &sys, ir->wall_atomtype, bVerbose); + atypes.renumberTypes(interactions, &sys, ir->wall_atomtype, bVerbose); } if (ir->implicit_solvent) @@ -2099,12 +2099,12 @@ int gmx_grompp(int argc, char *argv[]) } const int ntype = atypes.size(); - convertInteractionTypeParameters(ntype, plist, mi, intermolecular_interactions.get(), - comb, reppow, fudgeQQ, &sys); + convertInteractionsOfType(ntype, interactions, mi, intermolecular_interactions.get(), + comb, reppow, fudgeQQ, &sys); if (debug) { - pr_symtab(debug, 0, "After converInteractionTypeParameters", &sys.symtab); + pr_symtab(debug, 0, "After converInteractionsOfType", &sys.symtab); } /* set ptype to VSite for virtual sites */ diff --git a/src/gromacs/gmxpreprocess/grompp_impl.h b/src/gromacs/gmxpreprocess/grompp_impl.h index eae3711ae5..18411cd7a3 100644 --- a/src/gromacs/gmxpreprocess/grompp_impl.h +++ b/src/gromacs/gmxpreprocess/grompp_impl.h @@ -50,15 +50,15 @@ #include "gromacs/utility/real.h" /*! \libinternal \brief - * Describes a single parameter in a force field. + * Describes an interaction of a given type, plus its parameters. */ -class InteractionType +class InteractionOfType { public: //! Constructor that initializes vectors. - InteractionType(gmx::ArrayRef atoms, - gmx::ArrayRef params, - const std::string &name = ""); + InteractionOfType(gmx::ArrayRef atoms, + gmx::ArrayRef params, + const std::string &name = ""); /*!@{*/ //! Access the individual elements set for the parameter. const int &ai() const; @@ -130,18 +130,18 @@ class InteractionType * lists of interactions of a given type in a [moleculetype] * topology file definition. */ -struct InteractionTypeParameters +struct InteractionsOfType { // NOLINT (clang-analyzer-optin.performance.Padding) //! The different parameters in the system. - std::vector interactionTypes; + std::vector interactionTypes; //! CMAP grid spacing. - int cmakeGridSpacing = -1; + int cmakeGridSpacing = -1; //! Number of cmap angles. - int cmapAngles = -1; + int cmapAngles = -1; //! CMAP grid data. - std::vector cmap; + std::vector cmap; //! The five atomtypes followed by a number that identifies the type. - std::vector cmapAtomTypes; + std::vector cmapAtomTypes; //! Number of parameters. size_t size() const { return interactionTypes.size(); } @@ -179,8 +179,8 @@ struct MoleculeInformation t_block mols; //! Exclusions in the molecule. t_blocka excls; - //! Parameters in old style. - std::array plist; + //! Interactions of a defined type. + std::array interactions; /*! \brief * Initializer. diff --git a/src/gromacs/gmxpreprocess/nm2type.cpp b/src/gromacs/gmxpreprocess/nm2type.cpp index 9a7513d9f0..437030c57b 100644 --- a/src/gromacs/gmxpreprocess/nm2type.cpp +++ b/src/gromacs/gmxpreprocess/nm2type.cpp @@ -192,7 +192,7 @@ static int match_str(const char *atom, const char *template_string) } int nm2type(int nnm, t_nm2type nm2t[], t_symtab *tab, t_atoms *atoms, - PreprocessingAtomTypes *atype, int *nbonds, InteractionTypeParameters *bonds) + PreprocessingAtomTypes *atype, int *nbonds, InteractionsOfType *bonds) { int cur = 0; #define prev (1-cur) @@ -336,7 +336,7 @@ int nm2type(int nnm, t_nm2type nm2t[], t_symtab *tab, t_atoms *atoms, { atoms->atom[i].qB = alpha; atoms->atom[i].m = atoms->atom[i].mB = mm; - k = atype->addType(tab, atoms->atom[i], type, InteractionType({}, {}), + k = atype->addType(tab, atoms->atom[i], type, InteractionOfType({}, {}), atoms->atom[i].type, atomnr); } atoms->atom[i].type = k; diff --git a/src/gromacs/gmxpreprocess/nm2type.h b/src/gromacs/gmxpreprocess/nm2type.h index f982ececb7..4107337c1a 100644 --- a/src/gromacs/gmxpreprocess/nm2type.h +++ b/src/gromacs/gmxpreprocess/nm2type.h @@ -41,7 +41,7 @@ class PreprocessingAtomTypes; struct t_atoms; -struct InteractionTypeParameters; +struct InteractionsOfType; struct t_symtab; struct t_nm2type @@ -62,7 +62,7 @@ void dump_nm2type(FILE *fp, int nnm, t_nm2type nm2t[]); /* Dump the database for debugging. Can be reread by the program */ int nm2type(int nnm, t_nm2type nm2t[], t_symtab *tab, t_atoms *atoms, - PreprocessingAtomTypes *atype, int *nbonds, InteractionTypeParameters *bond); + PreprocessingAtomTypes *atype, int *nbonds, InteractionsOfType *bond); /* Try to determine the atomtype (force field dependent) for the atoms * with help of the bond list */ diff --git a/src/gromacs/gmxpreprocess/pdb2top.cpp b/src/gromacs/gmxpreprocess/pdb2top.cpp index 584ba950fa..713e281978 100644 --- a/src/gromacs/gmxpreprocess/pdb2top.cpp +++ b/src/gromacs/gmxpreprocess/pdb2top.cpp @@ -672,7 +672,7 @@ void print_top_mols(FILE *out, void write_top(FILE *out, const char *pr, const char *molname, t_atoms *at, bool bRTPresname, - int bts[], gmx::ArrayRef plist, t_excls excls[], + int bts[], gmx::ArrayRef plist, t_excls excls[], PreprocessingAtomTypes *atype, int *cgnr, int nrexcl) /* NOTE: nrexcl is not the size of *excl! */ { @@ -711,7 +711,7 @@ void write_top(FILE *out, const char *pr, const char *molname, -static void do_ssbonds(InteractionTypeParameters *ps, t_atoms *atoms, +static void do_ssbonds(InteractionsOfType *ps, t_atoms *atoms, gmx::ArrayRef ssbonds, bool bAllowMissing) { for (const auto &bond : ssbonds) @@ -731,7 +731,7 @@ static void do_ssbonds(InteractionTypeParameters *ps, t_atoms *atoms, } } -static void at2bonds(InteractionTypeParameters *psb, gmx::ArrayRef globalPatches, +static void at2bonds(InteractionsOfType *psb, gmx::ArrayRef globalPatches, t_atoms *atoms, gmx::ArrayRef x, real long_bond_dist, real short_bond_dist) @@ -813,7 +813,7 @@ static void at2bonds(InteractionTypeParameters *psb, gmx::ArrayRefsize() > 0) { @@ -1332,7 +1332,7 @@ void match_atomnames_with_rtp(gmx::ArrayRef usedPpResidue } #define NUM_CMAP_ATOMS 5 -static void gen_cmap(InteractionTypeParameters *psb, gmx::ArrayRef usedPpResidues, t_atoms *atoms) +static void gen_cmap(InteractionsOfType *psb, gmx::ArrayRef usedPpResidues, t_atoms *atoms) { int residx; const char *ptr; @@ -1462,7 +1462,7 @@ void pdb2top(FILE *top_file, const char *posre_fn, const char *molname, bool bDeuterate, bool bChargeGroups, bool bCmap, bool bRenumRes, bool bRTPresname) { - std::array plist; + std::array plist; t_excls *excls; t_nextnb nnb; int *cgnr; diff --git a/src/gromacs/gmxpreprocess/pdb2top.h b/src/gromacs/gmxpreprocess/pdb2top.h index 072371e15e..d350688a04 100644 --- a/src/gromacs/gmxpreprocess/pdb2top.h +++ b/src/gromacs/gmxpreprocess/pdb2top.h @@ -50,7 +50,7 @@ struct t_atoms; struct t_excls; struct MoleculePatchDatabase; struct t_mols; -struct InteractionTypeParameters; +struct InteractionsOfType; struct t_resinfo; struct PreprocessResidue; struct DisulfideBond; @@ -113,7 +113,7 @@ void print_top_mols(FILE *out, void write_top(FILE *out, const char *pr, const char *molname, t_atoms *at, bool bRTPresname, - int bts[], gmx::ArrayRef plist, t_excls excls[], + int bts[], gmx::ArrayRef plist, t_excls excls[], PreprocessingAtomTypes *atype, int *cgnr, int nrexcl); /* NOTE: nrexcl is not the size of *excl! */ diff --git a/src/gromacs/gmxpreprocess/resall.cpp b/src/gromacs/gmxpreprocess/resall.cpp index 1da6d137ea..60df05b6fb 100644 --- a/src/gromacs/gmxpreprocess/resall.cpp +++ b/src/gromacs/gmxpreprocess/resall.cpp @@ -92,7 +92,7 @@ PreprocessingAtomTypes read_atype(const char *ffdir, t_symtab *tab) if (sscanf(buf, "%s%lf", name, &m) == 2) { a->m = m; - at.addType(tab, *a, name, InteractionType({}, {}), 0, 0); + at.addType(tab, *a, name, InteractionOfType({}, {}), 0, 0); fprintf(stderr, "\rAtomtype %d", ++nratt); fflush(stderr); } diff --git a/src/gromacs/gmxpreprocess/tests/gpp_atomtype.cpp b/src/gromacs/gmxpreprocess/tests/gpp_atomtype.cpp index a7ebbb2140..50042a8941 100644 --- a/src/gromacs/gmxpreprocess/tests/gpp_atomtype.cpp +++ b/src/gromacs/gmxpreprocess/tests/gpp_atomtype.cpp @@ -81,10 +81,10 @@ class PreprocessingAtomTypesTest : public ::testing::Test done_symtab(&symtab_); } protected: - PreprocessingAtomTypes atypes_; - t_symtab symtab_; - t_atom atom_; - InteractionType nb_; + PreprocessingAtomTypes atypes_; + t_symtab symtab_; + t_atom atom_; + InteractionOfType nb_; }; TEST_F(PreprocessingAtomTypesTest, EmptyOnCreate) diff --git a/src/gromacs/gmxpreprocess/tomorse.cpp b/src/gromacs/gmxpreprocess/tomorse.cpp index 5c854a88a6..72d14acfd0 100644 --- a/src/gromacs/gmxpreprocess/tomorse.cpp +++ b/src/gromacs/gmxpreprocess/tomorse.cpp @@ -211,11 +211,11 @@ void convert_harmonics(gmx::ArrayRef mols, PreprocessingAto { if ((interaction_function[bb].flags & IF_BTYPE) && (bb != F_MORSE)) { - int nrharm = mol.plist[bb].size(); + int nrharm = mol.interactions[bb].size(); /* Now loop over the harmonics, trying to convert them */ - for (auto harmonic = mol.plist[bb].interactionTypes.begin(); - harmonic != mol.plist[bb].interactionTypes.end(); ) + for (auto harmonic = mol.interactions[bb].interactionTypes.begin(); + harmonic != mol.interactions[bb].interactionTypes.end(); ) { int ni = harmonic->ai(); int nj = harmonic->aj(); @@ -230,9 +230,9 @@ void convert_harmonics(gmx::ArrayRef mols, PreprocessingAto real beta = std::sqrt(kb/(2*edis)); std::vector atoms = {ni, nj}; std::vector forceParam = {b0, edis, beta}; - mol.plist[F_MORSE].interactionTypes.emplace_back( - InteractionType(atoms, forceParam)); - harmonic = mol.plist[bb].interactionTypes.erase(harmonic); + mol.interactions[F_MORSE].interactionTypes.emplace_back( + InteractionOfType(atoms, forceParam)); + harmonic = mol.interactions[bb].interactionTypes.erase(harmonic); } else { @@ -240,7 +240,7 @@ void convert_harmonics(gmx::ArrayRef mols, PreprocessingAto } } - int newHarmonics = mol.plist[bb].size(); + int newHarmonics = mol.interactions[bb].size(); fprintf(stderr, "Converted %d out of %d %s to morse bonds for mol %d\n", nrharm-newHarmonics, nrharm, interaction_function[bb].name, i); } diff --git a/src/gromacs/gmxpreprocess/topio.cpp b/src/gromacs/gmxpreprocess/topio.cpp index abdf0ecd1f..cee2f1b3b2 100644 --- a/src/gromacs/gmxpreprocess/topio.cpp +++ b/src/gromacs/gmxpreprocess/topio.cpp @@ -85,7 +85,7 @@ #define OPENDIR '[' /* starting sign for directive */ #define CLOSEDIR ']' /* ending sign for directive */ -static void gen_pairs(const InteractionTypeParameters &nbs, InteractionTypeParameters *pairs, real fudge, int comb) +static void gen_pairs(const InteractionsOfType &nbs, InteractionsOfType *pairs, real fudge, int comb) { real scaling; int ntp = nbs.size(); @@ -130,7 +130,7 @@ static void gen_pairs(const InteractionTypeParameters &nbs, InteractionTypeParam forceParam[j] = scaling*existingParam[j]; forceParam[nrfp+j] = scaling*existingParam[j]; } - pairs->interactionTypes.emplace_back(InteractionType(atomNumbers, forceParam)); + pairs->interactionTypes.emplace_back(InteractionOfType(atomNumbers, forceParam)); i++; } } @@ -377,7 +377,7 @@ static char **read_topol(const char *infile, const char *outfile, PreprocessingAtomTypes *atypes, std::vector *molinfo, std::unique_ptr *intermolecular_interactions, - gmx::ArrayRef plist, + gmx::ArrayRef interactions, int *combination_rule, double *reppow, t_gromppopts *opts, @@ -447,8 +447,8 @@ static char **read_topol(const char *infile, const char *outfile, *reppow = 12.0; /* Default value for repulsion power */ /* Init the number of CMAP torsion angles and grid spacing */ - plist[F_CMAP].cmakeGridSpacing = 0; - plist[F_CMAP].cmapAngles = 0; + interactions[F_CMAP].cmakeGridSpacing = 0; + interactions[F_CMAP].cmapAngles = 0; bWarn_copy_A_B = bFEP; @@ -638,10 +638,10 @@ static char **read_topol(const char *infile, const char *outfile, break; case Directive::d_bondtypes: - push_bt(d, plist, 2, nullptr, &bondAtomType, pline, wi); + push_bt(d, interactions, 2, nullptr, &bondAtomType, pline, wi); break; case Directive::d_constrainttypes: - push_bt(d, plist, 2, nullptr, &bondAtomType, pline, wi); + push_bt(d, interactions, 2, nullptr, &bondAtomType, pline, wi); break; case Directive::d_pairtypes: if (bGenPairs) @@ -650,15 +650,15 @@ static char **read_topol(const char *infile, const char *outfile, } else { - push_bt(d, plist, 2, atypes, nullptr, pline, wi); + push_bt(d, interactions, 2, atypes, nullptr, pline, wi); } break; case Directive::d_angletypes: - push_bt(d, plist, 3, nullptr, &bondAtomType, pline, wi); + push_bt(d, interactions, 3, nullptr, &bondAtomType, pline, wi); break; case Directive::d_dihedraltypes: /* Special routine that can read both 2 and 4 atom dihedral definitions. */ - push_dihedraltype(d, plist, &bondAtomType, pline, wi); + push_dihedraltype(d, interactions, &bondAtomType, pline, wi); break; case Directive::d_nonbond_params: @@ -678,7 +678,7 @@ static char **read_topol(const char *infile, const char *outfile, break; case Directive::d_cmaptypes: - push_cmaptype(d, plist, 5, atypes, &bondAtomType, pline, wi); + push_cmaptype(d, interactions, 5, atypes, &bondAtomType, pline, wi); break; case Directive::d_moleculetype: @@ -697,15 +697,15 @@ static char **read_topol(const char *infile, const char *outfile, } ntype = atypes->size(); ncombs = (ntype*(ntype+1))/2; - generate_nbparams(*combination_rule, nb_funct, &(plist[nb_funct]), atypes, wi); - ncopy = copy_nbparams(nbparam, nb_funct, &(plist[nb_funct]), + generate_nbparams(*combination_rule, nb_funct, &(interactions[nb_funct]), atypes, wi); + ncopy = copy_nbparams(nbparam, nb_funct, &(interactions[nb_funct]), ntype); fprintf(stderr, "Generated %d of the %d non-bonded parameter combinations\n", ncombs-ncopy, ncombs); free_nbparam(nbparam, ntype); if (bGenPairs) { - gen_pairs((plist[nb_funct]), &(plist[F_LJ14]), fudgeLJ, *combination_rule); - ncopy = copy_nbparams(pair, nb_funct, &(plist[F_LJ14]), + gen_pairs((interactions[nb_funct]), &(interactions[F_LJ14]), fudgeLJ, *combination_rule); + ncopy = copy_nbparams(pair, nb_funct, &(interactions[F_LJ14]), ntype); fprintf(stderr, "Generated %d of the %d 1-4 parameter combinations\n", ncombs-ncopy, ncombs); free_nbparam(pair, ntype); @@ -731,12 +731,12 @@ static char **read_topol(const char *infile, const char *outfile, case Directive::d_pairs: GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on"); - push_bond(d, plist, mi0->plist, &(mi0->atoms), atypes, pline, FALSE, + push_bond(d, interactions, mi0->interactions, &(mi0->atoms), atypes, pline, FALSE, bGenPairs, *fudgeQQ, bZero, &bWarn_copy_A_B, wi); break; case Directive::d_pairs_nb: GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on"); - push_bond(d, plist, mi0->plist, &(mi0->atoms), atypes, pline, FALSE, + push_bond(d, interactions, mi0->interactions, &(mi0->atoms), atypes, pline, FALSE, FALSE, 1.0, bZero, &bWarn_copy_A_B, wi); break; @@ -758,17 +758,17 @@ static char **read_topol(const char *infile, const char *outfile, case Directive::d_water_polarization: case Directive::d_thole_polarization: GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on"); - push_bond(d, plist, mi0->plist, &(mi0->atoms), atypes, pline, TRUE, + push_bond(d, interactions, mi0->interactions, &(mi0->atoms), atypes, pline, TRUE, bGenPairs, *fudgeQQ, bZero, &bWarn_copy_A_B, wi); break; case Directive::d_cmap: GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on"); - push_cmap(d, plist, mi0->plist, &(mi0->atoms), atypes, pline, wi); + push_cmap(d, interactions, mi0->interactions, &(mi0->atoms), atypes, pline, wi); break; case Directive::d_vsitesn: GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on"); - push_vsitesn(d, mi0->plist, &(mi0->atoms), pline, wi); + push_vsitesn(d, mi0->interactions, &(mi0->atoms), pline, wi); break; case Directive::d_exclusions: GMX_ASSERT(!exclusionBlocks.empty(), "exclusionBlocks must always be allocated so exclusions can be processed"); @@ -816,11 +816,11 @@ static char **read_topol(const char *infile, const char *outfile, t_nextnb nnb; generate_excl(mi0->nrexcl, mi0->atoms.nr, - mi0->plist, + mi0->interactions, &nnb, &(mi0->excls)); gmx::mergeExclusions(&(mi0->excls), exclusionBlocks[whichmol]); - make_shake(mi0->plist, &mi0->atoms, opts->nshake); + make_shake(mi0->interactions, &mi0->atoms, opts->nshake); done_nnb(&nnb); @@ -829,7 +829,7 @@ static char **read_topol(const char *infile, const char *outfile, convert_moltype_couple(mi0, dcatt, *fudgeQQ, opts->couple_lam0, opts->couple_lam1, opts->bCoupleIntra, - nb_funct, &(plist[nb_funct]), wi); + nb_funct, &(interactions[nb_funct]), wi); } stupid_fill_block(&mi0->mols, mi0->atoms.nr, TRUE); mi0->bProcessed = TRUE; @@ -933,7 +933,7 @@ char **do_top(bool bVerbose, t_gromppopts *opts, bool bZero, t_symtab *symtab, - gmx::ArrayRef plist, + gmx::ArrayRef interactions, int *combination_rule, double *repulsion_power, real *fudgeQQ, @@ -965,7 +965,7 @@ char **do_top(bool bVerbose, title = read_topol(topfile, tmpfile, opts->define, opts->include, symtab, atypes, molinfo, intermolecular_interactions, - plist, combination_rule, repulsion_power, + interactions, combination_rule, repulsion_power, opts, fudgeQQ, molblock, ffParametrizedWithHBondConstraints, ir->efep != efepNO, bZero, diff --git a/src/gromacs/gmxpreprocess/topio.h b/src/gromacs/gmxpreprocess/topio.h index c5e5386e3a..39e84c0474 100644 --- a/src/gromacs/gmxpreprocess/topio.h +++ b/src/gromacs/gmxpreprocess/topio.h @@ -50,7 +50,7 @@ class PreprocessingAtomTypes; struct t_gromppopts; struct t_inputrec; struct MoleculeInformation; -struct InteractionTypeParameters; +struct InteractionsOfType; struct t_symtab; struct warninp; enum struct GmxQmmmMode; @@ -65,7 +65,7 @@ char **do_top(bool bVerb t_gromppopts *opts, bool bZero, t_symtab *symtab, - gmx::ArrayRef plist, + gmx::ArrayRef plist, int *combination_rule, double *repulsion_power, real *fudgeQQ, diff --git a/src/gromacs/gmxpreprocess/toppush.cpp b/src/gromacs/gmxpreprocess/toppush.cpp index 52551d6806..751fad0ab4 100644 --- a/src/gromacs/gmxpreprocess/toppush.cpp +++ b/src/gromacs/gmxpreprocess/toppush.cpp @@ -68,7 +68,7 @@ void generate_nbparams(int comb, int ftype, - InteractionTypeParameters *plist, + InteractionsOfType *interactions, PreprocessingAtomTypes *atypes, warninp *wi) { @@ -78,7 +78,7 @@ void generate_nbparams(int comb, /* Lean mean shortcuts */ nr = atypes->size(); nrfp = NRFP(ftype); - plist->interactionTypes.clear(); + interactions->interactionTypes.clear(); std::array forceParam = {NOTSET}; /* Fill the matrix with force parameters */ @@ -100,7 +100,7 @@ void generate_nbparams(int comb, c = std::sqrt(ci * cj); forceParam[nf] = c; } - plist->interactionTypes.emplace_back(InteractionType({}, forceParam)); + interactions->interactionTypes.emplace_back(InteractionOfType({}, forceParam)); } } break; @@ -124,7 +124,7 @@ void generate_nbparams(int comb, forceParam[0] *= -1; } forceParam[1] = std::sqrt(ci1*cj1); - plist->interactionTypes.emplace_back(InteractionType({}, forceParam)); + interactions->interactionTypes.emplace_back(InteractionOfType({}, forceParam)); } } @@ -148,7 +148,7 @@ void generate_nbparams(int comb, forceParam[0] *= -1; } forceParam[1] = std::sqrt(ci1*cj1); - plist->interactionTypes.emplace_back(InteractionType({}, forceParam)); + interactions->interactionTypes.emplace_back(InteractionOfType({}, forceParam)); } } @@ -181,7 +181,7 @@ void generate_nbparams(int comb, forceParam[1] = 2.0/(1/bi+1/bj); } forceParam[2] = std::sqrt(ci2 * cj2); - plist->interactionTypes.emplace_back(InteractionType({}, forceParam)); + interactions->interactionTypes.emplace_back(InteractionOfType({}, forceParam)); } } @@ -194,7 +194,7 @@ void generate_nbparams(int comb, } /*! \brief Used to temporarily store the explicit non-bonded parameter - * combinations, which will be copied to InteractionTypeParameters. */ + * combinations, which will be copied to InteractionsOfType. */ struct t_nbparam { //! Has this combination been set. @@ -217,7 +217,7 @@ static void realloc_nb_params(PreprocessingAtomTypes *atypes, } } -int copy_nbparams(t_nbparam **param, int ftype, InteractionTypeParameters *plist, int nr) +int copy_nbparams(t_nbparam **param, int ftype, InteractionsOfType *interactions, int nr) { int nrfp, ncopy; @@ -233,8 +233,8 @@ int copy_nbparams(t_nbparam **param, int ftype, InteractionTypeParameters *plist { for (int f = 0; f < nrfp; f++) { - plist->interactionTypes[nr*i+j].setForceParameter(f, param[i][j].c[f]); - plist->interactionTypes[nr*j+i].setForceParameter(f, param[i][j].c[f]); + interactions->interactionTypes[nr*i+j].setForceParameter(f, param[i][j].c[f]); + interactions->interactionTypes[nr*j+i].setForceParameter(f, param[i][j].c[f]); } ncopy++; } @@ -541,7 +541,7 @@ void push_at (t_symtab *symtab, PreprocessingAtomTypes *at, PreprocessingBondAto forceParam[i] = c[i]; } - InteractionType interactionType({}, forceParam, ""); + InteractionOfType interactionType({}, forceParam, ""); batype_nr = bondAtomType->addBondAtomType(symtab, btype); @@ -578,13 +578,13 @@ static bool equalEitherForwardOrBackward(gmx::ArrayRef a, gmx::ArrayRef std::equal(a.begin(), a.end(), b.rbegin())); } -static void push_bondtype(InteractionTypeParameters *bt, - const InteractionType &b, - int nral, - int ftype, - bool bAllowRepeat, - const char *line, - warninp *wi) +static void push_bondtype(InteractionsOfType *bt, + const InteractionOfType &b, + int nral, + int ftype, + bool bAllowRepeat, + const char *line, + warninp *wi) { int nr = bt->size(); int nrfp = NRFP(ftype); @@ -693,7 +693,7 @@ static void push_bondtype(InteractionTypeParameters *bt, { /* fill the arrays up and down */ bt->interactionTypes.emplace_back( - InteractionType(b.atoms(), b.forceParam(), b.interactionTypeName())); + InteractionOfType(b.atoms(), b.forceParam(), b.interactionTypeName())); /* need to store force values because they might change below */ std::vector forceParam(b.forceParam().begin(), b.forceParam().end()); @@ -712,12 +712,12 @@ static void push_bondtype(InteractionTypeParameters *bt, { atoms.emplace_back(*oldAtom); } - bt->interactionTypes.emplace_back(InteractionType(atoms, forceParam, b.interactionTypeName())); + bt->interactionTypes.emplace_back(InteractionOfType(atoms, forceParam, b.interactionTypeName())); } } void push_bt(Directive d, - gmx::ArrayRef bt, + gmx::ArrayRef bt, int nral, PreprocessingAtomTypes *at, PreprocessingBondAtomType *bondAtomType, @@ -818,11 +818,11 @@ void push_bt(Directive d, { forceParam[i] = c[i]; } - push_bondtype (&(bt[ftype]), InteractionType(atoms, forceParam), nral, ftype, FALSE, line, wi); + push_bondtype (&(bt[ftype]), InteractionOfType(atoms, forceParam), nral, ftype, FALSE, line, wi); } -void push_dihedraltype(Directive d, gmx::ArrayRef bt, +void push_dihedraltype(Directive d, gmx::ArrayRef bt, PreprocessingBondAtomType *bondAtomType, char *line, warninp *wi) { @@ -990,7 +990,7 @@ void push_dihedraltype(Directive d, gmx::ArrayRef bt, /* Always use 4 atoms here, since we created two wildcard atoms * if there wasn't of them 4 already. */ - push_bondtype (&(bt[ftype]), InteractionType(atoms, forceParam), 4, ftype, bAllowRepeat, line, wi); + push_bondtype (&(bt[ftype]), InteractionOfType(atoms, forceParam), 4, ftype, bAllowRepeat, line, wi); } @@ -1122,7 +1122,7 @@ void push_nbt(Directive d, t_nbparam **nbt, PreprocessingAtomTypes *atypes, void push_cmaptype(Directive d, - gmx::ArrayRef bt, + gmx::ArrayRef bt, int nral, PreprocessingAtomTypes *atomtypes, PreprocessingBondAtomType *bondAtomType, @@ -1258,7 +1258,7 @@ push_cmaptype(Directive d, std::array forceParam = {NOTSET}; /* Push the bond to the bondlist */ - push_bondtype (&(bt[ftype]), InteractionType(atoms, forceParam), nral, ftype, FALSE, line, wi); + push_bondtype (&(bt[ftype]), InteractionOfType(atoms, forceParam), nral, ftype, FALSE, line, wi); } @@ -1508,16 +1508,16 @@ static bool findIfAllNBAtomsMatch(gmx::ArrayRef atomsFromParamet } } -static bool default_nb_params(int ftype, gmx::ArrayRef bt, t_atoms *at, - InteractionType *p, int c_start, bool bB, bool bGenPairs) +static bool default_nb_params(int ftype, gmx::ArrayRef bt, t_atoms *at, + InteractionOfType *p, int c_start, bool bB, bool bGenPairs) { - int ti, tj, ntype; - bool bFound; - InteractionType *pi = nullptr; - int nr = bt[ftype].size(); - int nral = NRAL(ftype); - int nrfp = interaction_function[ftype].nrfpA; - int nrfpB = interaction_function[ftype].nrfpB; + int ti, tj, ntype; + bool bFound; + InteractionOfType *pi = nullptr; + int nr = bt[ftype].size(); + int nral = NRAL(ftype); + int nrfp = interaction_function[ftype].nrfpA; + int nrfpB = interaction_function[ftype].nrfpB; if ((!bB && nrfp == 0) || (bB && nrfpB == 0)) { @@ -1601,9 +1601,9 @@ static bool default_nb_params(int ftype, gmx::ArrayRef bondtype, +static bool default_cmap_params(gmx::ArrayRef bondtype, t_atoms *at, PreprocessingAtomTypes *atypes, - InteractionType *p, bool bB, + InteractionOfType *p, bool bB, int *cmap_type, int *nparam_def, warninp *wi) { @@ -1655,7 +1655,7 @@ static bool default_cmap_params(gmx::ArrayRef bondtyp /* Returns the number of exact atom type matches, i.e. non wild-card matches, * returns -1 when there are no matches at all. */ -static int natom_match(const InteractionType &pi, +static int natom_match(const InteractionOfType &pi, int type_i, int type_j, int type_k, int type_l, const PreprocessingAtomTypes* atypes) { @@ -1676,11 +1676,11 @@ static int natom_match(const InteractionType &pi, } } -static int findNumberOfDihedralAtomMatches(const InteractionType ¤tParamFromParameterArray, - const InteractionType ¶meterToAdd, - const t_atoms *at, - const PreprocessingAtomTypes *atypes, - bool bB) +static int findNumberOfDihedralAtomMatches(const InteractionOfType ¤tParamFromParameterArray, + const InteractionOfType ¶meterToAdd, + const t_atoms *at, + const PreprocessingAtomTypes *atypes, + bool bB) { if (bB) { @@ -1736,11 +1736,11 @@ static bool findIfAllParameterAtomsMatch(gmx::ArrayRef atomsFrom } } -static std::vector::iterator -defaultInteractionTypeParameters(int ftype, gmx::ArrayRef bt, - t_atoms *at, PreprocessingAtomTypes *atypes, - const InteractionType &p, bool bB, - int *nparam_def) +static std::vector::iterator +defaultInteractionsOfType(int ftype, gmx::ArrayRef bt, + t_atoms *at, PreprocessingAtomTypes *atypes, + const InteractionOfType &p, bool bB, + int *nparam_def) { int nparam_found; int nrfpA = interaction_function[ftype].nrfpA; @@ -1823,8 +1823,8 @@ defaultInteractionTypeParameters(int ftype, gmx::ArrayRef bondtype, - gmx::ArrayRef bond, +void push_bond(Directive d, gmx::ArrayRef bondtype, + gmx::ArrayRef bond, t_atoms *at, PreprocessingAtomTypes *atypes, char *line, bool bBonded, bool bGenPairs, real fudgeQQ, bool bZero, bool *bWarn_copy_A_B, @@ -1965,19 +1965,19 @@ void push_bond(Directive d, gmx::ArrayRef bondtype, /* Get force params for normal and free energy perturbation * studies, as determined by types! */ - InteractionType param(atoms, forceParam, ""); + InteractionOfType param(atoms, forceParam, ""); - std::vector::iterator foundAParameter = bondtype[ftype].interactionTypes.end(); - std::vector::iterator foundBParameter = bondtype[ftype].interactionTypes.end(); + std::vector::iterator foundAParameter = bondtype[ftype].interactionTypes.end(); + std::vector::iterator foundBParameter = bondtype[ftype].interactionTypes.end(); if (bBonded) { - foundAParameter = defaultInteractionTypeParameters(ftype, - bondtype, - at, - atypes, - param, - FALSE, - &nparam_defA); + foundAParameter = defaultInteractionsOfType(ftype, + bondtype, + at, + atypes, + param, + FALSE, + &nparam_defA); if (foundAParameter != bondtype[ftype].interactionTypes.end()) { /* Copy the A-state and B-state default parameters. */ @@ -1993,13 +1993,13 @@ void push_bond(Directive d, gmx::ArrayRef bondtype, { bFoundA = true; } - foundBParameter = defaultInteractionTypeParameters(ftype, - bondtype, - at, - atypes, - param, - TRUE, - &nparam_defB); + foundBParameter = defaultInteractionsOfType(ftype, + bondtype, + at, + atypes, + param, + TRUE, + &nparam_defB); if (foundBParameter != bondtype[ftype].interactionTypes.end()) { /* Copy only the B-state default parameters */ @@ -2260,8 +2260,8 @@ void push_bond(Directive d, gmx::ArrayRef bondtype, } } -void push_cmap(Directive d, gmx::ArrayRef bondtype, - gmx::ArrayRef bond, +void push_cmap(Directive d, gmx::ArrayRef bondtype, + gmx::ArrayRef bond, t_atoms *at, PreprocessingAtomTypes *atypes, char *line, warninp *wi) { @@ -2328,8 +2328,8 @@ void push_cmap(Directive d, gmx::ArrayRef bondtype, { atoms.emplace_back(aa[j]-1); } - std::array forceParam = {0.0}; - InteractionType param(atoms, forceParam, ""); + std::array forceParam = {0.0}; + InteractionOfType param(atoms, forceParam, ""); /* Get the cmap type for this cmap angle */ bFound = default_cmap_params(bondtype, at, atypes, ¶m, FALSE, &cmap_type, &ncmap_params, wi); @@ -2351,7 +2351,7 @@ void push_cmap(Directive d, gmx::ArrayRef bondtype, -void push_vsitesn(Directive d, gmx::ArrayRef bond, +void push_vsitesn(Directive d, gmx::ArrayRef bond, t_atoms *at, char *line, warninp *wi) { @@ -2442,7 +2442,7 @@ void push_vsitesn(Directive d, gmx::ArrayRef bond, forceParam[0] = nj; forceParam[1] = weight[j]/weight_tot; /* Put the values in the appropriate arrays */ - add_param_to_list (&bond[ftype], InteractionType(atoms, forceParam)); + add_param_to_list (&bond[ftype], InteractionOfType(atoms, forceParam)); } sfree(atc); @@ -2577,7 +2577,7 @@ int add_atomtype_decoupled(t_symtab *symtab, PreprocessingAtomTypes *at, atom.ptype = eptAtom; std::array forceParam = {0.0}; - nr = at->addType(symtab, atom, "decoupled", InteractionType({}, forceParam, ""), -1, 0); + nr = at->addType(symtab, atom, "decoupled", InteractionOfType({}, forceParam, ""), -1, 0); /* Add space in the non-bonded parameters matrix */ realloc_nb_params(at, nbparam, pair); @@ -2585,14 +2585,14 @@ int add_atomtype_decoupled(t_symtab *symtab, PreprocessingAtomTypes *at, return nr; } -static void convert_pairs_to_pairsQ(gmx::ArrayRef plist, +static void convert_pairs_to_pairsQ(gmx::ArrayRef interactions, real fudgeQQ, t_atoms *atoms) { /* Add the pair list to the pairQ list */ - std::vector paramnew; + std::vector paramnew; - gmx::ArrayRef paramp1 = plist[F_LJ14].interactionTypes; - gmx::ArrayRef paramp2 = plist[F_LJC14_Q].interactionTypes; + gmx::ArrayRef paramp1 = interactions[F_LJ14].interactionTypes; + gmx::ArrayRef paramp2 = interactions[F_LJC14_Q].interactionTypes; /* Fill in the new F_LJC14_Q array with the old one. NOTE: it may be possible to just ADD the converted F_LJ14 array @@ -2612,17 +2612,17 @@ static void convert_pairs_to_pairsQ(gmx::ArrayRef pli fudgeQQ, atoms->atom[param.ai()].q, atoms->atom[param.aj()].q, param.c0(), param.c1() }; - paramnew.emplace_back(InteractionType(param.atoms(), forceParam, "")); + paramnew.emplace_back(InteractionOfType(param.atoms(), forceParam, "")); } /* now assign the new data to the F_LJC14_Q structure */ - plist[F_LJC14_Q].interactionTypes = paramnew; + interactions[F_LJC14_Q].interactionTypes = paramnew; /* Empty the LJ14 pairlist */ - plist[F_LJ14].interactionTypes.clear(); + interactions[F_LJ14].interactionTypes.clear(); } -static void generate_LJCpairsNB(MoleculeInformation *mol, int nb_funct, InteractionTypeParameters *nbp, warninp *wi) +static void generate_LJCpairsNB(MoleculeInformation *mol, int nb_funct, InteractionsOfType *nbp, warninp *wi) { int n, ntype; t_atom *atom; @@ -2665,7 +2665,7 @@ static void generate_LJCpairsNB(MoleculeInformation *mol, int nb_funct, Interact nbp->interactionTypes[ntype*atom[i].type+atom[j].type].c0(), nbp->interactionTypes[ntype*atom[i].type+atom[j].type].c1() }; - add_param_to_list(&mol->plist[F_LJC_PAIRS_NB], InteractionType(atoms, forceParam)); + add_param_to_list(&mol->interactions[F_LJC_PAIRS_NB], InteractionOfType(atoms, forceParam)); } } } @@ -2735,10 +2735,10 @@ static void decouple_atoms(t_atoms *atoms, int atomtype_decouple, void convert_moltype_couple(MoleculeInformation *mol, int atomtype_decouple, real fudgeQQ, int couple_lam0, int couple_lam1, - bool bCoupleIntra, int nb_funct, InteractionTypeParameters *nbp, + bool bCoupleIntra, int nb_funct, InteractionsOfType *nbp, warninp *wi) { - convert_pairs_to_pairsQ(mol->plist, fudgeQQ, &mol->atoms); + convert_pairs_to_pairsQ(mol->interactions, fudgeQQ, &mol->atoms); if (!bCoupleIntra) { generate_LJCpairsNB(mol, nb_funct, nbp, wi); diff --git a/src/gromacs/gmxpreprocess/toppush.h b/src/gromacs/gmxpreprocess/toppush.h index 0c1a689a54..626fd79f75 100644 --- a/src/gromacs/gmxpreprocess/toppush.h +++ b/src/gromacs/gmxpreprocess/toppush.h @@ -50,8 +50,8 @@ struct t_atoms; struct t_block; struct MoleculeInformation; struct t_nbparam; -class InteractionType; -struct InteractionTypeParameters; +class InteractionOfType; +struct InteractionsOfType; struct PreprocessResidue; struct warninp; @@ -60,7 +60,7 @@ namespace gmx struct ExclusionBlock; } // namespace gmx -void generate_nbparams(int comb, int funct, InteractionTypeParameters *plist, +void generate_nbparams(int comb, int funct, InteractionsOfType *plist, PreprocessingAtomTypes *atype, warninp *wi); @@ -69,15 +69,15 @@ void push_at (struct t_symtab *symtab, PreprocessingAtomTypes *at, t_nbparam ***nbparam, t_nbparam ***pair, warninp *wi); -void push_bt(Directive d, gmx::ArrayRef bt, int nral, +void push_bt(Directive d, gmx::ArrayRef bt, int nral, PreprocessingAtomTypes *at, PreprocessingBondAtomType *bat, char *line, warninp *wi); -void push_dihedraltype(Directive d, gmx::ArrayRef bt, +void push_dihedraltype(Directive d, gmx::ArrayRef bt, PreprocessingBondAtomType *bat, char *line, warninp *wi); -void push_cmaptype(Directive d, gmx::ArrayRef bt, int nral, PreprocessingAtomTypes *at, +void push_cmaptype(Directive d, gmx::ArrayRef bt, int nral, PreprocessingAtomTypes *at, PreprocessingBondAtomType *bat, char *line, warninp *wi); @@ -93,20 +93,20 @@ void push_atom(struct t_symtab *symtab, int *lastcg, warninp *wi); -void push_bond(Directive d, gmx::ArrayRef bondtype, - gmx::ArrayRef bond, +void push_bond(Directive d, gmx::ArrayRef bondtype, + gmx::ArrayRef bond, t_atoms *at, PreprocessingAtomTypes *atype, char *line, bool bBonded, bool bGenPairs, real fudgeQQ, bool bZero, bool *bWarn_copy_A_B, warninp *wi); void push_cmap(Directive d, - gmx::ArrayRef bondtype, - gmx::ArrayRef bond, + gmx::ArrayRef bondtype, + gmx::ArrayRef bond, t_atoms *at, PreprocessingAtomTypes *atype, char *line, warninp *wi); -void push_vsitesn(Directive d, gmx::ArrayRef bond, +void push_vsitesn(Directive d, gmx::ArrayRef bond, t_atoms *at, char *line, warninp *wi); @@ -119,7 +119,7 @@ void push_molt(struct t_symtab *symtab, std::vector *mol, c void push_excl(char *line, gmx::ArrayRef b2, warninp *wi); -int copy_nbparams(t_nbparam **param, int ftype, InteractionTypeParameters *plist, int nr); +int copy_nbparams(t_nbparam **param, int ftype, InteractionsOfType *plist, int nr); void free_nbparam(t_nbparam **param, int nr); @@ -133,7 +133,7 @@ void convert_moltype_couple(MoleculeInformation *mol, int atomtype_decouple, real fudgeQQ, int couple_lam0, int couple_lam1, bool bCoupleIntra, - int nb_funct, InteractionTypeParameters *nbp, + int nb_funct, InteractionsOfType *nbp, warninp *wi); /* Setup mol such that the B-state has no interaction with the rest * of the system, but full interaction with itself. diff --git a/src/gromacs/gmxpreprocess/topshake.cpp b/src/gromacs/gmxpreprocess/topshake.cpp index 5129535d42..d640f6ca22 100644 --- a/src/gromacs/gmxpreprocess/topshake.cpp +++ b/src/gromacs/gmxpreprocess/topshake.cpp @@ -75,7 +75,7 @@ static int count_hydrogens (char ***atomname, int nra, gmx::ArrayRef return nh; } -void make_shake(gmx::ArrayRef plist, t_atoms *atoms, int nshake) +void make_shake(gmx::ArrayRef plist, t_atoms *atoms, int nshake) { char ***info = atoms->atomname; real b_ij, b_jk; @@ -108,17 +108,17 @@ void make_shake(gmx::ArrayRef plist, t_atoms *atoms, { if (interaction_function[ftype].flags & IF_BTYPE) { - InteractionTypeParameters *bonds = &(plist[ftype]); + InteractionsOfType *bonds = &(plist[ftype]); for (int ftype_a = 0; (gmx::ssize(*bonds) > 0 && ftype_a < F_NRE); ftype_a++) { if (interaction_function[ftype_a].flags & IF_ATYPE) { - InteractionTypeParameters *pr = &(plist[ftype_a]); + InteractionsOfType *pr = &(plist[ftype_a]); for (auto parm = pr->interactionTypes.begin(); parm != pr->interactionTypes.end(); ) { - const InteractionType *ang = &(*parm); + const InteractionOfType *ang = &(*parm); #ifdef DEBUG printf("Angle: %d-%d-%d\n", ang->ai(), ang->aj(), ang->ak()); #endif @@ -164,7 +164,7 @@ void make_shake(gmx::ArrayRef plist, t_atoms *atoms, printf("p: %d, q: %d, dist: %12.5e\n", atomNumbers[0], atomNumbers[1], forceParm[0]); #endif - add_param_to_list (&(plist[F_CONSTR]), InteractionType(atomNumbers, forceParm)); + add_param_to_list (&(plist[F_CONSTR]), InteractionOfType(atomNumbers, forceParm)); /* move the last bond to this position */ *parm = *(pr->interactionTypes.end() - 1); pr->interactionTypes.erase(pr->interactionTypes.end() - 1); @@ -188,7 +188,7 @@ void make_shake(gmx::ArrayRef plist, t_atoms *atoms, { if (interaction_function[ftype].flags & IF_BTYPE) { - InteractionTypeParameters *pr = &(plist[ftype]); + InteractionsOfType *pr = &(plist[ftype]); for (auto parm = pr->interactionTypes.begin(); parm != pr->interactionTypes.end(); ) { if ( (nshake != eshHBONDS) || @@ -197,7 +197,7 @@ void make_shake(gmx::ArrayRef plist, t_atoms *atoms, /* append this bond to the shake list */ std::vector atomNumbers = {parm->ai(), parm->aj()}; std::vector forceParm = { parm->c0(), parm->c2()}; - add_param_to_list (&(plist[F_CONSTR]), InteractionType(atomNumbers, forceParm)); + add_param_to_list (&(plist[F_CONSTR]), InteractionOfType(atomNumbers, forceParm)); parm = pr->interactionTypes.erase(parm); } else diff --git a/src/gromacs/gmxpreprocess/topshake.h b/src/gromacs/gmxpreprocess/topshake.h index f9163f50db..7f2d57fe08 100644 --- a/src/gromacs/gmxpreprocess/topshake.h +++ b/src/gromacs/gmxpreprocess/topshake.h @@ -41,8 +41,8 @@ #include "gromacs/utility/arrayref.h" struct t_atoms; -struct InteractionTypeParameters; +struct InteractionsOfType; -void make_shake (gmx::ArrayRef plist, t_atoms *atoms, int nshake); +void make_shake (gmx::ArrayRef plist, t_atoms *atoms, int nshake); #endif diff --git a/src/gromacs/gmxpreprocess/toputil.cpp b/src/gromacs/gmxpreprocess/toputil.cpp index 8a1dd69412..92aa543fcc 100644 --- a/src/gromacs/gmxpreprocess/toputil.cpp +++ b/src/gromacs/gmxpreprocess/toputil.cpp @@ -57,7 +57,7 @@ /* UTILITIES */ -void add_param_to_list(InteractionTypeParameters *list, const InteractionType &b) +void add_param_to_list(InteractionsOfType *list, const InteractionOfType &b) { list->interactionTypes.emplace_back(b); } @@ -65,7 +65,7 @@ void add_param_to_list(InteractionTypeParameters *list, const InteractionType &b /* PRINTING STRUCTURES */ static void print_bt(FILE *out, Directive d, PreprocessingAtomTypes *at, - int ftype, int fsubtype, gmx::ArrayRef plist, + int ftype, int fsubtype, gmx::ArrayRef plist, bool bFullDih) { /* This dihp is a DIRTY patch because the dih-types do not use @@ -75,7 +75,7 @@ static void print_bt(FILE *out, Directive d, PreprocessingAtomTypes *at, int nral, nrfp; bool bDih = false, bSwapParity; - const InteractionTypeParameters *bt = &(plist[ftype]); + const InteractionsOfType *bt = &(plist[ftype]); if (bt->size() == 0) { @@ -386,7 +386,7 @@ void print_atoms(FILE *out, PreprocessingAtomTypes *atype, t_atoms *at, int *cgn } void print_bondeds(FILE *out, int natoms, Directive d, - int ftype, int fsubtype, gmx::ArrayRef plist) + int ftype, int fsubtype, gmx::ArrayRef plist) { t_symtab stab; t_atom *a; @@ -398,7 +398,7 @@ void print_bondeds(FILE *out, int natoms, Directive d, { char buf[12]; sprintf(buf, "%4d", (i+1)); - atype.addType(&stab, *a, buf, InteractionType({}, {}), 0, 0); + atype.addType(&stab, *a, buf, InteractionOfType({}, {}), 0, 0); } print_bt(out, d, &atype, ftype, fsubtype, plist, TRUE); diff --git a/src/gromacs/gmxpreprocess/toputil.h b/src/gromacs/gmxpreprocess/toputil.h index 1c04e64704..beca74c6e9 100644 --- a/src/gromacs/gmxpreprocess/toputil.h +++ b/src/gromacs/gmxpreprocess/toputil.h @@ -50,14 +50,14 @@ struct t_atoms; struct t_blocka; struct t_excls; struct MoleculeInformation; -class InteractionType; -struct InteractionTypeParameters; +class InteractionOfType; +struct InteractionsOfType; /* UTILITIES */ int name2index(char *str, char ***typenames, int ntypes); -void add_param_to_list(InteractionTypeParameters *list, const InteractionType &b); +void add_param_to_list(InteractionsOfType *list, const InteractionOfType &b); @@ -70,7 +70,7 @@ void print_atoms(FILE *out, PreprocessingAtomTypes *atype, t_atoms *at, int *cgn bool bRTPresname); void print_bondeds(FILE *out, int natoms, Directive d, - int ftype, int fsubtype, gmx::ArrayRef plist); + int ftype, int fsubtype, gmx::ArrayRef plist); void print_excl(FILE *out, int natoms, t_excls excls[]); diff --git a/src/gromacs/gmxpreprocess/vsite_parm.cpp b/src/gromacs/gmxpreprocess/vsite_parm.cpp index b20cf08008..0a3c2ccbb0 100644 --- a/src/gromacs/gmxpreprocess/vsite_parm.cpp +++ b/src/gromacs/gmxpreprocess/vsite_parm.cpp @@ -62,6 +62,7 @@ #include "gromacs/utility/smalloc.h" #include "gromacs/utility/strconvert.h" +#include "hackblock.h" #include "resall.h" typedef struct { @@ -75,11 +76,11 @@ typedef struct { struct VsiteBondParameter { - VsiteBondParameter(int ftype, const InteractionType &type) - : ftype_(ftype), type_(type) + VsiteBondParameter(int ftype, const InteractionOfType &vsiteInteraction) + : ftype_(ftype), vsiteInteraction_(vsiteInteraction) {} - int ftype_; - const InteractionType &type_; + int ftype_; + const InteractionOfType &vsiteInteraction_; }; struct Atom2VsiteBond @@ -109,7 +110,7 @@ static int vsite_bond_nrcheck(int ftype) } static void enter_bonded(int nratoms, int *nrbonded, t_mybonded **bondeds, - const InteractionType &type) + const InteractionOfType &type) { srenew(*bondeds, *nrbonded+1); @@ -136,9 +137,9 @@ static void get_bondeds(int nrat, gmx::ArrayRef atoms, { for (auto &vsite : at2vb[atoms[k]].vSiteBondedParameters) { - int ftype = vsite.ftype_; - const InteractionType &type = vsite.type_; - int nrcheck = vsite_bond_nrcheck(ftype); + int ftype = vsite.ftype_; + const InteractionOfType &type = vsite.vsiteInteraction_; + int nrcheck = vsite_bond_nrcheck(ftype); /* abuse nrcheck to see if we're adding bond, angle or idih */ switch (nrcheck) { @@ -151,7 +152,7 @@ static void get_bondeds(int nrat, gmx::ArrayRef atoms, } static std::vector -make_at2vsitebond(int natoms, gmx::ArrayRef plist) +make_at2vsitebond(int natoms, gmx::ArrayRef plist) { bool *bVSI; @@ -197,7 +198,7 @@ make_at2vsitebond(int natoms, gmx::ArrayRef plist) } static std::vector -make_at2vsitecon(int natoms, gmx::ArrayRef plist) +make_at2vsitecon(int natoms, gmx::ArrayRef plist) { std::vector bVSI(natoms); std::vector at2vc(natoms); @@ -278,7 +279,7 @@ static void print_bad(FILE *fp, } } -static void printInteractionType(FILE *fp, int ftype, int i, const InteractionType &type) +static void printInteractionOfType(FILE *fp, int ftype, int i, const InteractionOfType &type) { static int pass = 0; static int prev_ftype = NOTSET; @@ -362,7 +363,7 @@ static const char *get_atomtype_name_AB(t_atom *atom, PreprocessingAtomTypes *at } static bool calc_vsite3_param(PreprocessingAtomTypes *atypes, - InteractionType *param, t_atoms *at, + InteractionOfType *param, t_atoms *at, int nrbond, t_mybonded *bonds, int nrang, t_mybonded *angles ) { @@ -440,7 +441,7 @@ static bool calc_vsite3_param(PreprocessingAtomTypes *atypes, return bError; } -static bool calc_vsite3fd_param(InteractionType *param, +static bool calc_vsite3fd_param(InteractionOfType *param, int nrbond, t_mybonded *bonds, int nrang, t_mybonded *angles) { @@ -468,7 +469,7 @@ static bool calc_vsite3fd_param(InteractionType *param, return bError; } -static bool calc_vsite3fad_param(InteractionType *param, +static bool calc_vsite3fad_param(InteractionOfType *param, int nrbond, t_mybonded *bonds, int nrang, t_mybonded *angles) { @@ -499,7 +500,7 @@ static bool calc_vsite3fad_param(InteractionType *param, } static bool calc_vsite3out_param(PreprocessingAtomTypes *atypes, - InteractionType *param, t_atoms *at, + InteractionOfType *param, t_atoms *at, int nrbond, t_mybonded *bonds, int nrang, t_mybonded *angles) { @@ -595,7 +596,7 @@ static bool calc_vsite3out_param(PreprocessingAtomTypes *atypes, return bError; } -static bool calc_vsite4fd_param(InteractionType *param, +static bool calc_vsite4fd_param(InteractionOfType *param, int nrbond, t_mybonded *bonds, int nrang, t_mybonded *angles) { @@ -652,7 +653,7 @@ static bool calc_vsite4fd_param(InteractionType *param, static bool -calc_vsite4fdn_param(InteractionType *param, +calc_vsite4fdn_param(InteractionOfType *param, int nrbond, t_mybonded *bonds, int nrang, t_mybonded *angles) { @@ -710,7 +711,7 @@ calc_vsite4fdn_param(InteractionType *param, int set_vsites(bool bVerbose, t_atoms *atoms, PreprocessingAtomTypes *atypes, - gmx::ArrayRef plist) + gmx::ArrayRef plist) { int ftype; int nvsite, nrbond, nrang, nridih, nrset; @@ -752,7 +753,7 @@ int set_vsites(bool bVerbose, t_atoms *atoms, PreprocessingAtomTypes *atypes, if (debug) { fprintf(debug, "bSet=%s ", gmx::boolToString(bSet)); - printInteractionType(debug, ftype, i, plist[ftype].interactionTypes[i]); + printInteractionOfType(debug, ftype, i, plist[ftype].interactionTypes[i]); } if (!bSet) { @@ -872,11 +873,35 @@ void set_vsites_ptype(bool bVerbose, gmx_moltype_t *molt) } -typedef struct { - int ftype, parnr; -} t_pindex; +/*! \brief + * Convenience typedef for linking function type to parameter numbers. + * + * The entries in this datastructure are valid if the particle participates in + * a virtual site interaction and has a valid vsite function type other than VSITEN. + * \todo Change to remove empty constructor when gmx::compat::optional is available. + */ +class VsiteAtomMapping +{ + public: + //! Only construct with all information in place or nothing + VsiteAtomMapping(int functionType, int interactionIndex) + : functionType_(functionType), interactionIndex_(interactionIndex) + {} + VsiteAtomMapping() + : functionType_(-1), interactionIndex_(-1) + {} + //! Get function type. + const int &functionType() const { return functionType_; } + //! Get parameter number. + const int &interactionIndex() const { return interactionIndex_; }; + private: + //! Function type for the linked parameter. + int functionType_; + //! The linked parameter. + int interactionIndex_; +}; -static void check_vsite_constraints(gmx::ArrayRef plist, +static void check_vsite_constraints(gmx::ArrayRef plist, int cftype, const int vsite_type[]) { int n = 0; @@ -900,14 +925,15 @@ static void check_vsite_constraints(gmx::ArrayRef pli } } -static void clean_vsite_bonds(gmx::ArrayRef plist, t_pindex pindex[], +static void clean_vsite_bonds(gmx::ArrayRef plist, + gmx::ArrayRef pindex, int cftype, const int vsite_type[]) { int ftype, nOut; int nconverted, nremoved; int oatom, at1, at2; bool bKeep, bRemove, bAllFD; - InteractionTypeParameters *ps; + InteractionsOfType *ps; if (cftype == F_CONNBONDS) { @@ -936,18 +962,18 @@ static void clean_vsite_bonds(gmx::ArrayRef plist, t_ if (vsite_type[atom] != NOTSET && vsite_type[atom] != F_VSITEN) { nvsite++; - bool bThisFD = ( (pindex[atom].ftype == F_VSITE3FD ) || - (pindex[atom].ftype == F_VSITE3FAD) || - (pindex[atom].ftype == F_VSITE4FD ) || - (pindex[atom].ftype == F_VSITE4FDN ) ); - bool bThisOUT = ( (pindex[atom].ftype == F_VSITE3OUT) && + bool bThisFD = ( (pindex[atom].functionType() == F_VSITE3FD ) || + (pindex[atom].functionType() == F_VSITE3FAD) || + (pindex[atom].functionType() == F_VSITE4FD ) || + (pindex[atom].functionType() == F_VSITE4FDN ) ); + bool bThisOUT = ( (pindex[atom].functionType() == F_VSITE3OUT) && ((interaction_function[cftype].flags & IF_CONSTRAINT) != 0u) ); bAllFD = bAllFD && bThisFD; if (bThisFD || bThisOUT) { oatom = atoms[1-k]; /* the other atom */ if (vsite_type[oatom] == NOTSET && - oatom == plist[pindex[atom].ftype].interactionTypes[pindex[atom].parnr].aj()) + oatom == plist[pindex[atom].functionType()].interactionTypes[pindex[atom].interactionIndex()].aj()) { /* if the other atom isn't a vsite, and it is AI */ bRemove = true; @@ -969,8 +995,8 @@ static void clean_vsite_bonds(gmx::ArrayRef plist, t_ /* TODO This would be nicer to implement with a C++ "vector view" class" with an STL-container-like interface. */ - vsnral = NRAL(pindex[atom].ftype) - 1; - first_atoms = plist[pindex[atom].ftype].interactionTypes[pindex[atom].parnr].atoms().data() + 1; + vsnral = NRAL(pindex[atom].functionType()) - 1; + first_atoms = plist[pindex[atom].functionType()].interactionTypes[pindex[atom].interactionIndex()].atoms().data() + 1; } else { @@ -978,14 +1004,14 @@ static void clean_vsite_bonds(gmx::ArrayRef plist, t_ GMX_ASSERT(first_atoms != nullptr, "nvsite > 1 must have first_atoms != NULL"); /* if it is not the first then check if this vsite is constructed from the same atoms */ - if (vsnral == NRAL(pindex[atom].ftype)-1) + if (vsnral == NRAL(pindex[atom].functionType())-1) { for (int m = 0; (m < vsnral) && !bKeep; m++) { const int *atoms; bool bPresent = false; - atoms = plist[pindex[atom].ftype].interactionTypes[pindex[atom].parnr].atoms().data() + 1; + atoms = plist[pindex[atom].functionType()].interactionTypes[pindex[atom].interactionIndex()].atoms().data() + 1; for (int n = 0; (n < vsnral) && !bPresent; n++) { if (atoms[m] == first_atoms[n]) @@ -1121,12 +1147,13 @@ static void clean_vsite_bonds(gmx::ArrayRef plist, t_ } } -static void clean_vsite_angles(gmx::ArrayRef plist, t_pindex pindex[], +static void clean_vsite_angles(gmx::ArrayRef plist, + gmx::ArrayRef pindex, int cftype, const int vsite_type[], gmx::ArrayRef at2vc) { int atom, at1, at2; - InteractionTypeParameters *ps; + InteractionsOfType *ps; ps = &(plist[cftype]); int oldSize = ps->size(); @@ -1146,26 +1173,26 @@ static void clean_vsite_angles(gmx::ArrayRef plist, t if (vsite_type[atom] != NOTSET && vsite_type[atom] != F_VSITEN) { nvsite++; - bAll3FAD = bAll3FAD && (pindex[atom].ftype == F_VSITE3FAD); + bAll3FAD = bAll3FAD && (pindex[atom].functionType() == F_VSITE3FAD); if (nvsite == 1) { /* store construction atoms of first vsite */ - vsnral = NRAL(pindex[atom].ftype) - 1; - first_atoms = plist[pindex[atom].ftype].interactionTypes[pindex[atom].parnr].atoms().data() + 1; + vsnral = NRAL(pindex[atom].functionType()) - 1; + first_atoms = plist[pindex[atom].functionType()].interactionTypes[pindex[atom].interactionIndex()].atoms().data() + 1; } else { GMX_ASSERT(vsnral != 0, "If we've seen a vsite before, we know how many constructing atoms it had"); GMX_ASSERT(first_atoms != nullptr, "If we've seen a vsite before, we know what its first atom index was"); /* check if this vsite is constructed from the same atoms */ - if (vsnral == NRAL(pindex[atom].ftype)-1) + if (vsnral == NRAL(pindex[atom].functionType())-1) { for (int m = 0; (m < vsnral) && !bKeep; m++) { const int *subAtoms; bool bPresent = false; - subAtoms = plist[pindex[atom].ftype].interactionTypes[pindex[atom].parnr].atoms().data() + 1; + subAtoms = plist[pindex[atom].functionType()].interactionTypes[pindex[atom].interactionIndex()].atoms().data() + 1; for (int n = 0; (n < vsnral) && !bPresent; n++) { if (subAtoms[m] == first_atoms[n]) @@ -1256,10 +1283,11 @@ static void clean_vsite_angles(gmx::ArrayRef plist, t } } -static void clean_vsite_dihs(gmx::ArrayRef plist, t_pindex pindex[], +static void clean_vsite_dihs(gmx::ArrayRef plist, + gmx::ArrayRef pindex, int cftype, const int vsite_type[]) { - InteractionTypeParameters *ps; + InteractionsOfType *ps; ps = &(plist[cftype]); @@ -1282,22 +1310,22 @@ static void clean_vsite_dihs(gmx::ArrayRef plist, t_p if (nvsite == 0) { /* store construction atoms of first vsite */ - vsnral = NRAL(pindex[atom].ftype) - 1; - first_atoms = plist[pindex[atom].ftype].interactionTypes[pindex[atom].parnr].atoms().data() + 1; + vsnral = NRAL(pindex[atom].functionType()) - 1; + first_atoms = plist[pindex[atom].functionType()].interactionTypes[pindex[atom].interactionIndex()].atoms().data() + 1; } else { GMX_ASSERT(vsnral != 0, "If we've seen a vsite before, we know how many constructing atoms it had"); GMX_ASSERT(first_atoms != nullptr, "If we've seen a vsite before, we know what its first atom index was"); /* check if this vsite is constructed from the same atoms */ - if (vsnral == NRAL(pindex[atom].ftype)-1) + if (vsnral == NRAL(pindex[atom].functionType())-1) { for (int m = 0; (m < vsnral) && !bKeep; m++) { const int *subAtoms; bool bPresent = false; - subAtoms = plist[pindex[atom].ftype].interactionTypes[pindex[atom].parnr].atoms().data() + 1; + subAtoms = plist[pindex[atom].functionType()].interactionTypes[pindex[atom].interactionIndex()].atoms().data() + 1; for (int n = 0; (n < vsnral) && !bPresent; n++) { if (subAtoms[m] == first_atoms[n]) @@ -1368,14 +1396,14 @@ static void clean_vsite_dihs(gmx::ArrayRef plist, t_p } } -void clean_vsite_bondeds(gmx::ArrayRef plist, int natoms, bool bRmVSiteBds) +// TODO use gmx::compat::optional for pindex. +void clean_vsite_bondeds(gmx::ArrayRef plist, int natoms, bool bRmVSiteBds) { - int nvsite, vsite; - int *vsite_type; - t_pindex *pindex; - std::vector at2vc; + int nvsite, vsite; + int *vsite_type; + std::vector pindex; + std::vector at2vc; - pindex = nullptr; /* avoid warnings */ /* make vsite_type array */ snew(vsite_type, natoms); for (int i = 0; i < natoms; i++) @@ -1424,7 +1452,7 @@ void clean_vsite_bondeds(gmx::ArrayRef plist, int nat /* Make a reverse list to avoid ninteractions^2 operations */ at2vc = make_at2vsitecon(natoms, plist); - snew(pindex, natoms); + pindex.resize(natoms); for (int ftype = 0; ftype < F_NRE; ftype++) { /* Here we skip VSITEN. In neary all practical use cases this @@ -1441,11 +1469,12 @@ void clean_vsite_bondeds(gmx::ArrayRef plist, int nat if ((interaction_function[ftype].flags & IF_VSITE) && ftype != F_VSITEN) { - for (int parnr = 0; (parnr < gmx::ssize(plist[ftype])); parnr++) + for (int interactionIndex = 0; + interactionIndex < gmx::ssize(plist[ftype]); + interactionIndex++) { - int k = plist[ftype].interactionTypes[parnr].ai(); - pindex[k].ftype = ftype; - pindex[k].parnr = parnr; + int k = plist[ftype].interactionTypes[interactionIndex].ai(); + pindex[k] = VsiteAtomMapping(ftype, interactionIndex); } } } @@ -1480,6 +1509,5 @@ void clean_vsite_bondeds(gmx::ArrayRef plist, int nat } } - sfree(pindex); sfree(vsite_type); } diff --git a/src/gromacs/gmxpreprocess/vsite_parm.h b/src/gromacs/gmxpreprocess/vsite_parm.h index ec383ac64c..0026edc91a 100644 --- a/src/gromacs/gmxpreprocess/vsite_parm.h +++ b/src/gromacs/gmxpreprocess/vsite_parm.h @@ -43,10 +43,10 @@ class PreprocessingAtomTypes; struct gmx_moltype_t; struct t_atoms; -struct InteractionTypeParameters; +struct InteractionsOfType; int set_vsites(bool bVerbose, t_atoms *atoms, PreprocessingAtomTypes *atype, - gmx::ArrayRef plist); + gmx::ArrayRef plist); /* set parameters for virtual sites, return number of virtual sites */ void set_vsites_ptype(bool bVerbose, gmx_moltype_t *molt); @@ -56,6 +56,6 @@ void set_vsites_ptype(bool bVerbose, gmx_moltype_t *molt); * * Throw away all obsolete bonds, angles and dihedrals. * Throw away all constraints. */ -void clean_vsite_bondeds(gmx::ArrayRef ps, int natoms, bool bRmVSiteBds); +void clean_vsite_bondeds(gmx::ArrayRef ps, int natoms, bool bRmVSiteBds); #endif diff --git a/src/gromacs/gmxpreprocess/x2top.cpp b/src/gromacs/gmxpreprocess/x2top.cpp index 35af9d383d..476eb7755e 100644 --- a/src/gromacs/gmxpreprocess/x2top.cpp +++ b/src/gromacs/gmxpreprocess/x2top.cpp @@ -94,7 +94,7 @@ static bool is_bond(int nnm, t_nm2type nmt[], char *ai, char *aj, real blen) } static void mk_bonds(int nnm, t_nm2type nmt[], - t_atoms *atoms, const rvec x[], InteractionTypeParameters *bond, int nbond[], + t_atoms *atoms, const rvec x[], InteractionsOfType *bond, int nbond[], bool bPBC, matrix box) { int i, j; @@ -131,7 +131,7 @@ static void mk_bonds(int nnm, t_nm2type nmt[], { forceParam[0] = std::sqrt(dx2); std::vector atoms = {i, j}; - add_param_to_list (bond, InteractionType(atoms, forceParam)); + add_param_to_list (bond, InteractionOfType(atoms, forceParam)); nbond[i]++; nbond[j]++; } @@ -171,7 +171,7 @@ static int *set_cgnr(t_atoms *atoms, bool bUsePDBcharge, real *qtot, real *mtot) static void set_atom_type(PreprocessingAtomTypes *atypes, t_symtab *tab, t_atoms *atoms, - InteractionTypeParameters *bonds, + InteractionsOfType *bonds, int *nbonds, int nnm, t_nm2type nm2t[]) @@ -190,7 +190,7 @@ static void set_atom_type(PreprocessingAtomTypes *atypes, atypes->size()); } -static void lo_set_force_const(InteractionTypeParameters *plist, real c[], int nrfp, bool bRound, +static void lo_set_force_const(InteractionsOfType *plist, real c[], int nrfp, bool bRound, bool bDih, bool bParam) { double cc; @@ -236,11 +236,11 @@ static void lo_set_force_const(InteractionTypeParameters *plist, real c[], int n forceParam[j] = c[j]; forceParam[nrfp+j] = c[j]; } - param = InteractionType(param.atoms(), forceParam); + param = InteractionOfType(param.atoms(), forceParam); } } -static void set_force_const(gmx::ArrayRef plist, real kb, real kt, real kp, bool bRound, +static void set_force_const(gmx::ArrayRef plist, real kb, real kt, real kp, bool bRound, bool bParam) { real c[MAXFORCEPARAM]; @@ -255,7 +255,7 @@ static void set_force_const(gmx::ArrayRef plist, real lo_set_force_const(&plist[F_PDIHS], c, 3, bRound, TRUE, bParam); } -static void calc_angles_dihs(InteractionTypeParameters *ang, InteractionTypeParameters *dih, const rvec x[], bool bPBC, +static void calc_angles_dihs(InteractionsOfType *ang, InteractionsOfType *dih, const rvec x[], bool bPBC, matrix box) { int t1, t2, t3; @@ -296,7 +296,7 @@ static void dump_hybridization(FILE *fp, t_atoms *atoms, int nbonds[]) } } -static void print_pl(FILE *fp, gmx::ArrayRef plist, int ftp, const char *name, +static void print_pl(FILE *fp, gmx::ArrayRef plist, int ftp, const char *name, char ***atomname) { if (!plist[ftp].interactionTypes.empty()) @@ -327,7 +327,7 @@ static void print_pl(FILE *fp, gmx::ArrayRef pl static void print_rtp(const char *filenm, const char *title, t_atoms *atoms, - gmx::ArrayRef plist, + gmx::ArrayRef plist, PreprocessingAtomTypes *atypes, int cgnr[]) { @@ -390,7 +390,7 @@ int gmx_x2top(int argc, char *argv[]) "The atoms to atomtype translation table is incomplete ([TT]atomname2type.n2t[tt] file in the data directory). Please extend it and send the results back to the GROMACS crew." }; FILE *fp; - std::array plist; + std::array plist; t_excls *excls; t_nextnb nnb; t_nm2type *nm2t; -- 2.22.0