{
if (nwall > 0)
{
- t_grps *grps = &(groups->groups[SimulationAtomGroupType::EnergyOutput]);
- srenew(grps->nm_ind, grps->nr+nwall);
+ AtomGroupIndices *grps = &(groups->groups[SimulationAtomGroupType::EnergyOutput]);
for (int i = 0; i < nwall; i++)
{
groups->groupNames.emplace_back(
put_symtab(
symtab,
gmx::formatString("wall%d", i).c_str()));
- grps->nm_ind[grps->nr++] = groups->groupNames.size() - 1;
+ grps->emplace_back(groups->groupNames.size() - 1);
}
}
}
int grptp, bool bVerbose,
warninp_t wi)
{
- unsigned short *cbuf;
- t_grps *grps = &(groups->groups[gtype]);
- int j, gid, aj, ognr, ntot = 0;
- const char *title;
- bool bRest;
- char warn_buf[STRLEN];
+ unsigned short *cbuf;
+ AtomGroupIndices *grps = &(groups->groups[gtype]);
+ int j, gid, aj, ognr, ntot = 0;
+ const char *title;
+ bool bRest;
+ char warn_buf[STRLEN];
title = shortName(gtype);
cbuf[i] = NOGID;
}
- snew(grps->nm_ind, groupsFromMdpFile.size()+1); /* +1 for possible rest group */
for (int i = 0; i != groupsFromMdpFile.ssize(); ++i)
{
/* Lookup the group name in the block structure */
gid = search_string(groupsFromMdpFile[i].c_str(), block->nr, gnames);
if ((grptp != egrptpONE) || (i == 0))
{
- grps->nm_ind[grps->nr++] = gid;
+ grps->emplace_back(gid);
}
/* Now go over the atoms in the group */
{
if (cbuf[j] == NOGID)
{
- cbuf[j] = grps->nr;
+ cbuf[j] = grps->size();
bRest = TRUE;
}
}
title, natoms-ntot);
}
/* Add group name "rest" */
- grps->nm_ind[grps->nr] = restnm;
+ grps->emplace_back(restnm);
/* Assign the rest name to all atoms not currently assigned to a group */
for (j = 0; (j < natoms); j++)
{
if (cbuf[j] == NOGID)
{
- cbuf[j] = grps->nr;
+ // group size was not updated before this here, so need to use -1.
+ cbuf[j] = grps->size() - 1;
}
}
- grps->nr++;
}
}
- if (grps->nr == 1 && (ntot == 0 || ntot == natoms))
+ if (grps->size() == 1 && (ntot == 0 || ntot == natoms))
{
/* All atoms are part of one (or no) group, no index required */
groups->groupNumbers[gtype].clear();
/* We need to sum degrees of freedom into doubles,
* since floats give too low nrdf's above 3 million atoms.
*/
- snew(nrdf_tc, groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr+1);
- snew(nrdf_vcm, groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1);
- snew(dof_vcm, groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1);
- snew(na_vcm, groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1);
- snew(nrdf_vcm_sub, groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1);
+ snew(nrdf_tc, groups.groups[SimulationAtomGroupType::TemperatureCoupling].size()+1);
+ snew(nrdf_vcm, groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].size()+1);
+ snew(dof_vcm, groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].size()+1);
+ snew(na_vcm, groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].size()+1);
+ snew(nrdf_vcm_sub, groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].size()+1);
- for (int i = 0; i < groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr; i++)
+ for (int i = 0; i < gmx::ssize(groups.groups[SimulationAtomGroupType::TemperatureCoupling]); i++)
{
nrdf_tc[i] = 0;
}
- for (int i = 0; i < groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1; i++)
+ for (int i = 0; i < gmx::ssize(groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval])+1; i++)
{
nrdf_vcm[i] = 0;
clear_ivec(dof_vcm[i]);
nrdf_vcm[getGroupType(groups, SimulationAtomGroupType::MassCenterVelocityRemoval, ai)] -= 0.5*imin;
if (nrdf_tc[getGroupType(groups, SimulationAtomGroupType::TemperatureCoupling, 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.groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[getGroupType(groups, SimulationAtomGroupType::TemperatureCoupling, 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.groups[SimulationAtomGroupType::TemperatureCoupling][getGroupType(groups, SimulationAtomGroupType::TemperatureCoupling, ai)]]);
}
}
else
* the number of degrees of freedom in each vcm group when COM
* translation is removed and 6 when rotation is removed as well.
*/
- for (int j = 0; j < groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1; j++)
+ for (int j = 0; j < gmx::ssize(groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval])+1; j++)
{
switch (ir->comm_mode)
{
}
}
- for (int i = 0; i < groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr; i++)
+ for (int i = 0; i < gmx::ssize(groups.groups[SimulationAtomGroupType::TemperatureCoupling]); i++)
{
/* Count the number of atoms of TC group i for every VCM group */
- for (int j = 0; j < groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1; j++)
+ for (int j = 0; j < gmx::ssize(groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval])+1; j++)
{
na_vcm[j] = 0;
}
*/
nrdf_uc = nrdf_tc[i];
nrdf_tc[i] = 0;
- for (int j = 0; j < groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1; j++)
+ for (int j = 0; j < gmx::ssize(groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval])+1; j++)
{
if (nrdf_vcm[j] > nrdf_vcm_sub[j])
{
}
}
}
- for (int i = 0; (i < groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr); i++)
+ for (int i = 0; (i < gmx::ssize(groups.groups[SimulationAtomGroupType::TemperatureCoupling])); i++)
{
opts->nrdf[i] = nrdf_tc[i];
if (opts->nrdf[i] < 0)
}
fprintf(stderr,
"Number of degrees of freedom in T-Coupling group %s is %.2f\n",
- gnames[groups.groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i]], opts->nrdf[i]);
+ gnames[groups.groups[SimulationAtomGroupType::TemperatureCoupling][i]], opts->nrdf[i]);
}
sfree(nrdf2);
{
gmx_fatal(FARGS, "The number of groups for %s is odd", option);
}
- nr = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
+ nr = groups->groups[SimulationAtomGroupType::EnergyOutput].size();
bSet = FALSE;
for (size_t i = 0; i < names.size() / 2; i++)
{
// TODO this needs to be replaced by a solution using std::find_if
j = 0;
while ((j < nr) &&
- gmx_strcasecmp(names[2*i].c_str(), *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[j]])))
+ gmx_strcasecmp(names[2*i].c_str(), *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput][j]])))
{
j++;
}
}
k = 0;
while ((k < nr) &&
- gmx_strcasecmp(names[2*i+1].c_str(), *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[k]])))
+ gmx_strcasecmp(names[2*i+1].c_str(), *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput][k]])))
{
k++;
}
do_numbering(natoms, groups, temperatureCouplingGroupNames, defaultIndexGroups, gnames,
SimulationAtomGroupType::TemperatureCoupling,
restnm, useReferenceTemperature ? egrptpALL : egrptpALL_GENREST, bVerbose, wi);
- nr = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nr;
+ nr = groups->groups[SimulationAtomGroupType::TemperatureCoupling].size();
ir->opts.ngtc = nr;
snew(ir->opts.nrdf, nr);
snew(ir->opts.tau_t, nr);
{
if (ir->opts.annealing[i] != eannNO)
{
- j = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ j = groups->groups[SimulationAtomGroupType::TemperatureCoupling][i];
fprintf(stderr, "Simulated annealing for group %s: %s, %d timepoints\n",
*(groups->groupNames[j]), eann_names[ir->opts.annealing[i]],
ir->opts.anneal_npoints[i]);
do_numbering(natoms, groups, accelerationGroupNames, defaultIndexGroups, gnames,
SimulationAtomGroupType::Acceleration,
restnm, egrptpALL_GENREST, bVerbose, wi);
- nr = groups->groups[SimulationAtomGroupType::Acceleration].nr;
+ nr = groups->groups[SimulationAtomGroupType::Acceleration].size();
snew(ir->opts.acc, nr);
ir->opts.ngacc = nr;
do_numbering(natoms, groups, freezeGroupNames, defaultIndexGroups, gnames,
SimulationAtomGroupType::Freeze,
restnm, egrptpALL_GENREST, bVerbose, wi);
- nr = groups->groups[SimulationAtomGroupType::Freeze].nr;
+ nr = groups->groups[SimulationAtomGroupType::Freeze].size();
ir->opts.ngfrz = nr;
snew(ir->opts.nFreeze, nr);
for (i = k = 0; (size_t(i) < freezeGroupNames.size()); i++)
SimulationAtomGroupType::EnergyOutput,
restnm, egrptpALL_GENREST, bVerbose, wi);
add_wall_energrps(groups, ir->nwall, symtab);
- ir->opts.ngener = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
+ ir->opts.ngener = groups->groups[SimulationAtomGroupType::EnergyOutput].size();
auto vcmGroupNames = gmx::splitString(is->vcm);
bRest =
do_numbering(natoms, groups, vcmGroupNames, defaultIndexGroups, gnames,
{
for (auto group : gmx::keysOf(groups->groups))
{
- fprintf(stderr, "%-16s has %d element(s):", shortName(group), groups->groups[group].nr);
- for (int j = 0; (j < groups->groups[group].nr); j++)
+ fprintf(stderr, "%-16s has %zu element(s):", shortName(group), groups->groups[group].size());
+ for (const auto &entry : groups->groups[group])
{
- fprintf(stderr, " %s", *(groups->groupNames[groups->groups[group].nm_ind[j]]));
+ fprintf(stderr, " %s", *(groups->groupNames[entry]));
}
fprintf(stderr, "\n");
}
}
- nr = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
+ nr = groups->groups[SimulationAtomGroupType::EnergyOutput].size();
snew(ir->opts.egp_flags, nr*nr);
bExcl = do_egp_flag(ir, groups, "energygrp-excl", is->egpexcl, EGP_EXCL);
}
bAcc = FALSE;
- for (int i = 0; (i < sys->groups.groups[SimulationAtomGroupType::Acceleration].nr); i++)
+ for (int i = 0; (i < gmx::ssize(sys->groups.groups[SimulationAtomGroupType::Acceleration])); i++)
{
for (m = 0; (m < DIM); m++)
{
if (bAcc)
{
clear_rvec(acc);
- snew(mgrp, sys->groups.groups[SimulationAtomGroupType::Acceleration].nr);
+ snew(mgrp, sys->groups.groups[SimulationAtomGroupType::Acceleration].size());
for (const AtomProxy atomP : AtomRange(*sys))
{
const t_atom &local = atomP.atom();
mgrp[getGroupType(sys->groups, SimulationAtomGroupType::Acceleration, i)] += local.m;
}
mt = 0.0;
- for (i = 0; (i < sys->groups.groups[SimulationAtomGroupType::Acceleration].nr); i++)
+ for (i = 0; (i < gmx::ssize(sys->groups.groups[SimulationAtomGroupType::Acceleration])); i++)
{
for (m = 0; (m < DIM); m++)
{
if (ir->nstcomm != 0 && m < ndof_com(ir))
{
acc[m] /= mt;
- for (i = 0; (i < sys->groups.groups[SimulationAtomGroupType::Acceleration].nr); i++)
+ for (i = 0; (i < gmx::ssize(sys->groups.groups[SimulationAtomGroupType::Acceleration])); i++)
{
ir->opts.acc[i][m] -= acc[m];
}