Change gmx_moltype_t.ilist to InteractionLists
authorBerk Hess <hess@kth.se>
Thu, 13 Sep 2018 09:08:24 +0000 (11:08 +0200)
committerBerk Hess <hess@kth.se>
Fri, 14 Sep 2018 09:00:19 +0000 (11:00 +0200)
Also changed the mtop_util ilist loops to return a pointer
to InteractionLists.

Change-Id: I449176dcb2b7b73225c78308cf64da70cc88051b

17 files changed:
src/gromacs/domdec/domdec.cpp
src/gromacs/domdec/domdec_topology.cpp
src/gromacs/fileio/tpxio.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/listed-forces/disre.cpp
src/gromacs/listed-forces/orires.cpp
src/gromacs/mdlib/broadcaststructs.cpp
src/gromacs/mdlib/constr.cpp
src/gromacs/mdlib/constraintrange.cpp
src/gromacs/mdlib/lincs.cpp
src/gromacs/mdlib/settle.cpp
src/gromacs/mdlib/vsite.cpp
src/gromacs/pbcutil/mshift.cpp
src/gromacs/topology/mtop_util.cpp
src/gromacs/topology/mtop_util.h
src/gromacs/topology/topology.h

index d9f565e980518b6adbaef501206120910bed2966..d10b0dc4c40247d6f1cdbdfdb2561a0feb1009a0 100644 (file)
@@ -3229,18 +3229,17 @@ static int multi_body_bondeds_count(const gmx_mtop_t *mtop)
 {
     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));
             }
         }
     }
