for (i = 0; i < state->ngtc; i++)
{
- ni = groups.groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ ni = groups.groups[SimulationAtomGroupType::TemperatureCoupling][i];
bufi = *(groups.groupNames[ni]);
for (j = 0; (j < state->nhchainlength); j++)
{
/* The name of the TNG molecule containing the selection group is the
* same as the name of the selection group. */
- nameIndex = *mtop->groups.groups[SimulationAtomGroupType::CompressedPositionOutput].nm_ind;
+ nameIndex = mtop->groups.groups[SimulationAtomGroupType::CompressedPositionOutput][0];
groupName = *mtop->groups.groupNames[nameIndex];
tng_molecule_alloc(tng, &mol);
}
}
-static void do_grps(t_fileio *fio,
- gmx::ArrayRef<t_grps> grps,
- gmx_bool bRead)
+static void do_grps(t_fileio *fio,
+ gmx::ArrayRef<AtomGroupIndices> grps,
+ gmx_bool bRead)
{
for (auto &group : grps)
{
- gmx_fio_do_int(fio, group.nr);
+ int size = group.size();
+ gmx_fio_do_int(fio, size);
if (bRead)
{
- snew(group.nm_ind, group.nr);
+ group.resize(size);
}
- gmx_fio_ndo_int(fio, group.nm_ind, group.nr);
+ gmx_fio_ndo_int(fio, group.data(), size);
}
}
{
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];
}
}
}
-static void bc_grps(const t_commrec *cr, gmx::ArrayRef<t_grps> grps)
+static void bc_grps(const t_commrec *cr, gmx::ArrayRef<AtomGroupIndices> grps)
{
for (auto &group : grps)
{
- block_bc(cr, group.nr);
- snew_bc(cr, group.nm_ind, group.nr);
- nblock_bc(cr, group.nr, group.nm_ind);
+ int size = group.size();
+ block_bc(cr, size);
+ nblock_abc(cr, size, &group);
}
}
md->nEc++;
}
}
- n = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
+ n = groups->groups[SimulationAtomGroupType::EnergyOutput].size();
md->nEg = n;
md->nE = (n*(n+1))/2;
{
snew(gnm[k], STRLEN);
}
- for (i = 0; (i < groups->groups[SimulationAtomGroupType::EnergyOutput].nr); i++)
+ for (i = 0; (i < gmx::ssize(groups->groups[SimulationAtomGroupType::EnergyOutput])); i++)
{
- ni = groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i];
- for (j = i; (j < groups->groups[SimulationAtomGroupType::EnergyOutput].nr); j++)
+ ni = groups->groups[SimulationAtomGroupType::EnergyOutput][i];
+ for (j = i; (j < gmx::ssize(groups->groups[SimulationAtomGroupType::EnergyOutput])); j++)
{
- nj = groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[j];
+ nj = groups->groups[SimulationAtomGroupType::EnergyOutput][j];
for (k = kk = 0; (k < egNR); k++)
{
if (md->bEInd[k])
}
}
- md->nTC = isRerun ? 0 : groups->groups[SimulationAtomGroupType::TemperatureCoupling].nr;
+ md->nTC = isRerun ? 0 : groups->groups[SimulationAtomGroupType::TemperatureCoupling].size();
md->nNHC = ir->opts.nhchainlength; /* shorthand for number of NH chains */
if (md->bMTTK)
{
for (i = 0; (i < md->nTC); i++)
{
- ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling][i];
sprintf(buf, "T-%s", *(groups->groupNames[ni]));
grpnms[i] = gmx_strdup(buf);
}
{
for (i = 0; (i < md->nTC); i++)
{
- ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling][i];
bufi = *(groups->groupNames[ni]);
for (j = 0; (j < md->nNHC); j++)
{
{
for (i = 0; (i < md->nTC); i++)
{
- ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling][i];
bufi = *(groups->groupNames[ni]);
sprintf(buf, "Xi-%s", bufi);
grpnms[2*i] = gmx_strdup(buf);
{
for (i = 0; (i < md->nTC); i++)
{
- ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling][i];
sprintf(buf, "Lamb-%s", *(groups->groupNames[ni]));
grpnms[i] = gmx_strdup(buf);
}
}
sfree(grpnms);
- md->nU = groups->groups[SimulationAtomGroupType::Acceleration].nr;
+ md->nU = groups->groups[SimulationAtomGroupType::Acceleration].size();
snew(md->tmp_v, md->nU);
if (md->nU > 1)
{
snew(grpnms, 3*md->nU);
for (i = 0; (i < md->nU); i++)
{
- ni = groups->groups[SimulationAtomGroupType::Acceleration].nm_ind[i];
+ ni = groups->groups[SimulationAtomGroupType::Acceleration][i];
sprintf(buf, "Ux-%s", *(groups->groupNames[ni]));
grpnms[3*i+XX] = gmx_strdup(buf);
sprintf(buf, "Uy-%s", *(groups->groupNames[ni]));
if (opts->annealing[i] != eannNO)
{
fprintf(log, "Current ref_t for group %s: %8.1f\n",
- *(groups->groupNames[groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i]]),
+ *(groups->groupNames[groups->groups[SimulationAtomGroupType::TemperatureCoupling][i]]),
opts->ref_t[i]);
}
}
n = 0;
for (i = 0; (i < md->nEg); i++)
{
- ni = groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i];
+ ni = groups->groups[SimulationAtomGroupType::EnergyOutput][i];
for (j = i; (j < md->nEg); j++)
{
- nj = groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[j];
+ nj = groups->groups[SimulationAtomGroupType::EnergyOutput][j];
sprintf(buf, "%s-%s", *(groups->groupNames[ni]),
*(groups->groupNames[nj]));
md->print_grpnms[n++] = gmx_strdup(buf);
"Group", "Ux", "Uy", "Uz");
for (i = 0; (i < md->nU); i++)
{
- ni = groups->groups[SimulationAtomGroupType::Acceleration].nm_ind[i];
+ ni = groups->groups[SimulationAtomGroupType::Acceleration][i];
fprintf(log, "%15s", *groups->groupNames[ni]);
pr_ebin(log, md->ebin, md->iu+3*i, 3, 3, mode, FALSE);
}
int cg0,
int nmol,
const unsigned char *qm_grpnr,
- const t_grps *qm_grps,
- t_forcerec * fr,
+ const AtomGroupIndices *qm_grps,
+ t_forcerec *fr,
int *n_solvent_parameters,
solvent_parameters_t **solvent_parameters_p,
int cginfo,
{
for (j = j0; j < j1 && !qm; j++)
{
- qm = (qm_grpnr[j] < qm_grps->nr - 1);
+ qm = (qm_grpnr[j] < qm_grps->size() - 1);
}
}
/* Cannot use solvent optimization with QM */
gmx_bool bGenericKernelOnly;
gmx_bool needGroupSchemeTables, bSomeNormalNbListsAreInUse;
gmx_bool bFEP_NonBonded;
- int *nm_ind, egp_flags;
+ int egp_flags;
/* By default we turn SIMD kernels on, but it might be turned off further down... */
if (negptable > 0)
{
/* Read the special tables for certain energy group pairs */
- nm_ind = mtop->groups.groups[SimulationAtomGroupType::EnergyOutput].nm_ind;
+ gmx::ArrayRef<const int> nm_ind = mtop->groups.groups[SimulationAtomGroupType::EnergyOutput];
for (egi = 0; egi < negp_pp; egi++)
{
for (egj = egi; egj < negp_pp; egj++)
/* Initialize the thread working data for bonded interactions */
fr->bondedThreading =
- init_bonded_threading(fp, mtop->groups.groups[SimulationAtomGroupType::EnergyOutput].nr);
+ init_bonded_threading(fp, mtop->groups.groups[SimulationAtomGroupType::EnergyOutput].size());
fr->nthread_ewc = gmx_omp_nthreads_get(emntBonded);
snew(fr->ewc_t, fr->nthread_ewc);
snew(md, 1);
mdAtoms->mdatoms_.reset(md);
- md->nenergrp = mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].nr;
+ md->nenergrp = mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].size();
md->bVCMgrps = FALSE;
for (int i = 0; i < mtop.natoms; i++)
{
if (ir->bQMMM)
{
if (groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics].empty() ||
- groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics][ag] < groups.groups[SimulationAtomGroupType::QuantumMechanics].nr-1)
+ groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics][ag] < groups.groups[SimulationAtomGroupType::QuantumMechanics].size()-1)
{
md->bQM[i] = TRUE;
}
for (i = 0; i < state->natoms; i++)
{
gid = groups->groupNumbers[SimulationAtomGroupType::Freeze][i];
- if (groups->groups[SimulationAtomGroupType::Freeze].nm_ind[gid] == ins_grp_id)
+ if (groups->groups[SimulationAtomGroupType::Freeze][gid] == ins_grp_id)
{
xmin = std::min(xmin, x[i][XX]);
xmax = std::max(xmax, x[i][XX]);
for (i = 0; i < inputrec->opts.ngfrz; i++)
{
- tmp_id = mtop->groups.groups[SimulationAtomGroupType::Freeze].nm_ind[i];
+ tmp_id = mtop->groups.groups[SimulationAtomGroupType::Freeze][i];
if (ins_grp_id == tmp_id)
{
fr_id = tmp_id;
}
}
- ng = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
+ ng = groups->groups[SimulationAtomGroupType::EnergyOutput].size();
if (ng == 1)
{
gmx_input("No energy groups defined. This is necessary for energy exclusion in the freeze group");
if (inputrec->opts.egp_flags[ng*i+j] == EGP_EXCL)
{
bExcl = TRUE;
- if ( (groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i] != ins_grp_id) ||
- (groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[j] != ins_grp_id) )
+ if ( (groups->groups[SimulationAtomGroupType::EnergyOutput][i] != ins_grp_id) ||
+ (groups->groups[SimulationAtomGroupType::EnergyOutput][j] != ins_grp_id) )
{
gmx_fatal(FARGS, "Energy exclusions \"%s\" and \"%s\" do not match the group "
- "to embed \"%s\"", *groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i]],
- *groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[j]], ins);
+ "to embed \"%s\"", *groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput][i]],
+ *groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput][j]], ins);
}
}
}
mtop_.groups.groupNames.emplace_back(&handle);
}
- mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput].nr = 3;
- snew(mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput].nm_ind,
- mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput].nr);
- mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput].nm_ind[0] = 0;
- mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput].nm_ind[1] = 1;
- mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput].nm_ind[2] = 2;
-
- mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr = 3;
- snew(mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind,
- mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr);
- mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[0] = 0;
- mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[1] = 1;
- mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[2] = 2;
-
- mtop_.groups.groups[SimulationAtomGroupType::Acceleration].nr = 2;
- snew(mtop_.groups.groups[SimulationAtomGroupType::Acceleration].nm_ind,
- mtop_.groups.groups[SimulationAtomGroupType::Acceleration].nr);
- mtop_.groups.groups[SimulationAtomGroupType::Acceleration].nm_ind[0] = 0;
- mtop_.groups.groups[SimulationAtomGroupType::Acceleration].nm_ind[1] = 2;
+ mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput].resize(3);
+ mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput][0] = 0;
+ mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput][1] = 1;
+ mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput][2] = 2;
+
+ mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].resize(3);
+ mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling][0] = 0;
+ mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling][1] = 1;
+ mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling][2] = 2;
+
+ mtop_.groups.groups[SimulationAtomGroupType::Acceleration].resize(2);
+ mtop_.groups.groups[SimulationAtomGroupType::Acceleration][0] = 0;
+ mtop_.groups.groups[SimulationAtomGroupType::Acceleration][1] = 2;
// Nose-Hoover chains
inputrec_.bPrintNHChains = true;
inputrec_.opts.nhchainlength = 2;
- state_.nosehoover_xi.resize(mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr*inputrec_.opts.nhchainlength);
- state_.nosehoover_vxi.resize(mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr*inputrec_.opts.nhchainlength);
+ state_.nosehoover_xi.resize(mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].size()*inputrec_.opts.nhchainlength);
+ state_.nosehoover_vxi.resize(mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].size()*inputrec_.opts.nhchainlength);
// This will be needed only with MTTK barostat
state_.nhpres_xi.resize(1*inputrec_.opts.nhchainlength);
state_.nhpres_vxi.resize(1*inputrec_.opts.nhchainlength);
// Group pairs
- enerdata_ = std::make_unique<gmx_enerdata_t>(mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput].nr, 0);
+ enerdata_ = std::make_unique<gmx_enerdata_t>(mtop_.groups.groups[SimulationAtomGroupType::EnergyOutput].size(), 0);
// Kinetic energy and related data
- ekindata_.tcstat.resize(mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr);
- ekindata_.grpstat.resize(mtop_.groups.groups[SimulationAtomGroupType::Acceleration].nr);
+ ekindata_.tcstat.resize(mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].size());
+ ekindata_.grpstat.resize(mtop_.groups.groups[SimulationAtomGroupType::Acceleration].size());
// This is needed so that the ebin space will be allocated
inputrec_.cos_accel = 1.0;
}
// Kinetic energy and related data
- for (int i = 0; i < mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr; i++)
+ for (int i = 0; i < gmx::ssize(mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling]); i++)
{
ekindata_.tcstat[i].T = (*testValue += 0.1);
ekindata_.tcstat[i].lambda = (*testValue += 0.1);
}
- for (int i = 0; i < mtop_.groups.groups[SimulationAtomGroupType::Acceleration].nr; i++)
+ for (int i = 0; i < gmx::ssize(mtop_.groups.groups[SimulationAtomGroupType::Acceleration]); i++)
{
ekindata_.grpstat[i].u[XX] = (*testValue += 0.1);
ekindata_.grpstat[i].u[YY] = (*testValue += 0.1);
inputrec_.opts.ref_t[i] = (*testValue += 0.1);
}
- for (int k = 0; k < mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr*inputrec_.opts.nhchainlength; k++)
+ for (int k = 0; k < gmx::ssize(mtop_.groups.groups[SimulationAtomGroupType::TemperatureCoupling])*inputrec_.opts.nhchainlength; k++)
{
state_.nosehoover_xi[k] = (*testValue += 0.1);
state_.nosehoover_vxi[k] = (*testValue += 0.1);
if (mode != ecmNO)
{
- nr = groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr;
+ nr = groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].size();
/* Allocate one extra for a possible rest group */
size = nr + 1;
/* We need vcm->nr+1 elements per thread, but to avoid cache
for (int g = 0; (g < nr); g++)
{
group_ndf[g] = ir.opts.nrdf[g];
- group_name[g] = *groups.groupNames[groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nm_ind[g]];
+ group_name[g] = *groups.groupNames[groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval][g]];
}
t_forcerec *fr)
{
int negp_pp;
- int *nm_ind;
char buf[STRLEN];
negp_pp = ir->opts.ngener - ir->nwall;
- nm_ind = groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind;
+ gmx::ArrayRef<const int> nm_ind = groups->groups[SimulationAtomGroupType::EnergyOutput];
if (fplog)
{
cr, ms, nrnb, wcycle, fr->bMolPBC);
/* Energy terms and groups */
- gmx_enerdata_t enerd(mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].nr, inputrec->fepvals->n_lambda);
+ gmx_enerdata_t enerd(mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].size(), inputrec->fepvals->n_lambda);
/* Set up interactive MD (IMD) */
auto imdSession = makeImdSession(inputrec, cr, wcycle, &enerd, ms, &mtop, mdlog,
}
}
- ngid = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
+ ngid = groups->groups[SimulationAtomGroupType::EnergyOutput].size();
// TODO: Figure out which energy group to use
#if 0
gid_tp = GET_CGINFO_GID(fr->cginfo[cg_tp]);
for (i = 0; i < ngid; i++)
{
sprintf(str, "f. <U\\sVdW %s\\Ne\\S-\\betaU\\N>",
- *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i]]));
+ *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput][i]]));
leg[e++] = gmx_strdup(str);
}
if (bDispCorr)
for (i = 0; i < ngid; i++)
{
sprintf(str, "f. <U\\sCoul %s\\Ne\\S-\\betaU\\N>",
- *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i]]));
+ *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput][i]]));
leg[e++] = gmx_strdup(str);
}
if (bRFExcl)
gmx::EnumerationArray < SimulationAtomGroupType, std::vector < int>> gcount;
for (auto group : keysOf(gcount))
{
- gcount[group].resize(groups.groups[group].nr);
+ gcount[group].resize(groups.groups[group].size());
}
for (int i = 0; (i < mtop.natoms); i++)
{
atot = 0;
printf("%-12s: ", shortName(group));
- for (int j = 0; (j < groups.groups[group].nr); j++)
+ for (const auto &entry : gcount[group])
{
- printf(" %5d", gcount[group][j]);
- atot += gcount[group][j];
+ printf(" %5d", entry);
+ atot += entry;
}
printf(" (total %d atoms)\n", atot);
}
#include <stdio.h>
+#include <vector>
+
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
#include "gromacs/utility/unique_cptr.h"
int uij[6]; /* Anisotropic B-factor */
} t_pdbinfo;
-typedef struct t_grps
-{
- int nr; /* Number of different groups */
- int *nm_ind; /* Index in the group names */
-} t_grps;
+//! Contains indices into group names for different groups.
+using AtomGroupIndices = std::vector<int>;
typedef struct t_atoms
{
return c_simulationAtomGroupTypeShortNames[type];
}
-SimulationGroups::SimulationGroups()
-{
- for (auto group : keysOf(groups))
- {
- groups[group].nr = 0;
- groups[group].nm_ind = nullptr;
- }
-
-}
-
void init_top(t_topology *top)
{
top->name = nullptr;
done_blocka(&excls);
}
-SimulationGroups::~SimulationGroups()
-{
- for (auto group : keysOf(groups))
- {
- if (nullptr != groups[group].nm_ind)
- {
- sfree(groups[group].nm_ind);
- groups[group].nm_ind = nullptr;
- }
- }
-}
-
gmx_mtop_t::gmx_mtop_t()
{
init_atomtypes(&atomtypes);
return mtop->moltype.empty() || mtop->moltype[0].atoms.havePdbInfo;
}
-static void pr_grps(FILE *fp,
- const char *title,
- gmx::ArrayRef<const t_grps> grps,
- char ***grpname)
+static void pr_grps(FILE *fp,
+ const char *title,
+ gmx::ArrayRef<const AtomGroupIndices> grps,
+ char ***grpname)
{
int index = 0;
for (const auto &group : grps)
{
- fprintf(fp, "%s[%-12s] nr=%d, name=[", title, c_simulationAtomGroupTypeShortNames[index], group.nr);
- for (int j = 0; (j < group.nr); j++)
+ fprintf(fp, "%s[%-12s] nr=%zu, name=[", title, c_simulationAtomGroupTypeShortNames[index], group.size());
+ for (const auto &entry : group)
{
- fprintf(fp, " %s", *(grpname[group.nm_ind[j]]));
+ fprintf(fp, " %s", *(grpname[entry]));
}
fprintf(fp, "]\n");
index++;
for (auto group : keysOf(g0.groups))
{
std::string buf = gmx::formatString("grps[%d].nr", static_cast<int>(group));
- cmp_int(fp, buf.c_str(), -1, g0.groups[group].nr, g1.groups[group].nr);
- if (g0.groups[group].nr == g1.groups[group].nr)
+ cmp_int(fp, buf.c_str(), -1, g0.groups[group].size(), g1.groups[group].size());
+ if (g0.groups[group].size() == g1.groups[group].size())
{
- for (int j = 0; j < g0.groups[group].nr; j++)
+ for (int j = 0; j < gmx::ssize(g0.groups[group]); j++)
{
buf = gmx::formatString("grps[%d].name[%d]", static_cast<int>(group), j);
cmp_str(fp, buf.c_str(), -1,
- *g0.groupNames[g0.groups[group].nm_ind[j]],
- *g1.groupNames[g1.groups[group].nm_ind[j]]);
+ *g0.groupNames[g0.groups[group][j]],
+ *g1.groupNames[g1.groups[group][j]]);
}
}
cmp_int(fp, "ngrpnr", static_cast<int>(group), g0.numberOfGroupNumbers(group), g1.numberOfGroupNumbers(group));
*/
struct SimulationGroups
{
- SimulationGroups();
-
- ~SimulationGroups();
-
//! Groups of particles
- gmx::EnumerationArray<SimulationAtomGroupType, t_grps> groups;
+ gmx::EnumerationArray<SimulationAtomGroupType, AtomGroupIndices> groups;
//! Names of groups, stored as pointer to the entries in the symbol table.
- std::vector<char **> groupNames;
+ std::vector<char **> groupNames;
//! Group numbers for the different SimulationAtomGroupType groups.
gmx::EnumerationArray < SimulationAtomGroupType, std::vector < unsigned char>> groupNumbers;