{
for (int atomIndex = 0; atomIndex < atoms.nr; atomIndex++, i++)
{
- if (ggrpnr(&mtop->groups, gtype, i) != 0)
+ if (getGroupType(&mtop->groups, gtype, i) != 0)
{
return FALSE;
}
char *res_name;
int res_id;
- if (ggrpnr(&mtop->groups, egcCompressedX, i) != 0)
+ if (getGroupType(&mtop->groups, egcCompressedX, i) != 0)
{
continue;
}
int atom1, atom2;
atom1 = ilist->iatoms[l] + atom_offset;
atom2 = ilist->iatoms[l+1] + atom_offset;
- if (ggrpnr(&mtop->groups, egcCompressedX, atom1) == 0 &&
- ggrpnr(&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);
atom1 = ilist->iatoms[l] + atom_offset;
atom2 = ilist->iatoms[l+1] + atom_offset;
atom3 = ilist->iatoms[l+2] + atom_offset;
- if (ggrpnr(&mtop->groups, egcCompressedX, atom1) == 0)
+ if (getGroupType(&mtop->groups, egcCompressedX, atom1) == 0)
{
- if (ggrpnr(&mtop->groups, egcCompressedX, atom2) == 0)
+ if (getGroupType(&mtop->groups, egcCompressedX, atom2) == 0)
{
tng_molecule_bond_add(tng, mol, atom1,
atom2, &tngBond);
}
- if (ggrpnr(&mtop->groups, egcCompressedX, atom3) == 0)
+ if (getGroupType(&mtop->groups, egcCompressedX, atom3) == 0)
{
tng_molecule_bond_add(tng, mol, atom1,
atom3, &tngBond);
{
/* Get the energy group of the first atom in this charge group */
firstj = astart + molt->cgs.index[cg];
- firsteg = ggrpnr(&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 = ggrpnr(&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",
nrdf2[i] = 0;
if (atom->ptype == eptAtom || atom->ptype == eptNucleus)
{
- g = ggrpnr(groups, egcFREEZE, i);
+ g = getGroupType(groups, egcFREEZE, i);
for (d = 0; d < DIM; d++)
{
if (opts->nFreeze[g][d] == 0)
/* Add one DOF for particle i (counted as 2*1) */
nrdf2[i] += 2;
/* VCM group i has dim d as a DOF */
- dof_vcm[ggrpnr(groups, egcVCM, i)][d] = 1;
+ dof_vcm[getGroupType(groups, egcVCM, i)][d] = 1;
}
}
- nrdf_tc [ggrpnr(groups, egcTC, i)] += 0.5*nrdf2[i];
- nrdf_vcm[ggrpnr(groups, egcVCM, i)] += 0.5*nrdf2[i];
+ nrdf_tc [getGroupType(groups, egcTC, i)] += 0.5*nrdf2[i];
+ nrdf_vcm[getGroupType(groups, egcVCM, i)] += 0.5*nrdf2[i];
}
}
jmin = std::min(jmin, nrdf2[aj]);
nrdf2[ai] -= imin;
nrdf2[aj] -= jmin;
- nrdf_tc [ggrpnr(groups, egcTC, ai)] -= 0.5*imin;
- nrdf_tc [ggrpnr(groups, egcTC, aj)] -= 0.5*jmin;
- nrdf_vcm[ggrpnr(groups, egcVCM, ai)] -= 0.5*imin;
- nrdf_vcm[ggrpnr(groups, egcVCM, aj)] -= 0.5*jmin;
+ nrdf_tc [getGroupType(groups, egcTC, ai)] -= 0.5*imin;
+ nrdf_tc [getGroupType(groups, egcTC, aj)] -= 0.5*jmin;
+ nrdf_vcm[getGroupType(groups, egcVCM, ai)] -= 0.5*imin;
+ nrdf_vcm[getGroupType(groups, egcVCM, aj)] -= 0.5*jmin;
}
ia += interaction_function[ftype].nratoms+1;
i += interaction_function[ftype].nratoms+1;
ai = as + ia[1+j];
imin = std::min(2, nrdf2[ai]);
nrdf2[ai] -= imin;
- nrdf_tc [ggrpnr(groups, egcTC, ai)] -= 0.5*imin;
- nrdf_vcm[ggrpnr(groups, egcVCM, ai)] -= 0.5*imin;
+ nrdf_tc [getGroupType(groups, egcTC, ai)] -= 0.5*imin;
+ nrdf_vcm[getGroupType(groups, egcVCM, ai)] -= 0.5*imin;
}
ia += 4;
i += 4;
{
/* Subtract 1/2 dof from each group */
ai = pgrp->ind[0];
- nrdf_tc [ggrpnr(groups, egcTC, ai)] -= 0.5*imin;
- nrdf_vcm[ggrpnr(groups, egcVCM, ai)] -= 0.5*imin;
- if (nrdf_tc[ggrpnr(groups, egcTC, ai)] < 0)
+ nrdf_tc [getGroupType(groups, egcTC, ai)] -= 0.5*imin;
+ 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[ggrpnr(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
na_tot = 0;
for (ai = 0; ai < natoms; ai++)
{
- if (ggrpnr(groups, egcTC, ai) == i)
+ if (getGroupType(groups, egcTC, ai) == i)
{
- na_vcm[ggrpnr(groups, egcVCM, ai)]++;
+ na_vcm[getGroupType(groups, egcVCM, ai)]++;
na_tot++;
}
}
const t_atom *atom;
while (gmx_mtop_atomloop_all_next(aloop, &i, &atom))
{
- mgrp[ggrpnr(&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++)
od->nref = 0;
for (int i = 0; i < mtop->natoms; i++)
{
- if (ggrpnr(&mtop->groups, egcORFIT, i) == 0)
+ if (getGroupType(&mtop->groups, egcORFIT, i) == 0)
{
od->nref++;
}
{
a0 = cgs->index[cg];
a1 = cgs->index[cg+1];
- if (ggrpnr(&mtop->groups, egcENER, a_offset+am+a0) !=
- ggrpnr(&mtop->groups, egcENER, a_offset +a0))
+ if (getGroupType(&mtop->groups, egcENER, a_offset+am+a0) !=
+ getGroupType(&mtop->groups, egcENER, a_offset +a0))
{
bId = FALSE;
}
a1 = cgs->index[cg+1];
/* Store the energy group in cginfo */
- gid = ggrpnr(&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 */
md->bVCMgrps = FALSE;
for (int i = 0; i < mtop.natoms; i++)
{
- if (ggrpnr(&mtop.groups, egcVCM, i) > 0)
+ if (getGroupType(&mtop.groups, egcVCM, i) > 0)
{
md->bVCMgrps = TRUE;
}
if (md->cFREEZE)
{
- md->cFREEZE[i] = ggrpnr(groups, egcFREEZE, ag);
+ md->cFREEZE[i] = getGroupType(groups, egcFREEZE, ag);
}
if (EI_ENERGY_MINIMIZATION(ir->eI))
{
{
md->cTC[i] = groups->grpnr[egcTC][ag];
}
- md->cENER[i] = ggrpnr(groups, egcENER, ag);
+ md->cENER[i] = getGroupType(groups, egcENER, ag);
if (md->cACC)
{
md->cACC[i] = groups->grpnr[egcACC][ag];
}
if (md->cORF)
{
- md->cORF[i] = ggrpnr(groups, egcORFIT, ag);
+ md->cORF[i] = getGroupType(groups, egcORFIT, ag);
}
if (md->cU1)
of->natoms_x_compressed = 0;
for (i = 0; (i < top_global->natoms); i++)
{
- if (ggrpnr(of->groups, egcCompressedX, i) == 0)
+ if (getGroupType(of->groups, egcCompressedX, i) == 0)
{
of->natoms_x_compressed++;
}
snew(xxtc, of->natoms_x_compressed);
for (i = 0, j = 0; (i < of->natoms_global); i++)
{
- if (ggrpnr(of->groups, egcCompressedX, i) == 0)
+ if (getGroupType(of->groups, egcCompressedX, i) == 0)
{
copy_rvec(state_global->x[i], xxtc[j++]);
}
qm_max += 1000;
srenew(qm_arr, qm_max);
}
- if (ggrpnr(groups, egcQMMM, i) == j)
+ if (getGroupType(groups, egcQMMM, i) == j)
{
/* hack for tip4p */
qm_arr[qm_nr++] = i;
vsite = a_offset + iatoms[k+1]; /* the vsite */
ai = a_offset + iatoms[k+2]; /* constructing atom */
aj = a_offset + iatoms[k+3]; /* constructing atom */
- if (ggrpnr(groups, egcQMMM, vsite) == ggrpnr(groups, egcQMMM, ai)
+ if (getGroupType(groups, egcQMMM, vsite) == getGroupType(groups, egcQMMM, ai)
&&
- ggrpnr(groups, egcQMMM, vsite) == ggrpnr(groups, egcQMMM, aj))
+ getGroupType(groups, egcQMMM, vsite) == getGroupType(groups, egcQMMM, aj))
{
/* this dummy link atom needs to be removed from the qm_arr
* before making the QMrec of this layer!
aloop = gmx_mtop_atomloop_all_init(mtop);
while (gmx_mtop_atomloop_all_next(aloop, &i, &atom))
{
- grp = ggrpnr(groups, egcACC, i);
+ grp = getGroupType(groups, egcACC, i);
if ((grp < 0) && (grp >= ngacc))
{
gmx_incons("Input for acceleration groups wrong");
for (int d = 0; d < DIM; d++)
{
if (pulldim_con[d] == 1 &&
- ir->opts.nFreeze[ggrpnr(groups, egcFREEZE, ii)][d])
+ ir->opts.nFreeze[getGroupType(groups, egcFREEZE, ii)][d])
{
nfrozen++;
}
{
for (j = 0; (j < egcNR); j++)
{
- gcount[j][ggrpnr(groups, j, i)]++;
+ gcount[j][getGroupType(groups, j, i)]++;
}
}
printf("Group statistics\n");
void cmp_groups(FILE *fp, const gmx_groups_t *g0, const gmx_groups_t *g1,
int natoms0, int natoms1)
{
- int i, j;
char buf[32];
fprintf(fp, "comparing groups\n");
- for (i = 0; i < egcNR; i++)
+ 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)
{
- for (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,
if (g0->ngrpnr[i] == g1->ngrpnr[i] && natoms0 == natoms1 &&
(g0->grpnr[i] != nullptr || g1->grpnr[i] != nullptr))
{
- for (j = 0; j < natoms0; j++)
+ for (int j = 0; j < natoms0; j++)
{
- cmp_int(fp, gtypes[i], j, ggrpnr(g0, i, j), ggrpnr(g1, i, j));
+ cmp_int(fp, gtypes[i], j, getGroupType(g0, i, j), getGroupType(g1, i, j));
}
}
}
* so we can skip the grpname list comparison.
*/
}
+
+int getGroupType(const gmx_groups_t *group, int type, int atom)
+{
+ return (group->grpnr[type] ? group->grpnr[type][atom] : 0);
+}
#include "gromacs/topology/idef.h"
#include "gromacs/topology/symtab.h"
-enum {
+enum
+{
egcTC, egcENER, egcACC, egcFREEZE,
egcUser1, egcUser2, egcVCM, egcCompressedX,
egcORFIT, egcQMMM,
unsigned char *grpnr[egcNR]; /* Group numbers or NULL */
} gmx_groups_t;
-/* This macro gives the group number of group type egc for atom i.
- * This macro is useful, since the grpnr pointers are NULL
- * for group types that have all entries 0.
+/*! \brief
+ * Returns group number of an input group for a given atom.
+ *
+ * Returns the group \p type for \p atom in \p group, or 0 if the
+ * entries for all atoms in the group are 0 and the pointer is thus null.
+ *
+ * \param[in] group Group to check.
+ * \param[in] type Type of group to check.
+ * \param[in] atom Atom to check if it has an entry.
*/
-#define ggrpnr(groups, egc, i) ((groups)->grpnr[egc] ? (groups)->grpnr[egc][i] : 0)
+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.