index 55498e12c42c3778f44b3ab4c92a40fb1ee08357..58d1a80b2d3f55a474158ae6b347897214f72a06 100644 (file)
@@ -493,7 +493,7 @@ static void count_excls(const t_block *cgs, const t_blocka *excls,
 }
 
 /*! \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,
@@ -597,7 +597,7 @@ static int low_make_reverse_ilist(const InteractionList *il_mt,
 }
 
 /*! \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,
@@ -701,7 +701,7 @@ static gmx_reverse_top_t make_reverse_top(const gmx_mtop_t *mtop, gmx_bool bFE,
         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,
@@ -2280,7 +2280,7 @@ t_blocka *make_charge_group_links(const gmx_mtop_t *mtop, gmx_domdec_t *dd,
 
         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);
@@ -2507,7 +2507,7 @@ static void bonded_cg_distance_mol(const gmx_moltype_t *molt,
 }
 
 /*! \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,
@@ -2701,7 +2701,7 @@ void dd_bonded_cg_distance(const gmx::MDLogger &mdlog,
 
         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);
index 364bddea2164afbd740d7645dd959b9383421fb7..59ea8d0ec0ba0d35d6e88ac8fef298c05d6fd26f 100644 (file)
@@ -2039,15 +2039,16 @@ static void add_settle_atoms(InteractionList *ilist)
     }
 }
 
-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++)
@@ -2060,14 +2061,14 @@ static void do_ilists(t_fileio *fio, InteractionList *ilist, gmx_bool bRead,
         }
         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);
             }
         }
     }
@@ -2409,7 +2410,7 @@ static void do_moltype(t_fileio *fio, gmx_moltype_t *molt, gmx_bool bRead,
 
     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);
 
@@ -2456,15 +2457,14 @@ static void set_disres_npair(gmx_mtop_t *mtop)
 {
     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)
         {
@@ -2529,7 +2529,7 @@ static void do_mtop(t_fileio *fio, gmx_mtop_t *mtop, gmx_bool bRead,
             {
                 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
index bd036ef254503c78214859446f6d1902e322005f..2d6c9edae9b18f839c1ce6184665dc9432911c5a 100644 (file)
@@ -264,10 +264,10 @@ static void check_bonds_timestep(const gmx_mtop_t *mtop, double dt, warninp_t wi
     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))
index 355b112447679f887af7936470de74a9e678ae0c..778ffce363294b1cdcf013917d13fdc7158b2217 100644 (file)
@@ -3720,7 +3720,6 @@ static bool absolute_reference(t_inputrec *ir, gmx_mtop_t *sys,
 {
     int                    d, g, i;
     gmx_mtop_ilistloop_t   iloop;
-    const InteractionList *ilist;
     int                    nmol;
     t_iparams             *pr;
 
@@ -3748,14 +3747,14 @@ static bool absolute_reference(t_inputrec *ir, gmx_mtop_t *sys,
 
     /* 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)
@@ -3764,10 +3763,10 @@ static bool absolute_reference(t_inputrec *ir, gmx_mtop_t *sys,
                     }
                 }
             }
-            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)
index d43cdb268b0393ab01678ef375353fa09e9b5fbd..408601c06a9b9f27e3d90e5039b8cf14bf81a328 100644 (file)
@@ -71,13 +71,12 @@ void init_disres(FILE *fplog, const gmx_mtop_t *mtop,
                  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);
 
@@ -130,19 +129,19 @@ void init_disres(FILE *fplog, const gmx_mtop_t *mtop,
     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;
index f76c52f1aeea50d549aadac3b25076af3e535f15..f33d2323dbf01256eead7e432e8737748f79b553 100644 (file)
@@ -112,18 +112,17 @@ void init_orires(FILE                 *fplog,
     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)
             {
index fb015cc9e3ada247ba89ca7cea68de2dfcea5342..460bce63f718cca1f6b5560e4522ee57e975d7d6 100644 (file)
@@ -309,7 +309,7 @@ void broadcastStateWithoutDynamics(const t_commrec *cr, t_state *state)
     }
 }
 
-static void bc_ilists(const t_commrec *cr, InteractionList *ilist)
+static void bc_ilists(const t_commrec *cr, InteractionLists *ilist)
 {
     int ftype;
 
@@ -318,12 +318,12 @@ static void bc_ilists(const t_commrec *cr, InteractionList *ilist)
     {
         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;
@@ -333,7 +333,7 @@ static void bc_ilists(const t_commrec *cr, InteractionList *ilist)
     {
         for (ftype = 0; ftype < F_NRE; ftype++)
         {
-            ilist[ftype].iatoms.clear();
+            (*ilist)[ftype].iatoms.clear();
         }
         do
         {
@@ -342,8 +342,8 @@ static void bc_ilists(const t_commrec *cr, InteractionList *ilist)
             {
                 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);
@@ -745,7 +745,7 @@ static void bc_moltype(const t_commrec *cr, t_symtab *symtab,
         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);
 }
@@ -820,7 +820,7 @@ void bcast_ir_mtop(const t_commrec *cr, t_inputrec *inputrec, gmx_mtop_t *mtop)
     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();
index 128e68fbcd86a9b36b00fd51c75da53a8a70dbb1..223aabae9b2854d1c05bcd1fa99eb17eb2d66400 100644 (file)
@@ -832,7 +832,7 @@ t_blocka make_at2con(const gmx_moltype_t         &moltype,
                      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.
@@ -1014,7 +1014,7 @@ Constraints::Impl::Impl(const gmx_mtop_t     &mtop_p,
         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;
         }
index 9e1931a8ba6c226913cf034cb3c31c1f85590b1a..7416f380e118c90b5e99bc34d88deaae3cfd6693 100644 (file)
@@ -58,7 +58,7 @@ namespace gmx
 
 //! 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,
index 85427ce1627d23f49a170044e706c77dff74bcd3..82deb3f66582163ae5c7138d489aa01d35c5f0cc 100644 (file)
@@ -1385,8 +1385,8 @@ static void set_lincs_matrix(Lincs *li, real *invmass, real lambda)
 }
 
 //! 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;
@@ -1447,8 +1447,8 @@ static int count_triangle_constraints(const InteractionList *ilist,
 }
 
 //! 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;
index 1d96943314e0d41009cbc0fde9aca144dbba1825..8bcbfd1008cf9e7399892eb26c259f0a1d9b2783 100644 (file)
@@ -183,18 +183,18 @@ settledata *settle_init(const gmx_mtop_t &mtop)
     /* 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"
index 476b137dfadebfbac57b26aa913ebdb87853dfaa..1f5f24578e0898f8cb53968c22ac88818322d7df 100644 (file)
@@ -765,7 +765,7 @@ void constructVsitesGlobal(const gmx_mtop_t         &mtop,
     {
         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++)
@@ -2063,7 +2063,7 @@ initVsite(const gmx_mtop_t &mtop,
         {
             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);
         }
index cc410c7452b77846585709af316a6645f8f274fb..1c5be20466d80244be9b2606cfbcc66b3275c631 100644 (file)
@@ -502,7 +502,7 @@ mk_graph_ilist(FILE *fplog,
 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);
 }
index 96e0ef919c8259369c0c6eeb840e8e5df904e542..45f8ba94d711533dfdde624550e21e6b4a868fb0 100644 (file)
@@ -398,9 +398,9 @@ static void gmx_mtop_ilistloop_destroy(gmx_mtop_ilistloop_t iloop)
     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)
     {
@@ -413,21 +413,18 @@ gmx_bool gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t    iloop,
         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
 {
@@ -457,9 +454,9 @@ static void gmx_mtop_ilistloop_all_destroy(gmx_mtop_ilistloop_all_t iloop)
     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)
@@ -488,36 +485,32 @@ gmx_bool gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t   iloop,
             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)
index d8d9bedc973c4e669289ab42611536a806d32291..587773d71d8cbf01417aeca7d4ba05b0dea8c833 100644 (file)
@@ -49,7 +49,6 @@ struct gmx_localtop_t;
 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
@@ -169,14 +168,13 @@ gmx_mtop_ilistloop_init(const gmx_mtop_t &mtop);
 
 /* 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;
@@ -191,13 +189,12 @@ gmx_mtop_ilistloop_all_init(const gmx_mtop_t *mtop);
 
 /* 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);
 
 
index f2b03b839fd0c15f013cb96273aaba61b6e5a0ca..5655e73d7a93f22ab901d7a42c57bf317e6f64fc 100644 (file)
@@ -71,13 +71,11 @@ struct gmx_moltype_t
     /*! \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 */