From: Berk Hess Date: Thu, 13 Sep 2018 09:08:24 +0000 (+0200) Subject: Change gmx_moltype_t.ilist to InteractionLists X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=9e5656e3c6661ac27268eba38f81c574977a84f9;p=alexxy%2Fgromacs.git Change gmx_moltype_t.ilist to InteractionLists Also changed the mtop_util ilist loops to return a pointer to InteractionLists. Change-Id: I449176dcb2b7b73225c78308cf64da70cc88051b --- diff --git a/src/gromacs/domdec/domdec.cpp b/src/gromacs/domdec/domdec.cpp index d9f565e980..d10b0dc4c4 100644 --- a/src/gromacs/domdec/domdec.cpp +++ b/src/gromacs/domdec/domdec.cpp @@ -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)); } } } diff --git a/src/gromacs/domdec/domdec_topology.cpp b/src/gromacs/domdec/domdec_topology.cpp index 55498e12c4..58d1a80b2d 100644 --- a/src/gromacs/domdec/domdec_topology.cpp +++ b/src/gromacs/domdec/domdec_topology.cpp @@ -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); diff --git a/src/gromacs/fileio/tpxio.cpp b/src/gromacs/fileio/tpxio.cpp index 364bddea21..59ea8d0ec0 100644 --- a/src/gromacs/fileio/tpxio.cpp +++ b/src/gromacs/fileio/tpxio.cpp @@ -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(); } - do_ilists(fio, mtop->intermolecular_ilist->data(), bRead, file_version); + do_ilists(fio, mtop->intermolecular_ilist.get(), bRead, file_version); } } else diff --git a/src/gromacs/gmxpreprocess/grompp.cpp b/src/gromacs/gmxpreprocess/grompp.cpp index bd036ef254..2d6c9edae9 100644 --- a/src/gromacs/gmxpreprocess/grompp.cpp +++ b/src/gromacs/gmxpreprocess/grompp.cpp @@ -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)) diff --git a/src/gromacs/gmxpreprocess/readir.cpp b/src/gromacs/gmxpreprocess/readir.cpp index 355b112447..778ffce363 100644 --- a/src/gromacs/gmxpreprocess/readir.cpp +++ b/src/gromacs/gmxpreprocess/readir.cpp @@ -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) diff --git a/src/gromacs/listed-forces/disre.cpp b/src/gromacs/listed-forces/disre.cpp index d43cdb268b..408601c06a 100644 --- a/src/gromacs/listed-forces/disre.cpp +++ b/src/gromacs/listed-forces/disre.cpp @@ -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; diff --git a/src/gromacs/listed-forces/orires.cpp b/src/gromacs/listed-forces/orires.cpp index f76c52f1ae..f33d2323db 100644 --- a/src/gromacs/listed-forces/orires.cpp +++ b/src/gromacs/listed-forces/orires.cpp @@ -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) { diff --git a/src/gromacs/mdlib/broadcaststructs.cpp b/src/gromacs/mdlib/broadcaststructs.cpp index fb015cc9e3..460bce63f7 100644 --- a/src/gromacs/mdlib/broadcaststructs.cpp +++ b/src/gromacs/mdlib/broadcaststructs.cpp @@ -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(); - bc_ilists(cr, mtop->intermolecular_ilist->data()); + bc_ilists(cr, mtop->intermolecular_ilist.get()); } int nmolblock = mtop->molblock.size(); diff --git a/src/gromacs/mdlib/constr.cpp b/src/gromacs/mdlib/constr.cpp index 128e68fbcd..223aabae9b 100644 --- a/src/gromacs/mdlib/constr.cpp +++ b/src/gromacs/mdlib/constr.cpp @@ -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; } diff --git a/src/gromacs/mdlib/constraintrange.cpp b/src/gromacs/mdlib/constraintrange.cpp index 9e1931a8ba..7416f380e1 100644 --- a/src/gromacs/mdlib/constraintrange.cpp +++ b/src/gromacs/mdlib/constraintrange.cpp @@ -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, diff --git a/src/gromacs/mdlib/lincs.cpp b/src/gromacs/mdlib/lincs.cpp index 85427ce162..82deb3f665 100644 --- a/src/gromacs/mdlib/lincs.cpp +++ b/src/gromacs/mdlib/lincs.cpp @@ -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; diff --git a/src/gromacs/mdlib/settle.cpp b/src/gromacs/mdlib/settle.cpp index 1d96943314..8bcbfd1008 100644 --- a/src/gromacs/mdlib/settle.cpp +++ b/src/gromacs/mdlib/settle.cpp @@ -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" diff --git a/src/gromacs/mdlib/vsite.cpp b/src/gromacs/mdlib/vsite.cpp index 476b137dfa..1f5f24578e 100644 --- a/src/gromacs/mdlib/vsite.cpp +++ b/src/gromacs/mdlib/vsite.cpp @@ -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); } diff --git a/src/gromacs/pbcutil/mshift.cpp b/src/gromacs/pbcutil/mshift.cpp index cc410c7452..1c5be20466 100644 --- a/src/gromacs/pbcutil/mshift.cpp +++ b/src/gromacs/pbcutil/mshift.cpp @@ -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); } diff --git a/src/gromacs/topology/mtop_util.cpp b/src/gromacs/topology/mtop_util.cpp index 96e0ef919c..45f8ba94d7 100644 --- a/src/gromacs/topology/mtop_util.cpp +++ b/src/gromacs/topology/mtop_util.cpp @@ -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(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) diff --git a/src/gromacs/topology/mtop_util.h b/src/gromacs/topology/mtop_util.h index d8d9bedc97..587773d71d 100644 --- a/src/gromacs/topology/mtop_util.h +++ b/src/gromacs/topology/mtop_util.h @@ -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); diff --git a/src/gromacs/topology/topology.h b/src/gromacs/topology/topology.h index f2b03b839f..5655e73d7a 100644 --- a/src/gromacs/topology/topology.h +++ b/src/gromacs/topology/topology.h @@ -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 */