Use more const references in topology code
authorPaul Bauer <paul.bauer.q@gmail.com>
Thu, 6 Dec 2018 10:09:56 +0000 (11:09 +0100)
committerChristian Blau <cblau@gwdg.de>
Mon, 10 Dec 2018 16:32:24 +0000 (17:32 +0100)
Change-Id: I8fd2e443c0c5cf1ca19714efd175b8e7132dbe2c

14 files changed:
src/gromacs/fileio/tngio.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/listed-forces/orires.cpp
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/mdatoms.cpp
src/gromacs/mdlib/mdoutf.cpp
src/gromacs/mdlib/qmmm.cpp
src/gromacs/mdlib/tgroup.cpp
src/gromacs/pulling/pull.cpp
src/gromacs/tools/check.cpp
src/gromacs/tools/dump.cpp
src/gromacs/topology/topology.cpp
src/gromacs/topology/topology.h

index b69f38b7fb797536f2e54c2ffc2cd2db0b40b3ed..ee1b2d2e7aa74c0730370b9696b53f512ab33e13 100644 (file)
@@ -588,7 +588,7 @@ static gmx_bool all_atoms_selected(const gmx_mtop_t *mtop,
         {
             for (int atomIndex = 0; atomIndex < atoms.nr; atomIndex++, i++)
             {
-                if (getGroupType(&mtop->groups, gtype, i) != 0)
+                if (getGroupType(mtop->groups, gtype, i) != 0)
                 {
                     return FALSE;
                 }
@@ -664,7 +664,7 @@ static void add_selection_groups(gmx_tng_trajectory_t  gmx_tng,
                 char *res_name;
                 int   res_id;
 
-                if (getGroupType(&mtop->groups, egcCompressedX, i) != 0)
+                if (getGroupType(mtop->groups, egcCompressedX, i) != 0)
                 {
                     continue;
                 }
@@ -707,8 +707,8 @@ static void add_selection_groups(gmx_tng_trajectory_t  gmx_tng,
                             int atom1, atom2;
                             atom1 = ilist.iatoms[l] + atom_offset;
                             atom2 = ilist.iatoms[l + 1] + atom_offset;
-                            if (getGroupType(&mtop->groups, egcCompressedX, atom1) == 0 &&
-                                getGroupType(&mtop->groups, egcCompressedX, atom2) == 0)
+                            if (getGroupType(mtop->groups, egcCompressedX, atom1) == 0 &&
+                                getGroupType(mtop->groups, egcCompressedX, atom2) == 0)
                             {
                                 tng_molecule_bond_add(tng, mol, ilist.iatoms[l],
                                                       ilist.iatoms[l + 1], &tngBond);
@@ -724,14 +724,14 @@ static void add_selection_groups(gmx_tng_trajectory_t  gmx_tng,
                     atom1 = ilist.iatoms[l] + atom_offset;
                     atom2 = ilist.iatoms[l + 1] + atom_offset;
                     atom3 = ilist.iatoms[l + 2] + atom_offset;
-                    if (getGroupType(&mtop->groups, egcCompressedX, atom1) == 0)
+                    if (getGroupType(mtop->groups, egcCompressedX, atom1) == 0)
                     {
-                        if (getGroupType(&mtop->groups, egcCompressedX, atom2) == 0)
+                        if (getGroupType(mtop->groups, egcCompressedX, atom2) == 0)
                         {
                             tng_molecule_bond_add(tng, mol, atom1,
                                                   atom2, &tngBond);
                         }
-                        if (getGroupType(&mtop->groups, egcCompressedX, atom3) == 0)
+                        if (getGroupType(mtop->groups, egcCompressedX, atom3) == 0)
                         {
                             tng_molecule_bond_add(tng, mol, atom1,
                                                   atom3, &tngBond);
index 2485d5a2e222325751ade6e26cf086dd1c903ca9..970ae5c1402faae5ddc0f521e3a7827c82cccb86 100644 (file)
@@ -180,10 +180,10 @@ static void check_eg_vs_cg(gmx_mtop_t *mtop)
             {
                 /* Get the energy group of the first atom in this charge group */
                 firstj  = astart + molt->cgs.index[cg];
-                firsteg = getGroupType(&mtop->groups, egcENER, firstj);
+                firsteg = getGroupType(mtop->groups, egcENER, firstj);
                 for (j = molt->cgs.index[cg]+1; j < molt->cgs.index[cg+1]; j++)
                 {
-                    eg = getGroupType(&mtop->groups, egcENER, astart+j);
+                    eg = getGroupType(mtop->groups, egcENER, astart+j);
                     if (eg != firsteg)
                     {
                         gmx_fatal(FARGS, "atoms %d and %d in charge group %d of molecule type '%s' are in different energy groups",
index d0df5b43234ab3b5b19f0c7543bb8c52f6cd5be5..9d59e2f4d94758b1701b50b7e17bb101182273c5 100644 (file)
@@ -2760,7 +2760,6 @@ static bool do_numbering(int natoms, gmx_groups_t *groups,
 static void calc_nrdf(const gmx_mtop_t *mtop, t_inputrec *ir, char **gnames)
 {
     t_grpopts              *opts;
-    const gmx_groups_t     *groups;
     pull_params_t          *pull;
     int                     natoms, ai, aj, i, j, d, g, imin, jmin;
     int                    *nrdf2, *na_vcm, na_tot;
@@ -2778,24 +2777,24 @@ static void calc_nrdf(const gmx_mtop_t *mtop, t_inputrec *ir, char **gnames)
 
     opts = &ir->opts;
 
-    groups = &mtop->groups;
+    const gmx_groups_t &groups = mtop->groups;
     natoms = mtop->natoms;
 
     /* Allocate one more for a possible rest group */
     /* We need to sum degrees of freedom into doubles,
      * since floats give too low nrdf's above 3 million atoms.
      */
-    snew(nrdf_tc, groups->grps[egcTC].nr+1);
-    snew(nrdf_vcm, groups->grps[egcVCM].nr+1);
-    snew(dof_vcm, groups->grps[egcVCM].nr+1);
-    snew(na_vcm, groups->grps[egcVCM].nr+1);
-    snew(nrdf_vcm_sub, groups->grps[egcVCM].nr+1);
+    snew(nrdf_tc, groups.grps[egcTC].nr+1);
+    snew(nrdf_vcm, groups.grps[egcVCM].nr+1);
+    snew(dof_vcm, groups.grps[egcVCM].nr+1);
+    snew(na_vcm, groups.grps[egcVCM].nr+1);
+    snew(nrdf_vcm_sub, groups.grps[egcVCM].nr+1);
 
-    for (i = 0; i < groups->grps[egcTC].nr; i++)
+    for (i = 0; i < groups.grps[egcTC].nr; i++)
     {
         nrdf_tc[i] = 0;
     }
-    for (i = 0; i < groups->grps[egcVCM].nr+1; i++)
+    for (i = 0; i < groups.grps[egcVCM].nr+1; i++)
     {
         nrdf_vcm[i]     = 0;
         clear_ivec(dof_vcm[i]);
@@ -2932,7 +2931,7 @@ static void calc_nrdf(const gmx_mtop_t *mtop, t_inputrec *ir, char **gnames)
                     nrdf_vcm[getGroupType(groups, egcVCM, ai)] -= 0.5*imin;
                     if (nrdf_tc[getGroupType(groups, egcTC, ai)] < 0)
                     {
-                        gmx_fatal(FARGS, "Center of mass pulling constraints caused the number of degrees of freedom for temperature coupling group %s to be negative", gnames[groups->grps[egcTC].nm_ind[getGroupType(groups, egcTC, ai)]]);
+                        gmx_fatal(FARGS, "Center of mass pulling constraints caused the number of degrees of freedom for temperature coupling group %s to be negative", gnames[groups.grps[egcTC].nm_ind[getGroupType(groups, egcTC, ai)]]);
                     }
                 }
                 else
@@ -2955,7 +2954,7 @@ static void calc_nrdf(const gmx_mtop_t *mtop, t_inputrec *ir, char **gnames)
          * the number of degrees of freedom in each vcm group when COM
          * translation is removed and 6 when rotation is removed as well.
          */
-        for (j = 0; j < groups->grps[egcVCM].nr+1; j++)
+        for (j = 0; j < groups.grps[egcVCM].nr+1; j++)
         {
             switch (ir->comm_mode)
             {
@@ -2978,10 +2977,10 @@ static void calc_nrdf(const gmx_mtop_t *mtop, t_inputrec *ir, char **gnames)
             }
         }
 
-        for (i = 0; i < groups->grps[egcTC].nr; i++)
+        for (i = 0; i < groups.grps[egcTC].nr; i++)
         {
             /* Count the number of atoms of TC group i for every VCM group */
-            for (j = 0; j < groups->grps[egcVCM].nr+1; j++)
+            for (j = 0; j < groups.grps[egcVCM].nr+1; j++)
             {
                 na_vcm[j] = 0;
             }
@@ -2999,7 +2998,7 @@ static void calc_nrdf(const gmx_mtop_t *mtop, t_inputrec *ir, char **gnames)
              */
             nrdf_uc    = nrdf_tc[i];
             nrdf_tc[i] = 0;
-            for (j = 0; j < groups->grps[egcVCM].nr+1; j++)
+            for (j = 0; j < groups.grps[egcVCM].nr+1; j++)
             {
                 if (nrdf_vcm[j] > nrdf_vcm_sub[j])
                 {
@@ -3009,7 +3008,7 @@ static void calc_nrdf(const gmx_mtop_t *mtop, t_inputrec *ir, char **gnames)
             }
         }
     }
-    for (i = 0; (i < groups->grps[egcTC].nr); i++)
+    for (i = 0; (i < groups.grps[egcTC].nr); i++)
     {
         opts->nrdf[i] = nrdf_tc[i];
         if (opts->nrdf[i] < 0)
@@ -3018,7 +3017,7 @@ static void calc_nrdf(const gmx_mtop_t *mtop, t_inputrec *ir, char **gnames)
         }
         fprintf(stderr,
                 "Number of degrees of freedom in T-Coupling group %s is %.2f\n",
-                gnames[groups->grps[egcTC].nm_ind[i]], opts->nrdf[i]);
+                gnames[groups.grps[egcTC].nm_ind[i]], opts->nrdf[i]);
     }
 
     sfree(nrdf2);
@@ -4147,7 +4146,7 @@ void triple_check(const char *mdparin, t_inputrec *ir, gmx_mtop_t *sys,
         const t_atom *atom;
         while (gmx_mtop_atomloop_all_next(aloop, &i, &atom))
         {
-            mgrp[getGroupType(&sys->groups, egcACC, i)] += atom->m;
+            mgrp[getGroupType(sys->groups, egcACC, i)] += atom->m;
         }
         mt = 0.0;
         for (i = 0; (i < sys->groups.grps[egcACC].nr); i++)
index 93d1c5772977dcec939fb6381976f4bfaa2f1b44..786cdab1b913d4a724561c282857ed58ec925d76 100644 (file)
@@ -202,7 +202,7 @@ void init_orires(FILE                 *fplog,
     od->nref = 0;
     for (int i = 0; i < mtop->natoms; i++)
     {
-        if (getGroupType(&mtop->groups, egcORFIT, i) == 0)
+        if (getGroupType(mtop->groups, egcORFIT, i) == 0)
         {
             od->nref++;
         }
index 898ef8efb7809688f86766eca72320ab90bee242..fa66366e7e9f26f07344f8bb0898aa1cc2cbb200 100644 (file)
@@ -675,8 +675,8 @@ static cginfo_mb_t *init_cginfo_mb(FILE *fplog, const gmx_mtop_t *mtop,
             {
                 a0 = cgs->index[cg];
                 a1 = cgs->index[cg+1];
-                if (getGroupType(&mtop->groups, egcENER, a_offset+am+a0) !=
-                    getGroupType(&mtop->groups, egcENER, a_offset   +a0))
+                if (getGroupType(mtop->groups, egcENER, a_offset+am+a0) !=
+                    getGroupType(mtop->groups, egcENER, a_offset   +a0))
                 {
                     bId = FALSE;
                 }
@@ -732,7 +732,7 @@ static cginfo_mb_t *init_cginfo_mb(FILE *fplog, const gmx_mtop_t *mtop,
                 a1 = cgs->index[cg+1];
 
                 /* Store the energy group in cginfo */
-                gid = getGroupType(&mtop->groups, egcENER, a_offset+am+a0);
+                gid = getGroupType(mtop->groups, egcENER, a_offset+am+a0);
                 SET_CGINFO_GID(cginfo[cgm+cg], gid);
 
                 /* Check the intra/inter charge group exclusions */
index 10a6359521792c896ad79016d812f400cd7777e6..6c015cc6eaae22cf7e20491c93e50f6be6339ee3 100644 (file)
@@ -129,7 +129,7 @@ makeMDAtoms(FILE *fp, const gmx_mtop_t &mtop, const t_inputrec &ir,
     md->bVCMgrps = FALSE;
     for (int i = 0; i < mtop.natoms; i++)
     {
-        if (getGroupType(&mtop.groups, egcVCM, i) > 0)
+        if (getGroupType(mtop.groups, egcVCM, i) > 0)
         {
             md->bVCMgrps = TRUE;
         }
@@ -207,16 +207,15 @@ void atoms2md(const gmx_mtop_t *mtop, const t_inputrec *ir,
 {
     gmx_bool              bLJPME;
     const t_grpopts      *opts;
-    const gmx_groups_t   *groups;
     int                   nthreads gmx_unused;
 
     bLJPME = EVDW_PME(ir->vdwtype);
 
     opts = &ir->opts;
 
-    groups = &mtop->groups;
+    const gmx_groups_t &groups = mtop->groups;
 
-    auto md = mdAtoms->mdatoms();
+    auto                md = mdAtoms->mdatoms();
     /* nindex>=0 indicates DD where we use an index */
     if (nindex >= 0)
     {
@@ -369,7 +368,7 @@ void atoms2md(const gmx_mtop_t *mtop, const t_inputrec *ir,
                 else
                 {
                     /* The friction coefficient is mass/tau_t */
-                    fac = ir->delta_t/opts->tau_t[md->cTC ? groups->grpnr[egcTC][ag] : 0];
+                    fac = ir->delta_t/opts->tau_t[md->cTC ? groups.grpnr[egcTC][ag] : 0];
                     mA  = 0.5*atom.m*fac;
                     mB  = 0.5*atom.mB*fac;
                 }
@@ -466,16 +465,16 @@ void atoms2md(const gmx_mtop_t *mtop, const t_inputrec *ir,
             md->ptype[i]    = atom.ptype;
             if (md->cTC)
             {
-                md->cTC[i]    = groups->grpnr[egcTC][ag];
+                md->cTC[i]    = groups.grpnr[egcTC][ag];
             }
             md->cENER[i]    = getGroupType(groups, egcENER, ag);
             if (md->cACC)
             {
-                md->cACC[i]   = groups->grpnr[egcACC][ag];
+                md->cACC[i]   = groups.grpnr[egcACC][ag];
             }
             if (md->cVCM)
             {
-                md->cVCM[i]       = groups->grpnr[egcVCM][ag];
+                md->cVCM[i]       = groups.grpnr[egcVCM][ag];
             }
             if (md->cORF)
             {
@@ -484,17 +483,17 @@ void atoms2md(const gmx_mtop_t *mtop, const t_inputrec *ir,
 
             if (md->cU1)
             {
-                md->cU1[i]        = groups->grpnr[egcUser1][ag];
+                md->cU1[i]        = groups.grpnr[egcUser1][ag];
             }
             if (md->cU2)
             {
-                md->cU2[i]        = groups->grpnr[egcUser2][ag];
+                md->cU2[i]        = groups.grpnr[egcUser2][ag];
             }
 
             if (ir->bQMMM)
             {
-                if (groups->grpnr[egcQMMM] == nullptr ||
-                    groups->grpnr[egcQMMM][ag] < groups->grps[egcQMMM].nr-1)
+                if (groups.grpnr[egcQMMM] == nullptr ||
+                    groups.grpnr[egcQMMM][ag] < groups.grps[egcQMMM].nr-1)
                 {
                     md->bQM[i]      = TRUE;
                 }
index 2e4286624a8bc9fb98928c5b9be4919d63bc3499..6ecf24a2e260208fc36ca046738dc693d346eaeb 100644 (file)
@@ -209,7 +209,7 @@ gmx_mdoutf_t init_mdoutf(FILE *fplog, int nfile, const t_filenm fnm[],
         of->natoms_x_compressed = 0;
         for (i = 0; (i < top_global->natoms); i++)
         {
-            if (getGroupType(of->groups, egcCompressedX, i) == 0)
+            if (getGroupType(*of->groups, egcCompressedX, i) == 0)
             {
                 of->natoms_x_compressed++;
             }
@@ -361,7 +361,7 @@ void mdoutf_write_to_trajectory_files(FILE *fplog, const t_commrec *cr,
                 auto x = makeArrayRef(state_global->x);
                 for (i = 0, j = 0; (i < of->natoms_global); i++)
                 {
-                    if (getGroupType(of->groups, egcCompressedX, i) == 0)
+                    if (getGroupType(*of->groups, egcCompressedX, i) == 0)
                     {
                         copy_rvec(x[i], xxtc[j++]);
                     }
index a0081e6fe2b28e6a313b3b97807f62608cfc76b9..0b751cc86ca8e52eb89690946e73733812a884dd 100644 (file)
@@ -420,7 +420,7 @@ void init_QMMMrec(const t_commrec  *cr,
         qr->nrQMlayers = 1;
     }
 
-    const gmx_groups_t *groups = &mtop->groups;
+    const gmx_groups_t &groups = mtop->groups;
 
     /* there are jmax groups of QM atoms. In case of multiple QM groups
      * I assume that the users wants to do ONIOM. However, maybe it
index e52e74c137518f39241d8f138c7b27d33c2d39ab..fdae985a973050a5fc05da4a4d14a423fba75bef 100644 (file)
@@ -71,14 +71,13 @@ static void init_grptcstat(int ngtc, t_grp_tcstat tcstat[])
 
 static void init_grpstat(const gmx_mtop_t *mtop, int ngacc, t_grp_acc gstat[])
 {
-    const gmx_groups_t     *groups;
     gmx_mtop_atomloop_all_t aloop;
     int                     i, grp;
     const t_atom           *atom;
 
     if (ngacc > 0)
     {
-        groups = &mtop->groups;
+        const gmx_groups_t &groups = mtop->groups;
         aloop  = gmx_mtop_atomloop_all_init(mtop);
         while (gmx_mtop_atomloop_all_next(aloop, &i, &atom))
         {
index 3824b23df9d3276ba182e371ed79d89d068df93b..1f9722efc9dc5953a8c00d9665e634316e51bdf8 100644 (file)
@@ -1715,7 +1715,7 @@ static void init_pull_group_index(FILE *fplog, const t_commrec *cr,
     /* In parallel, store we need to extract localWeights from weights at DD time */
     std::vector<real>  &weights = ((cr && PAR(cr)) ? pg->globalWeights : pg->localWeights);
 
-    const gmx_groups_t *groups  = &mtop->groups;
+    const gmx_groups_t &groups  = mtop->groups;
 
     /* Count frozen dimensions and (weighted) mass */
     int    nfrozen = 0;
@@ -1771,13 +1771,13 @@ static void init_pull_group_index(FILE *fplog, const t_commrec *cr,
             }
             else
             {
-                if (groups->grpnr[egcTC] == nullptr)
+                if (groups.grpnr[egcTC] == nullptr)
                 {
                     mbd = ir->delta_t/ir->opts.tau_t[0];
                 }
                 else
                 {
-                    mbd = ir->delta_t/ir->opts.tau_t[groups->grpnr[egcTC][ii]];
+                    mbd = ir->delta_t/ir->opts.tau_t[groups.grpnr[egcTC][ii]];
                 }
             }
             w                   *= m/mbd;
index 67b273e4188d5c48f6a9a39105cb5e26c3f16237..47ff776549039294f7df7f87ccc08ddaa462a6cf 100644 (file)
@@ -118,8 +118,8 @@ static void comp_tpx(const char *fn1, const char *fn2,
         top[0] = gmx_mtop_t_to_t_topology(&mtop[0], false);
         top[1] = gmx_mtop_t_to_t_topology(&mtop[1], false);
         cmp_top(stdout, &top[0], &top[1], ftol, abstol);
-        cmp_groups(stdout, &mtop[0].groups, &mtop[1].groups,
-                   mtop[0].natoms, mtop[1].natoms);
+        compareAtomGroups(stdout, mtop[0].groups, mtop[1].groups,
+                          mtop[0].natoms, mtop[1].natoms);
         comp_state(&state[0], &state[1], bRMSD, ftol, abstol);
     }
     else
index 24a67a3d6a6058cd7288be9d5a4da14088892c7a..117d094a989775510f5ca106a2262bd31e5fdcc0 100644 (file)
@@ -85,7 +85,6 @@ static void list_tpx(const char *fn,
     t_state       state;
     t_tpxheader   tpx;
     gmx_mtop_t    mtop;
-    gmx_groups_t *groups;
     t_topology    top;
 
     read_tpxheader(fn, &tpx, TRUE);
@@ -144,12 +143,12 @@ static void list_tpx(const char *fn,
             pr_rvecs(stdout, indent, "v", tpx.bV ? state.v.rvec_array() : nullptr, state.natoms);
         }
 
-        groups = &mtop.groups;
+        const gmx_groups_t &groups = mtop.groups;
 
         snew(gcount, egcNR);
         for (i = 0; (i < egcNR); i++)
         {
-            snew(gcount[i], groups->grps[i].nr);
+            snew(gcount[i], groups.grps[i].nr);
         }
 
         for (i = 0; (i < mtop.natoms); i++)
@@ -164,7 +163,7 @@ static void list_tpx(const char *fn,
         {
             atot = 0;
             printf("%-12s: ", gtypes[i]);
-            for (j = 0; (j < groups->grps[i].nr); j++)
+            for (j = 0; (j < groups.grps[i].nr); j++)
             {
                 printf("  %5d", gcount[i][j]);
                 atot += gcount[i][j];
index 2dc6509752b9d215b46567d08bab98f232a5657d..9e2caf22daa9e6a5f49b932ca3853c617c343798 100644 (file)
@@ -599,30 +599,28 @@ void cmp_top(FILE *fp, const t_topology *t1, const t_topology *t2, real ftol, re
     }
 }
 
-void cmp_groups(FILE *fp, const gmx_groups_t *g0, const gmx_groups_t *g1,
-                int natoms0, int natoms1)
+void compareAtomGroups(FILE *fp, const gmx_groups_t &g0, const gmx_groups_t &g1,
+                       int natoms0, int natoms1)
 {
-    char buf[32];
-
     fprintf(fp, "comparing groups\n");
 
     for (int i = 0; i < egcNR; i++)
     {
-        sprintf(buf, "grps[%d].nr", i);
-        cmp_int(fp, buf, -1, g0->grps[i].nr, g1->grps[i].nr);
-        if (g0->grps[i].nr == g1->grps[i].nr)
+        std::string buf = gmx::formatString("grps[%d].nr", i);
+        cmp_int(fp, buf.c_str(), -1, g0.grps[i].nr, g1.grps[i].nr);
+        if (g0.grps[i].nr == g1.grps[i].nr)
         {
-            for (int j = 0; j < g0->grps[i].nr; j++)
+            for (int j = 0; j < g0.grps[i].nr; j++)
             {
-                sprintf(buf, "grps[%d].name[%d]", i, j);
-                cmp_str(fp, buf, -1,
-                        *g0->grpname[g0->grps[i].nm_ind[j]],
-                        *g1->grpname[g1->grps[i].nm_ind[j]]);
+                buf = gmx::formatString("grps[%d].name[%d]", i, j);
+                cmp_str(fp, buf.c_str(), -1,
+                        *g0.grpname[g0.grps[i].nm_ind[j]],
+                        *g1.grpname[g1.grps[i].nm_ind[j]]);
             }
         }
-        cmp_int(fp, "ngrpnr", i, g0->ngrpnr[i], g1->ngrpnr[i]);
-        if (g0->ngrpnr[i] == g1->ngrpnr[i] && natoms0 == natoms1 &&
-            (g0->grpnr[i] != nullptr || g1->grpnr[i] != nullptr))
+        cmp_int(fp, "ngrpnr", i, g0.ngrpnr[i], g1.ngrpnr[i]);
+        if (g0.ngrpnr[i] == g1.ngrpnr[i] && natoms0 == natoms1 &&
+            (g0.grpnr[i] != nullptr || g1.grpnr[i] != nullptr))
         {
             for (int j = 0; j < natoms0; j++)
             {
@@ -635,9 +633,9 @@ void cmp_groups(FILE *fp, const gmx_groups_t *g0, const gmx_groups_t *g1,
      */
 }
 
-int getGroupType(const gmx_groups_t *group, int type, int atom)
+int getGroupType(const gmx_groups_t &group, int type, int atom)
 {
-    return (group->grpnr[type] ? group->grpnr[type][atom] : 0);
+    return (group.grpnr[type] ? group.grpnr[type][atom] : 0);
 }
 
 void copy_moltype(const gmx_moltype_t *src, gmx_moltype_t *dst)
index d958ffe750cbbd38a812e58f33e3e548c81dd804..8d46a12e9d80b107b8e5f95d96454343333aadb3 100644 (file)
@@ -118,7 +118,7 @@ typedef struct gmx_groups_t
  * \param[in] type  Type of group to check.
  * \param[in] atom  Atom to check if it has an entry.
  */
-int getGroupType (const gmx_groups_t *group, int type, int atom);
+int getGroupType (const gmx_groups_t &group, int type, int atom);
 
 /* The global, complete system topology struct, based on molecule types.
  * This structure should contain no data that is O(natoms) in memory.
@@ -226,8 +226,17 @@ void pr_top(FILE *fp, int indent, const char *title, const t_topology *top,
             gmx_bool bShowNumbers, gmx_bool bShowParameters);
 
 void cmp_top(FILE *fp, const t_topology *t1, const t_topology *t2, real ftol, real abstol);
-void cmp_groups(FILE *fp, const gmx_groups_t *g0, const gmx_groups_t *g1,
-                int natoms0, int natoms1);
+
+/*! \brief Compare groups.
+ *
+ * \param[in] fp File pointer to write to.
+ * \param[in] g0 First group for comparison.
+ * \param[in] g1 Second group for comparison.
+ * \param[in] natoms0 Number of atoms for first group.
+ * \param[in] natoms1 Number of atoms for second group.
+ */
+void compareAtomGroups(FILE *fp, const gmx_groups_t &g0, const gmx_groups_t &g1,
+                       int natoms0, int natoms1);
 
 //! Deleter for gmx_localtop_t, needed until it has a proper destructor.
 using ExpandedTopologyPtr = gmx::unique_cptr<gmx_localtop_t, done_and_sfree_localtop>;