{
int n, nmol, ftype;
gmx_mtop_ilistloop_t iloop;
- const InteractionList *il;
n = 0;
iloop = gmx_mtop_ilistloop_init(mtop);
- while (gmx_mtop_ilistloop_next(iloop, &il, &nmol))
+ while (const InteractionLists *il = gmx_mtop_ilistloop_next(iloop, &nmol))
{
for (ftype = 0; ftype < F_NRE; ftype++)
{
if ((interaction_function[ftype].flags & IF_BOND) &&
NRAL(ftype) > 2)
{
- n += nmol*il[ftype].size()/(1 + NRAL(ftype));
+ n += nmol*(*il)[ftype].size()/(1 + NRAL(ftype));
}
}
}
}
/*! \brief Run the reverse ilist generation and store it in r_il when \p bAssign = TRUE */
-static int low_make_reverse_ilist(const InteractionList *il_mt,
+static int low_make_reverse_ilist(const InteractionLists &il_mt,
const t_atom *atom,
gmx::ArrayRef < const std::vector < int>> vsitePbc,
int *count,
}
/*! \brief Make the reverse ilist: a list of bonded interactions linked to atoms */
-static int make_reverse_ilist(const InteractionList *ilist,
+static int make_reverse_ilist(const InteractionLists &ilist,
const t_atoms *atoms,
gmx::ArrayRef < const std::vector < int>> vsitePbc,
gmx_bool bConstr, gmx_bool bSettle,
GMX_RELEASE_ASSERT(mtop->intermolecular_ilist.get(), "We should have an ilist when intermolecular interactions are on");
*nint +=
- make_reverse_ilist(mtop->intermolecular_ilist->data(),
+ make_reverse_ilist(*mtop->intermolecular_ilist,
&atoms_global,
gmx::EmptyArrayRef(),
rt.bConstr, rt.bSettle, rt.bBCheck, FALSE,
GMX_RELEASE_ASSERT(mtop->intermolecular_ilist.get(), "We should have an ilist when intermolecular interactions are on");
- make_reverse_ilist(mtop->intermolecular_ilist->data(),
+ make_reverse_ilist(*mtop->intermolecular_ilist,
&atoms,
gmx::EmptyArrayRef(),
FALSE, FALSE, FALSE, TRUE, &ril_intermol);
}
/*! \brief Set the distance, function type and atom indices for the longest atom distance involved in intermolecular interactions for two-body and multi-body bonded interactions */
-static void bonded_distance_intermol(const InteractionList *ilists_intermol,
+static void bonded_distance_intermol(const InteractionLists &ilists_intermol,
gmx_bool bBCheck,
const rvec *x, int ePBC, const matrix box,
bonded_distance_t *bd_2b,
GMX_RELEASE_ASSERT(mtop->intermolecular_ilist.get(), "We should have an ilist when intermolecular interactions are on");
- bonded_distance_intermol(mtop->intermolecular_ilist->data(),
+ bonded_distance_intermol(*mtop->intermolecular_ilist,
bBCheck,
x, ir->ePBC, box,
&bd_2b, &bd_mb);
}
}
-static void do_ilists(t_fileio *fio, InteractionList *ilist, gmx_bool bRead,
+static void do_ilists(t_fileio *fio, InteractionLists *ilists, gmx_bool bRead,
int file_version)
{
- int j;
- gmx_bool bClear;
+ GMX_RELEASE_ASSERT(ilists, "Need a valid ilists object");
+ GMX_RELEASE_ASSERT(ilists->size() == F_NRE, "The code needs to be in sync with InteractionLists");
- for (j = 0; (j < F_NRE); j++)
+ for (int j = 0; j < F_NRE; j++)
{
- bClear = FALSE;
+ InteractionList &ilist = (*ilists)[j];
+ gmx_bool bClear = FALSE;
if (bRead)
{
for (int k = 0; k < NFTUPD; k++)
}
if (bClear)
{
- ilist[j].iatoms.clear();
+ ilist.iatoms.clear();
}
else
{
- do_ilist(fio, &ilist[j], bRead);
- if (file_version < 78 && j == F_SETTLE && ilist[j].size() > 0)
+ do_ilist(fio, &ilist, bRead);
+ if (file_version < 78 && j == F_SETTLE && ilist.size() > 0)
{
- add_settle_atoms(&ilist[j]);
+ add_settle_atoms(&ilist);
}
}
}
do_atoms(fio, &molt->atoms, bRead, symtab, file_version);
- do_ilists(fio, molt->ilist, bRead, file_version);
+ do_ilists(fio, &molt->ilist, bRead, file_version);
do_block(fio, &molt->cgs, bRead);
{
t_iparams *ip;
gmx_mtop_ilistloop_t iloop;
- const InteractionList *ilist;
int nmol;
ip = mtop->ffparams.iparams;
iloop = gmx_mtop_ilistloop_init(mtop);
- while (gmx_mtop_ilistloop_next(iloop, &ilist, &nmol))
+ while (const InteractionLists *ilist = gmx_mtop_ilistloop_next(iloop, &nmol))
{
- const InteractionList &il = ilist[F_DISRES];
+ const InteractionList &il = (*ilist)[F_DISRES];
if (il.size() > 0)
{
{
mtop->intermolecular_ilist = gmx::compat::make_unique<InteractionLists>();
}
- do_ilists(fio, mtop->intermolecular_ilist->data(), bRead, file_version);
+ do_ilists(fio, mtop->intermolecular_ilist.get(), bRead, file_version);
}
}
else
const gmx_moltype_t *w_moltype = nullptr;
for (const gmx_moltype_t &moltype : mtop->moltype)
{
- const t_atom *atom = moltype.atoms.atom;
- const InteractionList *ilist = moltype.ilist;
- const InteractionList *ilc = &ilist[F_CONSTR];
- const InteractionList *ils = &ilist[F_SETTLE];
+ const t_atom *atom = moltype.atoms.atom;
+ const InteractionLists &ilist = moltype.ilist;
+ const InteractionList *ilc = &ilist[F_CONSTR];
+ const InteractionList *ils = &ilist[F_SETTLE];
for (ftype = 0; ftype < F_NRE; ftype++)
{
if (!(ftype == F_BONDS || ftype == F_G96BONDS || ftype == F_HARMONIC))
{
int d, g, i;
gmx_mtop_ilistloop_t iloop;
- const InteractionList *ilist;
int nmol;
t_iparams *pr;
/* Check for position restraints */
iloop = gmx_mtop_ilistloop_init(sys);
- while (gmx_mtop_ilistloop_next(iloop, &ilist, &nmol))
+ while (const InteractionLists *ilist = gmx_mtop_ilistloop_next(iloop, &nmol))
{
if (nmol > 0 &&
(AbsRef[XX] == 0 || AbsRef[YY] == 0 || AbsRef[ZZ] == 0))
{
- for (i = 0; i < ilist[F_POSRES].size(); i += 2)
+ for (i = 0; i < (*ilist)[F_POSRES].size(); i += 2)
{
- pr = &sys->ffparams.iparams[ilist[F_POSRES].iatoms[i]];
+ pr = &sys->ffparams.iparams[(*ilist)[F_POSRES].iatoms[i]];
for (d = 0; d < DIM; d++)
{
if (pr->posres.fcA[d] != 0)
}
}
}
- for (i = 0; i < ilist[F_FBPOSRES].size(); i += 2)
+ for (i = 0; i < (*ilist)[F_FBPOSRES].size(); i += 2)
{
/* Check for flat-bottom posres */
- pr = &sys->ffparams.iparams[ilist[F_FBPOSRES].iatoms[i]];
+ pr = &sys->ffparams.iparams[(*ilist)[F_FBPOSRES].iatoms[i]];
if (pr->fbposres.k != 0)
{
switch (pr->fbposres.geom)
const gmx_multisim_t *ms,
t_fcdata *fcd, t_state *state, gmx_bool bIsREMD)
{
- int fa, nmol, npair, np;
- t_disresdata *dd;
- history_t *hist;
- gmx_mtop_ilistloop_t iloop;
- const InteractionList *il;
- char *ptr;
- int type_min, type_max;
+ int fa, nmol, npair, np;
+ t_disresdata *dd;
+ history_t *hist;
+ gmx_mtop_ilistloop_t iloop;
+ char *ptr;
+ int type_min, type_max;
dd = &(fcd->disres);
type_min = INT_MAX;
type_max = 0;
iloop = gmx_mtop_ilistloop_init(mtop);
- while (gmx_mtop_ilistloop_next(iloop, &il, &nmol))
+ while (const InteractionLists *il = gmx_mtop_ilistloop_next(iloop, &nmol))
{
- if (nmol > 1 && il[F_DISRES].size() > 0 && ir->eDisre != edrEnsemble)
+ if (nmol > 1 && (*il)[F_DISRES].size() > 0 && ir->eDisre != edrEnsemble)
{
gmx_fatal(FARGS, "NMR distance restraints with multiple copies of the same molecule are currently only supported with ensemble averaging. If you just want to restrain distances between atom pairs using a flat-bottomed potential, use a restraint potential (bonds type 10) instead.");
}
np = 0;
- for (fa = 0; fa < il[F_DISRES].size(); fa += 3)
+ for (fa = 0; fa < (*il)[F_DISRES].size(); fa += 3)
{
int type;
- type = il[F_DISRES].iatoms[fa];
+ type = (*il)[F_DISRES].iatoms[fa];
np++;
npair = mtop->ffparams.iparams[type].disres.npair;
int typeMin = INT_MAX;
int typeMax = 0;
gmx_mtop_ilistloop_t iloop = gmx_mtop_ilistloop_init(mtop);
- const InteractionList *il;
int nmol;
- while (gmx_mtop_ilistloop_next(iloop, &il, &nmol))
+ while (const InteractionLists *il = gmx_mtop_ilistloop_next(iloop, &nmol))
{
if (nmol > 1)
{
gmx_fatal(FARGS, "Found %d copies of a molecule with orientation restrains while the current code only supports a single copy. If you want to ensemble average, run multiple copies of the system using the multi-sim feature of mdrun.", nmol);
}
- for (int i = 0; i < il[F_ORIRES].size(); i += 3)
+ for (int i = 0; i < (*il)[F_ORIRES].size(); i += 3)
{
- int type = il[F_ORIRES].iatoms[i];
+ int type = (*il)[F_ORIRES].iatoms[i];
int ex = mtop->ffparams.iparams[type].orires.ex;
if (ex >= od->nex)
{
}
}
-static void bc_ilists(const t_commrec *cr, InteractionList *ilist)
+static void bc_ilists(const t_commrec *cr, InteractionLists *ilist)
{
int ftype;
{
for (ftype = 0; ftype < F_NRE; ftype++)
{
- if (ilist[ftype].size() > 0)
+ if ((*ilist)[ftype].size() > 0)
{
block_bc(cr, ftype);
- int nr = ilist[ftype].size();
+ int nr = (*ilist)[ftype].size();
block_bc(cr, nr);
- nblock_bc(cr, nr, ilist[ftype].iatoms.data());
+ nblock_bc(cr, nr, (*ilist)[ftype].iatoms.data());
}
}
ftype = -1;
{
for (ftype = 0; ftype < F_NRE; ftype++)
{
- ilist[ftype].iatoms.clear();
+ (*ilist)[ftype].iatoms.clear();
}
do
{
{
int nr;
block_bc(cr, nr);
- ilist[ftype].iatoms.resize(nr);
- nblock_bc(cr, nr, ilist[ftype].iatoms.data());
+ (*ilist)[ftype].iatoms.resize(nr);
+ nblock_bc(cr, nr, (*ilist)[ftype].iatoms.data());
}
}
while (ftype >= 0);
fprintf(debug, "after bc_atoms\n");
}
- bc_ilists(cr, moltype->ilist);
+ bc_ilists(cr, &moltype->ilist);
bc_block(cr, &moltype->cgs);
bc_blocka(cr, &moltype->excls);
}
if (mtop->bIntermolecularInteractions)
{
mtop->intermolecular_ilist = gmx::compat::make_unique<InteractionLists>();
- bc_ilists(cr, mtop->intermolecular_ilist->data());
+ bc_ilists(cr, mtop->intermolecular_ilist.get());
}
int nmolblock = mtop->molblock.size();
const t_iparams *iparams,
FlexibleConstraintTreatment flexibleConstraintTreatment)
{
- return makeAtomsToConstraintsList(moltype.atoms.nr, moltype.ilist, iparams, flexibleConstraintTreatment);
+ return makeAtomsToConstraintsList(moltype.atoms.nr, moltype.ilist.data(), iparams, flexibleConstraintTreatment);
}
//! Return the number of flexible constraints in the \c ilist and \c iparams.
for (const gmx_molblock_t &molblock : mtop.molblock)
{
int count =
- countFlexibleConstraintsTemplate(mtop.moltype[molblock.type].ilist,
+ countFlexibleConstraintsTemplate(mtop.moltype[molblock.type].ilist.data(),
mtop.ffparams.iparams);
nflexcon += molblock.nmol*count;
}
//! Recursing function to help find all adjacent constraints.
static void constr_recur(const t_blocka *at2con,
- const InteractionList *ilist, const t_iparams *iparams,
+ const InteractionLists &ilist, const t_iparams *iparams,
gmx_bool bTopB,
int at, int depth, int nc, int *path,
real r0, real r1, real *r2max,
}
//! Finds all triangles of atoms that share constraints to a central atom.
-static int count_triangle_constraints(const InteractionList *ilist,
- const t_blocka &at2con)
+static int count_triangle_constraints(const InteractionLists &ilist,
+ const t_blocka &at2con)
{
int ncon1, ncon_tot;
int c0, n1, c1, ac1, n2, c2;
}
//! Finds sequences of sequential constraints.
-static bool more_than_two_sequential_constraints(const InteractionList *ilist,
- const t_blocka &at2con)
+static bool more_than_two_sequential_constraints(const InteractionLists &ilist,
+ const t_blocka &at2con)
{
int ncon1, ncon_tot, c;
bool bMoreThanTwoSequentialConstraints;
/* Check that we have only one settle type */
int settle_type = -1;
gmx_mtop_ilistloop_t iloop = gmx_mtop_ilistloop_init(mtop);
- const InteractionList *ilist;
int nmol;
const int nral1 = 1 + NRAL(F_SETTLE);
- while (gmx_mtop_ilistloop_next(iloop, &ilist, &nmol))
+ while (const InteractionLists *ilists = gmx_mtop_ilistloop_next(iloop, &nmol))
{
- for (int i = 0; i < ilist[F_SETTLE].size(); i += nral1)
+ const InteractionList &ilist = (*ilists)[F_SETTLE];
+ for (int i = 0; i < ilist.size(); i += nral1)
{
if (settle_type == -1)
{
- settle_type = ilist[F_SETTLE].iatoms[i];
+ settle_type = ilist.iatoms[i];
}
- else if (ilist[F_SETTLE].iatoms[i] != settle_type)
+ else if (ilist.iatoms[i] != settle_type)
{
gmx_fatal(FARGS,
"The [molecules] section of your topology specifies more than one block of\n"
{
const gmx_molblock_t &molb = mtop.molblock[mb];
const gmx_moltype_t &molt = mtop.moltype[molb.type];
- if (vsiteIlistNrCount(molt.ilist) > 0)
+ if (vsiteIlistNrCount(molt.ilist.data()) > 0)
{
int atomOffset = mtop.moleculeBlockIndices[mb].globalAtomStart;
for (int mol = 0; mol < molb.nmol; mol++)
{
const gmx_moltype_t &molt = mtop.moltype[mt];
vsite->vsite_pbc_molt[mt] = get_vsite_pbc(mtop.ffparams.iparams,
- molt.ilist,
+ molt.ilist.data(),
molt.atoms.atom, nullptr,
molt.cgs);
}
void mk_graph_moltype(const gmx_moltype_t &moltype,
t_graph *g)
{
- mk_graph_ilist(nullptr, moltype.ilist, 0, moltype.atoms.nr,
+ mk_graph_ilist(nullptr, moltype.ilist.data(), 0, moltype.atoms.nr,
FALSE, FALSE,
g);
}
sfree(iloop);
}
-gmx_bool gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t iloop,
- const InteractionList **ilist_mol,
- int *nmol)
+const InteractionLists *
+gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t iloop,
+ int *nmol)
{
if (iloop == nullptr)
{
if (iloop->mblock == static_cast<int>(iloop->mtop->molblock.size()) &&
iloop->mtop->bIntermolecularInteractions)
{
- *ilist_mol = iloop->mtop->intermolecular_ilist->data();
*nmol = 1;
- return TRUE;
+ return iloop->mtop->intermolecular_ilist.get();
}
gmx_mtop_ilistloop_destroy(iloop);
- return FALSE;
+ return nullptr;
}
- *ilist_mol =
- iloop->mtop->moltype[iloop->mtop->molblock[iloop->mblock].type].ilist;
-
*nmol = iloop->mtop->molblock[iloop->mblock].nmol;
- return TRUE;
+ return
+ &iloop->mtop->moltype[iloop->mtop->molblock[iloop->mblock].type].ilist;
}
typedef struct gmx_mtop_ilistloop_all
{
sfree(iloop);
}
-gmx_bool gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop,
- const InteractionList **ilist_mol,
- int *atnr_offset)
+const InteractionLists *
+gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop,
+ int *atnr_offset)
{
if (iloop == nullptr)
if (iloop->mblock == iloop->mtop->molblock.size() &&
iloop->mtop->bIntermolecularInteractions)
{
- *ilist_mol = iloop->mtop->intermolecular_ilist->data();
*atnr_offset = 0;
- return TRUE;
+ return iloop->mtop->intermolecular_ilist.get();
}
gmx_mtop_ilistloop_all_destroy(iloop);
- return FALSE;
+ return nullptr;
}
}
- *ilist_mol =
- iloop->mtop->moltype[iloop->mtop->molblock[iloop->mblock].type].ilist;
-
*atnr_offset = iloop->a_offset;
- return TRUE;
+ return
+ &iloop->mtop->moltype[iloop->mtop->molblock[iloop->mblock].type].ilist;
}
int gmx_mtop_ftype_count(const gmx_mtop_t *mtop, int ftype)
{
gmx_mtop_ilistloop_t iloop;
- const InteractionList *il;
int n, nmol;
n = 0;
iloop = gmx_mtop_ilistloop_init(mtop);
- while (gmx_mtop_ilistloop_next(iloop, &il, &nmol))
+ while (const InteractionLists *il = gmx_mtop_ilistloop_next(iloop, &nmol))
{
- n += nmol*il[ftype].size()/(1+NRAL(ftype));
+ n += nmol*(*il)[ftype].size()/(1+NRAL(ftype));
}
if (mtop->bIntermolecularInteractions)
struct t_atom;
struct t_atoms;
struct t_block;
-struct InteractionList;
struct t_symtab;
// TODO All of the functions taking a const gmx_mtop * are deprecated
/* Loop to the next molecule,
* When not at the end:
- * returns TRUE and a pointer to the next array ilist_mol[F_NRE],
+ * returns a valid pointer to the next array ilist_mol[F_NRE],
* writes the number of molecules for this ilist in *nmol.
- * When at the end, destroys iloop and returns FALSE.
+ * When at the end, destroys iloop and returns nullptr.
*/
-gmx_bool
-gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t iloop,
- const InteractionList **ilist_mol,
- int *nmol);
+const InteractionLists *
+gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t iloop,
+ int *nmol);
/* Abstract type for ilist loop over all ilists of all molecules */
typedef struct gmx_mtop_ilistloop_all *gmx_mtop_ilistloop_all_t;
/* Loop to the next molecule,
* When not at the end:
- * returns TRUE and a pointer to the next array ilist_mol[F_NRE],
+ * returns a valid pointer to the next array ilist_mol[F_NRE],
* writes the atom offset which should be added to iatoms in atnr_offset.
- * When at the end, destroys iloop and returns FALSE.
+ * When at the end, destroys iloop and returns nullptr.
*/
-gmx_bool
+const InteractionLists *
gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop,
- const InteractionList **ilist_mol,
int *atnr_offset);
/*! \brief Default copy constructor */
gmx_moltype_t(const gmx_moltype_t &) = default;
- char **name; /**< Name of the molecule type */
- t_atoms atoms; /**< The atoms in this molecule */
- InteractionList ilist[F_NRE]; /**< Interaction list with local indices */
- t_block cgs; /**< The charge groups */
- t_blocka excls; /**< The exclusions */
-
- /* TODO: Change ilist to InteractionLists */
+ char **name; /**< Name of the molecule type */
+ t_atoms atoms; /**< The atoms in this molecule */
+ InteractionLists ilist; /**< Interaction list with local indices */
+ t_block cgs; /**< The charge groups */
+ t_blocka excls; /**< The exclusions */
};
/*! \brief Block of molecules of the same type, used in gmx_mtop_t */