}
-void get_enx_state(const char *fn, real t, const gmx_groups_t *groups, t_inputrec *ir,
+void get_enx_state(const char *fn, real t, const SimulationGroups &groups, t_inputrec *ir,
t_state *state)
{
/* Should match the names in mdebin.c */
for (i = 0; i < state->ngtc; i++)
{
- ni = groups->grps[egcTC].nm_ind[i];
- bufi = *(groups->grpname[ni]);
+ ni = groups.groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ bufi = *(groups.groupNames[ni]);
for (j = 0; (j < state->nhchainlength); j++)
{
if (inputrecNvtTrotter(ir))
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
-struct gmx_groups_t;
+struct SimulationGroups;
struct t_energy;
struct t_enxframe;
struct t_fileio;
/* Reads enx_frames, memory in fr is (re)allocated if necessary */
void get_enx_state(const char *fn, real t,
- const gmx_groups_t *groups, t_inputrec *ir,
+ const SimulationGroups &groups, t_inputrec *ir,
t_state *state);
/*
* Reads state variables from enx file fn at time t.
#if GMX_USE_TNG
/* Check if all atoms in the molecule system are selected
* by a selection group of type specified by gtype. */
-static gmx_bool all_atoms_selected(const gmx_mtop_t *mtop,
- const int gtype)
+static gmx_bool all_atoms_selected(const gmx_mtop_t *mtop,
+ const SimulationAtomGroupType gtype)
{
/* Iterate through all atoms in the molecule system and
* check if they belong to a selection group of the
/* If no atoms are selected we do not need to create a
* TNG selection group molecule. */
- if (mtop->groups.ngrpnr[egcCompressedX] == 0)
+ if (mtop->groups.numberOfGroupNumbers(SimulationAtomGroupType::CompressedPositionOutput) == 0)
{
return;
}
/* If all atoms are selected we do not have to create a selection
* group molecule in the TNG molecule system. */
- if (all_atoms_selected(mtop, egcCompressedX))
+ if (all_atoms_selected(mtop, SimulationAtomGroupType::CompressedPositionOutput))
{
return;
}
/* The name of the TNG molecule containing the selection group is the
* same as the name of the selection group. */
- nameIndex = *mtop->groups.grps[egcCompressedX].nm_ind;
- groupName = *mtop->groups.grpname[nameIndex];
+ nameIndex = *mtop->groups.groups[SimulationAtomGroupType::CompressedPositionOutput].nm_ind;
+ groupName = *mtop->groups.groupNames[nameIndex];
tng_molecule_alloc(tng, &mol);
tng_molecule_name_set(tng, mol, groupName);
char *res_name;
int res_id;
- if (getGroupType(mtop->groups, egcCompressedX, i) != 0)
+ if (getGroupType(mtop->groups, SimulationAtomGroupType::CompressedPositionOutput, i) != 0)
{
continue;
}
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, SimulationAtomGroupType::CompressedPositionOutput, atom1) == 0 &&
+ getGroupType(mtop->groups, SimulationAtomGroupType::CompressedPositionOutput, 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 (getGroupType(mtop->groups, egcCompressedX, atom1) == 0)
+ if (getGroupType(mtop->groups, SimulationAtomGroupType::CompressedPositionOutput, atom1) == 0)
{
- if (getGroupType(mtop->groups, egcCompressedX, atom2) == 0)
+ if (getGroupType(mtop->groups, SimulationAtomGroupType::CompressedPositionOutput, atom2) == 0)
{
tng_molecule_bond_add(tng, mol, atom1,
atom2, &tngBond);
}
- if (getGroupType(mtop->groups, egcCompressedX, atom3) == 0)
+ if (getGroupType(mtop->groups, SimulationAtomGroupType::CompressedPositionOutput, atom3) == 0)
{
tng_molecule_bond_add(tng, mol, atom1,
atom3, &tngBond);
}
}
-static void do_grps(t_fileio *fio, int ngrp, t_grps grps[], gmx_bool bRead)
+static void do_grps(t_fileio *fio,
+ gmx::ArrayRef<t_grps> grps,
+ gmx_bool bRead)
{
- for (int j = 0; j < ngrp; j++)
+ for (auto &group : grps)
{
- gmx_fio_do_int(fio, grps[j].nr);
+ gmx_fio_do_int(fio, group.nr);
if (bRead)
{
- snew(grps[j].nm_ind, grps[j].nr);
+ snew(group.nm_ind, group.nr);
}
- gmx_fio_ndo_int(fio, grps[j].nm_ind, grps[j].nr);
+ gmx_fio_ndo_int(fio, group.nm_ind, group.nr);
}
}
do_resinfo(fio, atoms->nres, atoms->resinfo, bRead, symtab, file_version);
}
-static void do_groups(t_fileio *fio, gmx_groups_t *groups,
+static void do_groups(t_fileio *fio, SimulationGroups *groups,
gmx_bool bRead, t_symtab *symtab)
{
- int g;
-
- do_grps(fio, egcNR, groups->grps, bRead);
- gmx_fio_do_int(fio, groups->ngrpname);
+ do_grps(fio, groups->groups, bRead);
+ int numberOfGroupNames = groups->groupNames.size();
+ gmx_fio_do_int(fio, numberOfGroupNames);
if (bRead)
{
- snew(groups->grpname, groups->ngrpname);
+ groups->groupNames.resize(numberOfGroupNames);
}
- do_strstr(fio, groups->ngrpname, groups->grpname, bRead, symtab);
- for (g = 0; g < egcNR; g++)
+ do_strstr(fio, numberOfGroupNames, groups->groupNames.data(), bRead, symtab);
+ for (auto group : gmx::keysOf(groups->groupNumbers))
{
- gmx_fio_do_int(fio, groups->ngrpnr[g]);
- if (groups->ngrpnr[g] == 0)
- {
- if (bRead)
- {
- groups->grpnr[g] = nullptr;
- }
- }
- else
+ int numberOfGroupNumbers = groups->numberOfGroupNumbers(group);
+ gmx_fio_do_int(fio, numberOfGroupNumbers);
+ if (numberOfGroupNumbers != 0)
{
if (bRead)
{
- snew(groups->grpnr[g], groups->ngrpnr[g]);
+ groups->groupNumbers[group].resize(numberOfGroupNumbers);
}
- gmx_fio_ndo_uchar(fio, groups->grpnr[g], groups->ngrpnr[g]);
+ gmx_fio_ndo_uchar(fio, groups->groupNumbers[group].data(), numberOfGroupNumbers);
}
}
}
{
/* 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, SimulationAtomGroupType::EnergyOutput, 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, SimulationAtomGroupType::EnergyOutput, 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",
if ((ir->epc != epcNO || ir->etc == etcNOSEHOOVER) && ener)
{
- get_enx_state(ener, use_time, &sys->groups, ir, state);
+ get_enx_state(ener, use_time, sys->groups, ir, state);
preserve_box_shape(ir, state->box_rel, state->boxv);
}
}
{
char warn_buf[STRLEN];
- double cio = compute_io(ir, sys.natoms, &sys.groups, F_NRE, 1);
+ double cio = compute_io(ir, sys.natoms, sys.groups, F_NRE, 1);
sprintf(warn_buf, "This run will generate roughly %.0f Mb of data", cio);
if (cio > 2000)
{
}
}
-static void add_wall_energrps(gmx_groups_t *groups, int nwall, t_symtab *symtab)
+static void add_wall_energrps(SimulationGroups *groups, int nwall, t_symtab *symtab)
{
- int i;
- t_grps *grps;
- char str[STRLEN];
-
if (nwall > 0)
{
- srenew(groups->grpname, groups->ngrpname+nwall);
- grps = &(groups->grps[egcENER]);
+ t_grps *grps = &(groups->groups[SimulationAtomGroupType::EnergyOutput]);
srenew(grps->nm_ind, grps->nr+nwall);
- for (i = 0; i < nwall; i++)
+ for (int i = 0; i < nwall; i++)
{
- sprintf(str, "wall%d", i);
- groups->grpname[groups->ngrpname] = put_symtab(symtab, str);
- grps->nm_ind[grps->nr++] = groups->ngrpname++;
+ groups->groupNames.emplace_back(
+ put_symtab(
+ symtab,
+ gmx::formatString("wall%d", i).c_str()));
+ grps->nm_ind[grps->nr++] = groups->groupNames.size() - 1;
}
}
}
s);
}
-static bool do_numbering(int natoms, gmx_groups_t *groups,
+static bool do_numbering(int natoms, SimulationGroups *groups,
gmx::ArrayRef<std::string> groupsFromMdpFile,
t_blocka *block, char *gnames[],
- int gtype, int restnm,
+ SimulationAtomGroupType gtype, int restnm,
int grptp, bool bVerbose,
warninp_t wi)
{
unsigned short *cbuf;
- t_grps *grps = &(groups->grps[gtype]);
+ t_grps *grps = &(groups->groups[gtype]);
int j, gid, aj, ognr, ntot = 0;
const char *title;
bool bRest;
char warn_buf[STRLEN];
- title = gtypes[gtype];
+ title = shortName(gtype);
snew(cbuf, natoms);
/* Mark all id's as not set */
if (grps->nr == 1 && (ntot == 0 || ntot == natoms))
{
/* All atoms are part of one (or no) group, no index required */
- groups->ngrpnr[gtype] = 0;
- groups->grpnr[gtype] = nullptr;
+ groups->groupNumbers[gtype].clear();
}
else
{
- groups->ngrpnr[gtype] = natoms;
- snew(groups->grpnr[gtype], natoms);
- for (j = 0; (j < natoms); j++)
+ for (int j = 0; (j < natoms); j++)
{
- groups->grpnr[gtype][j] = cbuf[j];
+ groups->groupNumbers[gtype].emplace_back(cbuf[j]);
}
}
{
t_grpopts *opts;
pull_params_t *pull;
- int natoms, ai, aj, i, j, d, g, imin, jmin;
+ int natoms, imin, jmin;
int *nrdf2, *na_vcm, na_tot;
double *nrdf_tc, *nrdf_vcm, nrdf_uc, *nrdf_vcm_sub;
ivec *dof_vcm;
- int mol, ftype, as;
+ int as;
/* Calculate nrdf.
* First calc 3xnr-atoms for each group
opts = &ir->opts;
- const gmx_groups_t &groups = mtop->groups;
+ const SimulationGroups &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.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);
- for (i = 0; i < groups.grps[egcTC].nr; i++)
+ for (int i = 0; i < groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr; i++)
{
nrdf_tc[i] = 0;
}
- for (i = 0; i < groups.grps[egcVCM].nr+1; i++)
+ for (int i = 0; i < groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1; i++)
{
nrdf_vcm[i] = 0;
clear_ivec(dof_vcm[i]);
na_vcm[i] = 0;
nrdf_vcm_sub[i] = 0;
}
-
snew(nrdf2, natoms);
for (const AtomProxy atomP : AtomRange(*mtop))
{
nrdf2[i] = 0;
if (local.ptype == eptAtom || local.ptype == eptNucleus)
{
- g = getGroupType(groups, egcFREEZE, i);
+ int g = getGroupType(groups, SimulationAtomGroupType::Freeze, i);
for (int 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[getGroupType(groups, egcVCM, i)][d] = 1;
+ dof_vcm[getGroupType(groups, SimulationAtomGroupType::MassCenterVelocityRemoval, i)][d] = 1;
}
}
- nrdf_tc [getGroupType(groups, egcTC, i)] += 0.5*nrdf2[i];
- nrdf_vcm[getGroupType(groups, egcVCM, i)] += 0.5*nrdf2[i];
+ nrdf_tc [getGroupType(groups, SimulationAtomGroupType::TemperatureCoupling, i)] += 0.5*nrdf2[i];
+ nrdf_vcm[getGroupType(groups, SimulationAtomGroupType::MassCenterVelocityRemoval, i)] += 0.5*nrdf2[i];
}
}
{
const gmx_moltype_t &molt = mtop->moltype[molb.type];
const t_atom *atom = molt.atoms.atom;
- for (mol = 0; mol < molb.nmol; mol++)
+ for (int mol = 0; mol < molb.nmol; mol++)
{
- for (ftype = F_CONSTR; ftype <= F_CONSTRNC; ftype++)
+ for (int ftype = F_CONSTR; ftype <= F_CONSTRNC; ftype++)
{
gmx::ArrayRef<const int> ia = molt.ilist[ftype].iatoms;
- for (i = 0; i < molt.ilist[ftype].size(); )
+ for (int i = 0; i < molt.ilist[ftype].size(); )
{
/* Subtract degrees of freedom for the constraints,
* if the particles still have degrees of freedom left.
* contribute to the constraints the degrees of freedom do not
* change.
*/
- ai = as + ia[i + 1];
- aj = as + ia[i + 2];
+ int ai = as + ia[i + 1];
+ int aj = as + ia[i + 2];
if (((atom[ia[i + 1]].ptype == eptNucleus) ||
(atom[ia[i + 1]].ptype == eptAtom)) &&
((atom[ia[i + 2]].ptype == eptNucleus) ||
jmin = std::min(jmin, nrdf2[aj]);
nrdf2[ai] -= imin;
nrdf2[aj] -= 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;
+ nrdf_tc [getGroupType(groups, SimulationAtomGroupType::TemperatureCoupling, ai)] -= 0.5*imin;
+ nrdf_tc [getGroupType(groups, SimulationAtomGroupType::TemperatureCoupling, aj)] -= 0.5*jmin;
+ nrdf_vcm[getGroupType(groups, SimulationAtomGroupType::MassCenterVelocityRemoval, ai)] -= 0.5*imin;
+ nrdf_vcm[getGroupType(groups, SimulationAtomGroupType::MassCenterVelocityRemoval, aj)] -= 0.5*jmin;
}
i += interaction_function[ftype].nratoms+1;
}
}
gmx::ArrayRef<const int> ia = molt.ilist[F_SETTLE].iatoms;
- for (i = 0; i < molt.ilist[F_SETTLE].size(); )
+ for (int i = 0; i < molt.ilist[F_SETTLE].size(); )
{
/* Subtract 1 dof from every atom in the SETTLE */
- for (j = 0; j < 3; j++)
+ for (int j = 0; j < 3; j++)
{
- ai = as + ia[i + 1 + j];
+ int ai = as + ia[i + 1 + j];
imin = std::min(2, nrdf2[ai]);
nrdf2[ai] -= imin;
- nrdf_tc [getGroupType(groups, egcTC, ai)] -= 0.5*imin;
- nrdf_vcm[getGroupType(groups, egcVCM, ai)] -= 0.5*imin;
+ nrdf_tc [getGroupType(groups, SimulationAtomGroupType::TemperatureCoupling, ai)] -= 0.5*imin;
+ nrdf_vcm[getGroupType(groups, SimulationAtomGroupType::MassCenterVelocityRemoval, ai)] -= 0.5*imin;
}
i += 4;
}
*/
pull = ir->pull;
- for (i = 0; i < pull->ncoord; i++)
+ for (int i = 0; i < pull->ncoord; i++)
{
if (pull->coord[i].eType != epullCONSTRAINT)
{
imin = 1;
- for (j = 0; j < 2; j++)
+ for (int j = 0; j < 2; j++)
{
const t_pull_group *pgrp;
if (pgrp->nat > 0)
{
/* Subtract 1/2 dof from each group */
- ai = pgrp->ind[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)
+ int ai = pgrp->ind[0];
+ nrdf_tc [getGroupType(groups, SimulationAtomGroupType::TemperatureCoupling, ai)] -= 0.5*imin;
+ 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.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.groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[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 (j = 0; j < groups.grps[egcVCM].nr+1; j++)
+ for (int j = 0; j < groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1; j++)
{
switch (ir->comm_mode)
{
case ecmLINEAR:
case ecmLINEAR_ACCELERATION_CORRECTION:
nrdf_vcm_sub[j] = 0;
- for (d = 0; d < ndim_rm_vcm; d++)
+ for (int d = 0; d < ndim_rm_vcm; d++)
{
if (dof_vcm[j][d])
{
}
}
- for (i = 0; i < groups.grps[egcTC].nr; i++)
+ for (int i = 0; i < groups.groups[SimulationAtomGroupType::TemperatureCoupling].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 (int j = 0; j < groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1; j++)
{
na_vcm[j] = 0;
}
na_tot = 0;
- for (ai = 0; ai < natoms; ai++)
+ for (int ai = 0; ai < natoms; ai++)
{
- if (getGroupType(groups, egcTC, ai) == i)
+ if (getGroupType(groups, SimulationAtomGroupType::TemperatureCoupling, ai) == i)
{
- na_vcm[getGroupType(groups, egcVCM, ai)]++;
+ na_vcm[getGroupType(groups, SimulationAtomGroupType::MassCenterVelocityRemoval, ai)]++;
na_tot++;
}
}
*/
nrdf_uc = nrdf_tc[i];
nrdf_tc[i] = 0;
- for (j = 0; j < groups.grps[egcVCM].nr+1; j++)
+ for (int j = 0; j < groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr+1; j++)
{
if (nrdf_vcm[j] > nrdf_vcm_sub[j])
{
}
}
}
- for (i = 0; (i < groups.grps[egcTC].nr); i++)
+ for (int i = 0; (i < groups.groups[SimulationAtomGroupType::TemperatureCoupling].nr); 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.grps[egcTC].nm_ind[i]], opts->nrdf[i]);
+ gnames[groups.groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i]], opts->nrdf[i]);
}
sfree(nrdf2);
sfree(nrdf_vcm_sub);
}
-static bool do_egp_flag(t_inputrec *ir, gmx_groups_t *groups,
+static bool do_egp_flag(t_inputrec *ir, SimulationGroups *groups,
const char *option, const char *val, int flag)
{
/* The maximum number of energy group pairs would be MAXPTR*(MAXPTR+1)/2.
*/
#define EGP_MAX (STRLEN/2)
int j, k, nr;
- char ***gnames;
bool bSet;
- gnames = groups->grpname;
-
- auto names = gmx::splitString(val);
+ auto names = gmx::splitString(val);
if (names.size() % 2 != 0)
{
gmx_fatal(FARGS, "The number of groups for %s is odd", option);
}
- nr = groups->grps[egcENER].nr;
+ nr = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
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(), *(gnames[groups->grps[egcENER].nm_ind[j]])))
+ gmx_strcasecmp(names[2*i].c_str(), *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[j]])))
{
j++;
}
}
k = 0;
while ((k < nr) &&
- gmx_strcasecmp(names[2*i+1].c_str(), *(gnames[groups->grps[egcENER].nm_ind[k]])))
+ gmx_strcasecmp(names[2*i+1].c_str(), *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[k]])))
{
k++;
}
t_inputrec *ir,
warninp_t wi)
{
- t_blocka *grps;
- gmx_groups_t *groups;
- int natoms;
- t_symtab *symtab;
- t_atoms atoms_all;
- char warnbuf[STRLEN], **gnames;
- int nr;
- real tau_min;
- int nstcmin;
- int i, j, k, restnm;
- bool bExcl, bTable, bAnneal, bRest;
- char warn_buf[STRLEN];
+ t_blocka *defaultIndexGroups;
+ int natoms;
+ t_symtab *symtab;
+ t_atoms atoms_all;
+ char warnbuf[STRLEN], **gnames;
+ int nr;
+ real tau_min;
+ int nstcmin;
+ int i, j, k, restnm;
+ bool bExcl, bTable, bAnneal, bRest;
+ char warn_buf[STRLEN];
if (bVerbose)
{
}
if (ndx == nullptr)
{
- snew(grps, 1);
- snew(grps->index, 1);
+ snew(defaultIndexGroups, 1);
+ snew(defaultIndexGroups->index, 1);
snew(gnames, 1);
atoms_all = gmx_mtop_global_atoms(mtop);
- analyse(&atoms_all, grps, &gnames, FALSE, TRUE);
+ analyse(&atoms_all, defaultIndexGroups, &gnames, FALSE, TRUE);
done_atom(&atoms_all);
}
else
{
- grps = init_index(ndx, &gnames);
+ defaultIndexGroups = init_index(ndx, &gnames);
}
- groups = &mtop->groups;
+ SimulationGroups *groups = &mtop->groups;
natoms = mtop->natoms;
symtab = &mtop->symtab;
- snew(groups->grpname, grps->nr+1);
-
- for (i = 0; (i < grps->nr); i++)
+ for (int i = 0; (i < defaultIndexGroups->nr); i++)
{
- groups->grpname[i] = put_symtab(symtab, gnames[i]);
+ groups->groupNames.emplace_back(put_symtab(symtab, gnames[i]));
}
- groups->grpname[i] = put_symtab(symtab, "rest");
- restnm = i;
- srenew(gnames, grps->nr+1);
- gnames[restnm] = *(groups->grpname[i]);
- groups->ngrpname = grps->nr+1;
+ groups->groupNames.emplace_back(put_symtab(symtab, "rest"));
+ restnm = groups->groupNames.size() - 1;
+ GMX_RELEASE_ASSERT(restnm == defaultIndexGroups->nr, "Size of allocations must match");
+ srenew(gnames, defaultIndexGroups->nr+1);
+ gnames[restnm] = *(groups->groupNames.back());
set_warning_line(wi, mdparin, -1);
}
const bool useReferenceTemperature = integratorHasReferenceTemperature(ir);
- do_numbering(natoms, groups, temperatureCouplingGroupNames, grps, gnames, egcTC,
+ do_numbering(natoms, groups, temperatureCouplingGroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::TemperatureCoupling,
restnm, useReferenceTemperature ? egrptpALL : egrptpALL_GENREST, bVerbose, wi);
- nr = groups->grps[egcTC].nr;
+ nr = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nr;
ir->opts.ngtc = nr;
snew(ir->opts.nrdf, nr);
snew(ir->opts.tau_t, nr);
{
if (ir->opts.annealing[i] != eannNO)
{
- j = groups->grps[egcTC].nm_ind[i];
+ j = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
fprintf(stderr, "Simulated annealing for group %s: %s, %d timepoints\n",
- *(groups->grpname[j]), eann_names[ir->opts.annealing[i]],
+ *(groups->groupNames[j]), eann_names[ir->opts.annealing[i]],
ir->opts.anneal_npoints[i]);
fprintf(stderr, "Time (ps) Temperature (K)\n");
/* All terms except the last one */
if (ir->bPull)
{
- make_pull_groups(ir->pull, is->pull_grp, grps, gnames);
+ make_pull_groups(ir->pull, is->pull_grp, defaultIndexGroups, gnames);
make_pull_coords(ir->pull);
}
if (ir->bRot)
{
- make_rotation_groups(ir->rot, is->rot_grp, grps, gnames);
+ make_rotation_groups(ir->rot, is->rot_grp, defaultIndexGroups, gnames);
}
if (ir->eSwapCoords != eswapNO)
{
- make_swap_groups(ir->swap, grps, gnames);
+ make_swap_groups(ir->swap, defaultIndexGroups, gnames);
}
/* Make indices for IMD session */
if (ir->bIMD)
{
- make_IMD_group(ir->imd, is->imd_grp, grps, gnames);
+ make_IMD_group(ir->imd, is->imd_grp, defaultIndexGroups, gnames);
}
auto accelerations = gmx::splitString(is->acc);
gmx_fatal(FARGS, "Invalid Acceleration input: %zu groups and %zu acc. values",
accelerationGroupNames.size(), accelerations.size());
}
- do_numbering(natoms, groups, accelerationGroupNames, grps, gnames, egcACC,
+ do_numbering(natoms, groups, accelerationGroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::Acceleration,
restnm, egrptpALL_GENREST, bVerbose, wi);
- nr = groups->grps[egcACC].nr;
+ nr = groups->groups[SimulationAtomGroupType::Acceleration].nr;
snew(ir->opts.acc, nr);
ir->opts.ngacc = nr;
gmx_fatal(FARGS, "Invalid Freezing input: %zu groups and %zu freeze values",
freezeGroupNames.size(), freezeDims.size());
}
- do_numbering(natoms, groups, freezeGroupNames, grps, gnames, egcFREEZE,
+ do_numbering(natoms, groups, freezeGroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::Freeze,
restnm, egrptpALL_GENREST, bVerbose, wi);
- nr = groups->grps[egcFREEZE].nr;
+ nr = groups->groups[SimulationAtomGroupType::Freeze].nr;
ir->opts.ngfrz = nr;
snew(ir->opts.nFreeze, nr);
for (i = k = 0; (size_t(i) < freezeGroupNames.size()); i++)
}
auto energyGroupNames = gmx::splitString(is->energy);
- do_numbering(natoms, groups, energyGroupNames, grps, gnames, egcENER,
+ do_numbering(natoms, groups, energyGroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::EnergyOutput,
restnm, egrptpALL_GENREST, bVerbose, wi);
add_wall_energrps(groups, ir->nwall, symtab);
- ir->opts.ngener = groups->grps[egcENER].nr;
+ ir->opts.ngener = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
auto vcmGroupNames = gmx::splitString(is->vcm);
bRest =
- do_numbering(natoms, groups, vcmGroupNames, grps, gnames, egcVCM,
+ do_numbering(natoms, groups, vcmGroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::MassCenterVelocityRemoval,
restnm, vcmGroupNames.empty() ? egrptpALL_GENREST : egrptpPART, bVerbose, wi);
if (bRest)
{
calc_nrdf(mtop, ir, gnames);
auto user1GroupNames = gmx::splitString(is->user1);
- do_numbering(natoms, groups, user1GroupNames, grps, gnames, egcUser1,
+ do_numbering(natoms, groups, user1GroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::User1,
restnm, egrptpALL_GENREST, bVerbose, wi);
auto user2GroupNames = gmx::splitString(is->user2);
- do_numbering(natoms, groups, user2GroupNames, grps, gnames, egcUser2,
+ do_numbering(natoms, groups, user2GroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::User2,
restnm, egrptpALL_GENREST, bVerbose, wi);
auto compressedXGroupNames = gmx::splitString(is->x_compressed_groups);
- do_numbering(natoms, groups, compressedXGroupNames, grps, gnames, egcCompressedX,
+ do_numbering(natoms, groups, compressedXGroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::CompressedPositionOutput,
restnm, egrptpONE, bVerbose, wi);
auto orirefFitGroupNames = gmx::splitString(is->orirefitgrp);
- do_numbering(natoms, groups, orirefFitGroupNames, grps, gnames, egcORFIT,
+ do_numbering(natoms, groups, orirefFitGroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::OrientationRestraintsFit,
restnm, egrptpALL_GENREST, bVerbose, wi);
/* QMMM input processing */
qmBasisSets.size(), qmMethods.size());
}
/* group rest, if any, is always MM! */
- do_numbering(natoms, groups, qmGroupNames, grps, gnames, egcQMMM,
+ do_numbering(natoms, groups, qmGroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::QuantumMechanics,
restnm, egrptpALL_GENREST, bVerbose, wi);
nr = qmGroupNames.size(); /*atoms->grps[egcQMMM].nr;*/
ir->opts.ngQM = qmGroupNames.size();
gmx_fatal(FARGS, "Currently, having more than one QM group in MiMiC is not supported");
}
/* group rest, if any, is always MM! */
- do_numbering(natoms, groups, qmGroupNames, grps, gnames, egcQMMM,
+ do_numbering(natoms, groups, qmGroupNames, defaultIndexGroups, gnames,
+ SimulationAtomGroupType::QuantumMechanics,
restnm, egrptpALL_GENREST, bVerbose, wi);
ir->opts.ngQM = qmGroupNames.size();
if (bVerbose)
{
- for (i = 0; (i < egcNR); i++)
+ for (auto group : gmx::keysOf(groups->groups))
{
- fprintf(stderr, "%-16s has %d element(s):", gtypes[i], groups->grps[i].nr);
- for (j = 0; (j < groups->grps[i].nr); j++)
+ 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, " %s", *(groups->grpname[groups->grps[i].nm_ind[j]]));
+ fprintf(stderr, " %s", *(groups->groupNames[groups->groups[group].nm_ind[j]]));
}
fprintf(stderr, "\n");
}
}
- nr = groups->grps[egcENER].nr;
+ nr = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
snew(ir->opts.egp_flags, nr*nr);
bExcl = do_egp_flag(ir, groups, "energygrp-excl", is->egpexcl, EGP_EXCL);
"by default, but it is recommended to set it to an explicit value!",
ir->expandedvals->nstexpanded));
}
- for (i = 0; (i < grps->nr); i++)
+ for (i = 0; (i < defaultIndexGroups->nr); i++)
{
sfree(gnames[i]);
}
sfree(gnames);
- done_blocka(grps);
- sfree(grps);
+ done_blocka(defaultIndexGroups);
+ sfree(defaultIndexGroups);
}
}
bAcc = FALSE;
- for (i = 0; (i < sys->groups.grps[egcACC].nr); i++)
+ for (int i = 0; (i < sys->groups.groups[SimulationAtomGroupType::Acceleration].nr); i++)
{
for (m = 0; (m < DIM); m++)
{
if (bAcc)
{
clear_rvec(acc);
- snew(mgrp, sys->groups.grps[egcACC].nr);
+ snew(mgrp, sys->groups.groups[SimulationAtomGroupType::Acceleration].nr);
for (const AtomProxy atomP : AtomRange(*sys))
{
const t_atom &local = atomP.atom();
int i = atomP.globalAtomNumber();
- mgrp[getGroupType(sys->groups, egcACC, i)] += local.m;
+ mgrp[getGroupType(sys->groups, SimulationAtomGroupType::Acceleration, i)] += local.m;
}
mt = 0.0;
- for (i = 0; (i < sys->groups.grps[egcACC].nr); i++)
+ for (i = 0; (i < sys->groups.groups[SimulationAtomGroupType::Acceleration].nr); i++)
{
for (m = 0; (m < DIM); m++)
{
if (ir->nstcomm != 0 && m < ndof_com(ir))
{
acc[m] /= mt;
- for (i = 0; (i < sys->groups.grps[egcACC].nr); i++)
+ for (i = 0; (i < sys->groups.groups[SimulationAtomGroupType::Acceleration].nr); i++)
{
ir->opts.acc[i][m] -= acc[m];
}
class MDModules;
}
-struct gmx_groups_t;
struct gmx_mtop_t;
struct gmx_output_env_t;
struct pull_params_t;
int index_offset = 0;
int qm_nr = 0;
- grpnr = sys->groups.grpnr[egcQMMM];
+ grpnr = sys->groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics].data();
for (size_t mb = 0; mb < sys->molblock.size(); mb++)
{
od->nref = 0;
for (int i = 0; i < mtop->natoms; i++)
{
- if (getGroupType(mtop->groups, egcORFIT, i) == 0)
+ if (getGroupType(mtop->groups, SimulationAtomGroupType::OrientationRestraintsFit, i) == 0)
{
od->nref++;
}
{
const t_atom &local = atomP.atom();
int i = atomP.globalAtomNumber();
- if (mtop->groups.grpnr[egcORFIT] == nullptr ||
- mtop->groups.grpnr[egcORFIT][i] == 0)
+ if (mtop->groups.groupNumbers[SimulationAtomGroupType::OrientationRestraintsFit].empty() ||
+ mtop->groups.groupNumbers[SimulationAtomGroupType::OrientationRestraintsFit][i] == 0)
{
/* Not correct for free-energy with changing masses */
od->mref[j] = local.m;
sfree(handle);
}
+static void bc_strings_container(const t_commrec *cr,
+ t_symtab *symtab,
+ int nr,
+ std::vector<char **> *nm)
+{
+ std::vector<int> handle;
+ if (MASTER(cr))
+ {
+ for (int i = 0; (i < nr); i++)
+ {
+ handle.emplace_back(lookup_symtab(symtab, (*nm)[i]));
+ }
+ }
+ block_bc(cr, nr);
+ nblock_abc(cr, nr, &handle);
+
+ if (!MASTER(cr))
+ {
+ nm->resize(nr);
+ for (int i = 0; (i < nr); i++)
+ {
+ (*nm)[i] = get_symtab_handle(symtab, handle[i]);
+ }
+ }
+}
+
static void bc_strings_resinfo(const t_commrec *cr, t_symtab *symtab,
int nr, t_resinfo *resinfo)
{
}
}
-static void bc_grps(const t_commrec *cr, t_grps grps[])
+static void bc_grps(const t_commrec *cr, gmx::ArrayRef<t_grps> grps)
{
- int i;
-
- for (i = 0; (i < egcNR); i++)
+ for (auto &group : grps)
{
- block_bc(cr, grps[i].nr);
- snew_bc(cr, grps[i].nm_ind, grps[i].nr);
- nblock_bc(cr, grps[i].nr, grps[i].nm_ind);
+ block_bc(cr, group.nr);
+ snew_bc(cr, group.nm_ind, group.nr);
+ nblock_bc(cr, group.nr, group.nm_ind);
}
}
}
static void bc_groups(const t_commrec *cr, t_symtab *symtab,
- int natoms, gmx_groups_t *groups)
+ int natoms, SimulationGroups *groups)
{
- int g, n;
+ int n;
- bc_grps(cr, groups->grps);
- block_bc(cr, groups->ngrpname);
- bc_strings(cr, symtab, groups->ngrpname, &groups->grpname);
- for (g = 0; g < egcNR; g++)
+ bc_grps(cr, groups->groups);
+ bc_strings_container(cr, symtab, groups->groupNames.size(), &groups->groupNames);
+ for (auto group : gmx::keysOf(groups->groups))
{
if (MASTER(cr))
{
- if (groups->grpnr[g])
+ if (!groups->groupNumbers[group].empty())
{
n = natoms;
}
}
}
block_bc(cr, n);
- if (n == 0)
- {
- groups->grpnr[g] = nullptr;
- }
- else
+ if (n != 0)
{
- snew_bc(cr, groups->grpnr[g], n);
- nblock_bc(cr, n, groups->grpnr[g]);
+ nblock_abc(cr, n, &groups->groupNumbers[group]);
}
}
if (debug)
}
}
-double compute_io(const t_inputrec *ir, int natoms, const gmx_groups_t *groups,
+double compute_io(const t_inputrec *ir, int natoms, const SimulationGroups &groups,
int nrener, int nrepl)
{
nstxtc = div_nsteps(nsteps, ir->nstxout_compressed);
if (ir->nstxout_compressed > 0)
{
- for (i = 0; i < natoms; i++)
+ for (int i = 0; i < natoms; i++)
{
- if (groups->grpnr[egcCompressedX] == nullptr || groups->grpnr[egcCompressedX][i] == 0)
+ if (groups.groupNumbers[SimulationAtomGroupType::CompressedPositionOutput].empty() ||
+ groups.groupNumbers[SimulationAtomGroupType::CompressedPositionOutput][i] == 0)
{
nxtcatoms++;
}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2014,2015,2018, by the GROMACS development team, led by
+ * Copyright (c) 2011,2014,2015,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#ifndef GMX_MDLIB_COMPUTE_IO_H
#define GMX_MDLIB_COMPUTE_IO_H
-struct gmx_groups_t;
+struct SimulationGroups;
struct t_inputrec;
-double compute_io(const t_inputrec *ir, int natoms, const gmx_groups_t *groups,
+double compute_io(const t_inputrec *ir, int natoms, const SimulationGroups &groups,
int nrener, int nrepl);
/* Return total output to be written from this simulation. */
FILE *fp_dhdl,
bool isRerun)
{
- const char *ener_nm[F_NRE];
- static const char *vir_nm[] = {
+ const char *ener_nm[F_NRE];
+ static const char *vir_nm[] = {
"Vir-XX", "Vir-XY", "Vir-XZ",
"Vir-YX", "Vir-YY", "Vir-YZ",
"Vir-ZX", "Vir-ZY", "Vir-ZZ"
};
- static const char *sv_nm[] = {
+ static const char *sv_nm[] = {
"ShakeVir-XX", "ShakeVir-XY", "ShakeVir-XZ",
"ShakeVir-YX", "ShakeVir-YY", "ShakeVir-YZ",
"ShakeVir-ZX", "ShakeVir-ZY", "ShakeVir-ZZ"
};
- static const char *fv_nm[] = {
+ static const char *fv_nm[] = {
"ForceVir-XX", "ForceVir-XY", "ForceVir-XZ",
"ForceVir-YX", "ForceVir-YY", "ForceVir-YZ",
"ForceVir-ZX", "ForceVir-ZY", "ForceVir-ZZ"
};
- static const char *pres_nm[] = {
+ static const char *pres_nm[] = {
"Pres-XX", "Pres-XY", "Pres-XZ",
"Pres-YX", "Pres-YY", "Pres-YZ",
"Pres-ZX", "Pres-ZY", "Pres-ZZ"
};
- static const char *surft_nm[] = {
+ static const char *surft_nm[] = {
"#Surf*SurfTen"
};
- static const char *mu_nm[] = {
+ static const char *mu_nm[] = {
"Mu-X", "Mu-Y", "Mu-Z"
};
- static const char *vcos_nm[] = {
+ static const char *vcos_nm[] = {
"2CosZ*Vel-X"
};
- static const char *visc_nm[] = {
+ static const char *visc_nm[] = {
"1/Viscosity"
};
- static const char *baro_nm[] = {
+ static const char *baro_nm[] = {
"Barostat"
};
- const gmx_groups_t *groups;
- char **gnm;
- char buf[256];
- const char *bufi;
- t_mdebin *md;
- int i, j, ni, nj, n, k, kk, ncon, nset;
- gmx_bool bBHAM, b14;
+ const SimulationGroups *groups;
+ char **gnm;
+ char buf[256];
+ const char *bufi;
+ t_mdebin *md;
+ int i, j, ni, nj, n, k, kk, ncon, nset;
+ gmx_bool bBHAM, b14;
snew(md, 1);
md->nEc++;
}
}
-
- n = groups->grps[egcENER].nr;
+ n = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
md->nEg = n;
md->nE = (n*(n+1))/2;
{
snew(gnm[k], STRLEN);
}
- for (i = 0; (i < groups->grps[egcENER].nr); i++)
+ for (i = 0; (i < groups->groups[SimulationAtomGroupType::EnergyOutput].nr); i++)
{
- ni = groups->grps[egcENER].nm_ind[i];
- for (j = i; (j < groups->grps[egcENER].nr); j++)
+ ni = groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i];
+ for (j = i; (j < groups->groups[SimulationAtomGroupType::EnergyOutput].nr); j++)
{
- nj = groups->grps[egcENER].nm_ind[j];
+ nj = groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[j];
for (k = kk = 0; (k < egNR); k++)
{
if (md->bEInd[k])
{
sprintf(gnm[kk], "%s:%s-%s", egrp_nm[k],
- *(groups->grpname[ni]), *(groups->grpname[nj]));
+ *(groups->groupNames[ni]), *(groups->groupNames[nj]));
kk++;
}
}
}
}
- md->nTC = isRerun ? 0 : groups->grps[egcTC].nr;
+ md->nTC = isRerun ? 0 : groups->groups[SimulationAtomGroupType::TemperatureCoupling].nr;
md->nNHC = ir->opts.nhchainlength; /* shorthand for number of NH chains */
if (md->bMTTK)
{
for (i = 0; (i < md->nTC); i++)
{
- ni = groups->grps[egcTC].nm_ind[i];
- sprintf(buf, "T-%s", *(groups->grpname[ni]));
+ ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ sprintf(buf, "T-%s", *(groups->groupNames[ni]));
grpnms[i] = gmx_strdup(buf);
}
md->itemp = get_ebin_space(md->ebin, md->nTC, grpnms,
{
for (i = 0; (i < md->nTC); i++)
{
- ni = groups->grps[egcTC].nm_ind[i];
- bufi = *(groups->grpname[ni]);
+ ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ bufi = *(groups->groupNames[ni]);
for (j = 0; (j < md->nNHC); j++)
{
sprintf(buf, "Xi-%d-%s", j, bufi);
{
for (i = 0; (i < md->nTC); i++)
{
- ni = groups->grps[egcTC].nm_ind[i];
- bufi = *(groups->grpname[ni]);
+ ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ bufi = *(groups->groupNames[ni]);
sprintf(buf, "Xi-%s", bufi);
grpnms[2*i] = gmx_strdup(buf);
sprintf(buf, "vXi-%s", bufi);
{
for (i = 0; (i < md->nTC); i++)
{
- ni = groups->grps[egcTC].nm_ind[i];
- sprintf(buf, "Lamb-%s", *(groups->grpname[ni]));
+ ni = groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i];
+ sprintf(buf, "Lamb-%s", *(groups->groupNames[ni]));
grpnms[i] = gmx_strdup(buf);
}
md->itc = get_ebin_space(md->ebin, md->mde_n, grpnms, "");
}
sfree(grpnms);
- md->nU = groups->grps[egcACC].nr;
+ md->nU = groups->groups[SimulationAtomGroupType::Acceleration].nr;
if (md->nU > 1)
{
snew(grpnms, 3*md->nU);
for (i = 0; (i < md->nU); i++)
{
- ni = groups->grps[egcACC].nm_ind[i];
- sprintf(buf, "Ux-%s", *(groups->grpname[ni]));
+ ni = groups->groups[SimulationAtomGroupType::Acceleration].nm_ind[i];
+ sprintf(buf, "Ux-%s", *(groups->groupNames[ni]));
grpnms[3*i+XX] = gmx_strdup(buf);
- sprintf(buf, "Uy-%s", *(groups->grpname[ni]));
+ sprintf(buf, "Uy-%s", *(groups->groupNames[ni]));
grpnms[3*i+YY] = gmx_strdup(buf);
- sprintf(buf, "Uz-%s", *(groups->grpname[ni]));
+ sprintf(buf, "Uz-%s", *(groups->groupNames[ni]));
grpnms[3*i+ZZ] = gmx_strdup(buf);
}
md->iu = get_ebin_space(md->ebin, 3*md->nU, grpnms, unit_vel);
int64_t step, double time,
int mode,
t_mdebin *md, t_fcdata *fcd,
- gmx_groups_t *groups, t_grpopts *opts,
+ SimulationGroups *groups, t_grpopts *opts,
gmx::Awh *awh)
{
/*static char **grpnms=NULL;*/
if (opts->annealing[i] != eannNO)
{
fprintf(log, "Current ref_t for group %s: %8.1f\n",
- *(groups->grpname[groups->grps[egcTC].nm_ind[i]]),
+ *(groups->groupNames[groups->groups[SimulationAtomGroupType::TemperatureCoupling].nm_ind[i]]),
opts->ref_t[i]);
}
}
n = 0;
for (i = 0; (i < md->nEg); i++)
{
- ni = groups->grps[egcENER].nm_ind[i];
+ ni = groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i];
for (j = i; (j < md->nEg); j++)
{
- nj = groups->grps[egcENER].nm_ind[j];
- sprintf(buf, "%s-%s", *(groups->grpname[ni]),
- *(groups->grpname[nj]));
+ nj = groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[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->grps[egcACC].nm_ind[i];
- fprintf(log, "%15s", *groups->grpname[ni]);
+ ni = groups->groups[SimulationAtomGroupType::Acceleration].nm_ind[i];
+ fprintf(log, "%15s", *groups->groupNames[ni]);
pr_ebin(log, md->ebin, md->iu+3*i, 3, 3, mode, FALSE);
}
fprintf(log, "\n");
int64_t step, double time,
int mode,
t_fcdata *fcd,
- gmx_groups_t *groups, t_grpopts *opts,
+ SimulationGroups *groups, t_grpopts *opts,
gmx::Awh *awh)
{
print_ebin(fp_ene, bEne, bDR, bOR, log, step, time, mode,
struct ener_file;
struct gmx_ekindata_t;
struct gmx_enerdata_t;
-struct gmx_groups_t;
+struct SimulationGroups;
struct gmx_mtop_t;
struct gmx_output_env_t;
struct t_ebin;
int64_t step, double time,
int mode,
t_fcdata *fcd,
- gmx_groups_t *groups, t_grpopts *opts,
+ SimulationGroups *groups, t_grpopts *opts,
gmx::Awh *awh);
/*! \brief Get the number of energy terms recorded.
*
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
-void ns(FILE *fp,
- t_forcerec *fr,
- matrix box,
- const gmx_groups_t *groups,
- gmx_localtop_t *top,
- const t_mdatoms *md,
- const t_commrec *cr,
- t_nrnb *nrnb,
- gmx_bool bFillGrid)
+void ns(FILE *fp,
+ t_forcerec *fr,
+ matrix box,
+ const SimulationGroups *groups,
+ gmx_localtop_t *top,
+ const t_mdatoms *md,
+ const t_commrec *cr,
+ t_nrnb *nrnb,
+ gmx_bool bFillGrid)
{
int nsearch;
struct gmx_edsam;
struct gmx_enerdata_t;
struct gmx_enfrot;
-struct gmx_groups_t;
+struct SimulationGroups;
struct gmx_grppairener_t;
struct gmx_localtop_t;
struct gmx_multisim_t;
void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, t_lambda *fepvals);
/* Sum the free energy contributions */
-void do_force(FILE *log,
- const t_commrec *cr,
- const gmx_multisim_t *ms,
- const t_inputrec *inputrec,
- gmx::Awh *awh,
- gmx_enfrot *enforcedRotation,
- int64_t step,
- t_nrnb *nrnb,
- gmx_wallcycle *wcycle,
+void do_force(FILE *log,
+ const t_commrec *cr,
+ const gmx_multisim_t *ms,
+ const t_inputrec *inputrec,
+ gmx::Awh *awh,
+ gmx_enfrot *enforcedRotation,
+ int64_t step,
+ t_nrnb *nrnb,
+ gmx_wallcycle *wcycle,
// TODO top can be const when the group scheme no longer
// builds exclusions during neighbor searching within
// do_force_cutsGROUP.
- gmx_localtop_t *top,
- const gmx_groups_t *groups,
- matrix box,
- gmx::ArrayRefWithPadding<gmx::RVec> coordinates,
- history_t *hist,
- gmx::ArrayRefWithPadding<gmx::RVec> force,
- tensor vir_force,
- const t_mdatoms *mdatoms,
- gmx_enerdata_t *enerd,
- t_fcdata *fcd,
- gmx::ArrayRef<real> lambda,
- t_graph *graph,
- t_forcerec *fr,
- gmx::PpForceWorkload *ppForceWorkload,
- const gmx_vsite_t *vsite,
- rvec mu_tot,
- double t,
- gmx_edsam *ed,
- int flags,
- const DDBalanceRegionHandler &ddBalanceRegionHandler);
+ gmx_localtop_t *top,
+ const SimulationGroups *groups,
+ matrix box,
+ gmx::ArrayRefWithPadding<gmx::RVec> coordinates,
+ history_t *hist,
+ gmx::ArrayRefWithPadding<gmx::RVec> force,
+ tensor vir_force,
+ const t_mdatoms *mdatoms,
+ gmx_enerdata_t *enerd,
+ t_fcdata *fcd,
+ gmx::ArrayRef<real> lambda,
+ t_graph *graph,
+ t_forcerec *fr,
+ gmx::PpForceWorkload *ppForceWorkload,
+ const gmx_vsite_t *vsite,
+ rvec mu_tot,
+ double t,
+ gmx_edsam *ed,
+ int flags,
+ const DDBalanceRegionHandler &ddBalanceRegionHandler);
/* Communicate coordinates (if parallel).
* Do neighbor searching (if necessary).
* f is always required.
*/
-void ns(FILE *fplog,
- t_forcerec *fr,
- matrix box,
- const gmx_groups_t *groups,
- gmx_localtop_t *top,
- const t_mdatoms *md,
- const t_commrec *cr,
- t_nrnb *nrnb,
- gmx_bool bFillGrid);
+void ns(FILE *fplog,
+ t_forcerec *fr,
+ matrix box,
+ const SimulationGroups *groups,
+ gmx_localtop_t *top,
+ const t_mdatoms *md,
+ const t_commrec *cr,
+ t_nrnb *nrnb,
+ gmx_bool bFillGrid);
/* Call the neighborsearcher */
void do_force_lowlevel(t_forcerec *fr,
for (cg_mol = 0; cg_mol < cgs->nr; cg_mol++)
{
check_solvent_cg(molt, cg_mol, nmol,
- mtop->groups.grpnr[egcQMMM] ?
- mtop->groups.grpnr[egcQMMM]+at_offset+am : nullptr,
- &mtop->groups.grps[egcQMMM],
+ mtop->groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics].empty() ?
+ nullptr : mtop->groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics].data()+at_offset+am,
+ &mtop->groups.groups[SimulationAtomGroupType::QuantumMechanics],
fr,
&n_solvent_parameters, &solvent_parameters,
cginfo_mb[mb].cginfo[cgm+cg_mol],
{
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, SimulationAtomGroupType::QuantumMechanics, a_offset+am+a0) !=
+ getGroupType(mtop->groups, SimulationAtomGroupType::QuantumMechanics, a_offset +a0))
{
bId = FALSE;
}
- if (mtop->groups.grpnr[egcQMMM] != nullptr)
+ if (!mtop->groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics].empty())
{
for (ai = a0; ai < a1; ai++)
{
- if (mtop->groups.grpnr[egcQMMM][a_offset+am+ai] !=
- mtop->groups.grpnr[egcQMMM][a_offset +ai])
+ if (mtop->groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics][a_offset+am+ai] !=
+ mtop->groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics][a_offset +ai])
{
bId = FALSE;
}
a1 = cgs->index[cg+1];
/* Store the energy group in cginfo */
- gid = getGroupType(mtop->groups, egcENER, a_offset+am+a0);
+ gid = getGroupType(mtop->groups, SimulationAtomGroupType::EnergyOutput, a_offset+am+a0);
SET_CGINFO_GID(cginfo[cgm+cg], gid);
/* Check the intra/inter charge group exclusions */
if (negptable > 0)
{
/* Read the special tables for certain energy group pairs */
- nm_ind = mtop->groups.grps[egcENER].nm_ind;
+ nm_ind = mtop->groups.groups[SimulationAtomGroupType::EnergyOutput].nm_ind;
for (egi = 0; egi < negp_pp; egi++)
{
for (egj = egi; egj < negp_pp; egj++)
}
/* Read the table file with the two energy groups names appended */
make_nbf_tables(fp, ic, rtab, tabfn,
- *mtop->groups.grpname[nm_ind[egi]],
- *mtop->groups.grpname[nm_ind[egj]],
+ *mtop->groups.groupNames[nm_ind[egi]],
+ *mtop->groups.groupNames[nm_ind[egj]],
&fr->nblists[m]);
m++;
}
init_ns(fp, cr, fr->ns, fr, mtop);
/* Initialize the thread working data for bonded interactions */
- init_bonded_threading(fp, mtop->groups.grps[egcENER].nr,
+ init_bonded_threading(fp, mtop->groups.groups[SimulationAtomGroupType::EnergyOutput].nr,
&fr->bondedThreading);
fr->nthread_ewc = gmx_omp_nthreads_get(emntBonded);
snew(md, 1);
mdAtoms->mdatoms_.reset(md);
- md->nenergrp = mtop.groups.grps[egcENER].nr;
+ md->nenergrp = mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].nr;
md->bVCMgrps = FALSE;
for (int i = 0; i < mtop.natoms; i++)
{
- if (getGroupType(mtop.groups, egcVCM, i) > 0)
+ if (getGroupType(mtop.groups, SimulationAtomGroupType::MassCenterVelocityRemoval, i) > 0)
{
md->bVCMgrps = TRUE;
}
opts = &ir->opts;
- const gmx_groups_t &groups = mtop->groups;
+ const SimulationGroups &groups = mtop->groups;
- auto md = mdAtoms->mdatoms();
+ auto md = mdAtoms->mdatoms();
/* nindex>=0 indicates DD where we use an index */
if (nindex >= 0)
{
* Therefore, when adding code, the user should use something like:
* gprnrU1 = (md->cU1==NULL ? 0 : md->cU1[localatindex])
*/
- if (mtop->groups.grpnr[egcUser1] != nullptr)
+ if (!mtop->groups.groupNumbers[SimulationAtomGroupType::User1].empty())
{
srenew(md->cU1, md->nalloc);
}
- if (mtop->groups.grpnr[egcUser2] != nullptr)
+ if (!mtop->groups.groupNumbers[SimulationAtomGroupType::User2].empty())
{
srenew(md->cU2, md->nalloc);
}
}
}
- int molb = 0;
+ int molb = 0;
nthreads = gmx_omp_nthreads_get(emntDefault);
#pragma omp parallel for num_threads(nthreads) schedule(static) firstprivate(molb)
if (md->cFREEZE)
{
- md->cFREEZE[i] = getGroupType(groups, egcFREEZE, ag);
+ md->cFREEZE[i] = getGroupType(groups, SimulationAtomGroupType::Freeze, ag);
}
if (EI_ENERGY_MINIMIZATION(ir->eI))
{
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.groupNumbers[SimulationAtomGroupType::TemperatureCoupling][ag] : 0];
mA = 0.5*atom.m*fac;
mB = 0.5*atom.mB*fac;
}
md->ptype[i] = atom.ptype;
if (md->cTC)
{
- md->cTC[i] = groups.grpnr[egcTC][ag];
+ md->cTC[i] = groups.groupNumbers[SimulationAtomGroupType::TemperatureCoupling][ag];
}
- md->cENER[i] = getGroupType(groups, egcENER, ag);
+ md->cENER[i] = getGroupType(groups, SimulationAtomGroupType::EnergyOutput, ag);
if (md->cACC)
{
- md->cACC[i] = groups.grpnr[egcACC][ag];
+ md->cACC[i] = groups.groupNumbers[SimulationAtomGroupType::Acceleration][ag];
}
if (md->cVCM)
{
- md->cVCM[i] = groups.grpnr[egcVCM][ag];
+ md->cVCM[i] = groups.groupNumbers[SimulationAtomGroupType::MassCenterVelocityRemoval][ag];
}
if (md->cORF)
{
- md->cORF[i] = getGroupType(groups, egcORFIT, ag);
+ md->cORF[i] = getGroupType(groups, SimulationAtomGroupType::OrientationRestraintsFit, ag);
}
if (md->cU1)
{
- md->cU1[i] = groups.grpnr[egcUser1][ag];
+ md->cU1[i] = groups.groupNumbers[SimulationAtomGroupType::User1][ag];
}
if (md->cU2)
{
- md->cU2[i] = groups.grpnr[egcUser2][ag];
+ md->cU2[i] = groups.groupNumbers[SimulationAtomGroupType::User2][ag];
}
if (ir->bQMMM)
{
- if (groups.grpnr[egcQMMM] == nullptr ||
- groups.grpnr[egcQMMM][ag] < groups.grps[egcQMMM].nr-1)
+ if (groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics].empty() ||
+ groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics][ag] < groups.groups[SimulationAtomGroupType::QuantumMechanics].nr-1)
{
md->bQM[i] = TRUE;
}
#include "gromacs/utility/smalloc.h"
struct gmx_mdoutf {
- t_fileio *fp_trn;
- t_fileio *fp_xtc;
- gmx_tng_trajectory_t tng;
- gmx_tng_trajectory_t tng_low_prec;
- int x_compression_precision; /* only used by XTC output */
- ener_file_t fp_ene;
- const char *fn_cpt;
- gmx_bool bKeepAndNumCPT;
- int eIntegrator;
- gmx_bool bExpanded;
- int elamstats;
- int simulation_part;
- FILE *fp_dhdl;
- int natoms_global;
- int natoms_x_compressed;
- gmx_groups_t *groups; /* for compressed position writing */
- gmx_wallcycle_t wcycle;
- rvec *f_global;
- gmx::IMDOutputProvider *outputProvider;
+ t_fileio *fp_trn;
+ t_fileio *fp_xtc;
+ gmx_tng_trajectory_t tng;
+ gmx_tng_trajectory_t tng_low_prec;
+ int x_compression_precision; /* only used by XTC output */
+ ener_file_t fp_ene;
+ const char *fn_cpt;
+ gmx_bool bKeepAndNumCPT;
+ int eIntegrator;
+ gmx_bool bExpanded;
+ int elamstats;
+ int simulation_part;
+ FILE *fp_dhdl;
+ int natoms_global;
+ int natoms_x_compressed;
+ SimulationGroups *groups; /* for compressed position writing */
+ gmx_wallcycle_t wcycle;
+ rvec *f_global;
+ gmx::IMDOutputProvider *outputProvider;
};
of->natoms_x_compressed = 0;
for (i = 0; (i < top_global->natoms); i++)
{
- if (getGroupType(*of->groups, egcCompressedX, i) == 0)
+ if (getGroupType(*of->groups, SimulationAtomGroupType::CompressedPositionOutput, i) == 0)
{
of->natoms_x_compressed++;
}
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, SimulationAtomGroupType::CompressedPositionOutput, i) == 0)
{
copy_rvec(x[i], xxtc[j++]);
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
/* Obtain the maximum and minimum coordinates of the group to be embedded */
static int init_ins_at(t_block *ins_at, t_block *rest_at, t_state *state, pos_ins_t *pos_ins,
- gmx_groups_t *groups, int ins_grp_id, real xy_max)
+ SimulationGroups *groups, int ins_grp_id, real xy_max)
{
int i, gid, c = 0;
real xmin, xmax, ymin, ymax, zmin, zmax;
for (i = 0; i < state->natoms; i++)
{
- gid = groups->grpnr[egcFREEZE][i];
- if (groups->grps[egcFREEZE].nm_ind[gid] == ins_grp_id)
+ gid = groups->groupNumbers[SimulationAtomGroupType::Freeze][i];
+ if (groups->groups[SimulationAtomGroupType::Freeze].nm_ind[gid] == ins_grp_id)
{
xmin = std::min(xmin, x[i][XX]);
xmax = std::max(xmax, x[i][XX]);
}
/*remove all lipids and waters overlapping and update all important structures (e.g. state and mtop)*/
-static void rm_group(gmx_groups_t *groups, gmx_mtop_t *mtop, rm_t *rm_p, t_state *state,
+static void rm_group(SimulationGroups *groups, gmx_mtop_t *mtop, rm_t *rm_p, t_state *state,
t_block *ins_at, pos_ins_t *pos_ins)
{
int j, k, n, rm, mol_id, at, block;
rvec *x_tmp, *v_tmp;
int *list;
- unsigned char *new_egrp[egcNR];
+ gmx::EnumerationArray < SimulationAtomGroupType, std::vector < unsigned char>> new_egrp;
gmx_bool bRM;
int RMmolblock;
snew(x_tmp, state->natoms);
snew(v_tmp, state->natoms);
- for (int i = 0; i < egcNR; i++)
+ for (auto group : keysOf(groups->groupNumbers))
{
- if (groups->grpnr[i] != nullptr)
+ if (!groups->groupNumbers[group].empty())
{
- groups->ngrpnr[i] = state->natoms;
- snew(new_egrp[i], state->natoms);
+ groups->groupNumbers[group].resize(state->natoms);
+ new_egrp[group].resize(state->natoms);
}
}
if (!bRM)
{
- for (j = 0; j < egcNR; j++)
+ for (auto group : keysOf(groups->groupNumbers))
{
- if (groups->grpnr[j] != nullptr)
+ if (!groups->groupNumbers[group].empty())
{
- new_egrp[j][i-rm] = groups->grpnr[j][i];
+ new_egrp[group][i-rm] = groups->groupNumbers[group][i];
}
}
copy_rvec(x[i], x_tmp[i-rm]);
}
sfree(v_tmp);
- for (int i = 0; i < egcNR; i++)
+ for (auto group : keysOf(groups->groupNumbers))
{
- if (groups->grpnr[i] != nullptr)
+ if (!groups->groupNumbers[group].empty())
{
- sfree(groups->grpnr[i]);
- groups->grpnr[i] = new_egrp[i];
+ groups->groupNumbers[group] = new_egrp[group];
}
}
resize(membed->r_ins, x, membed->pos_ins, membed->fac);
}
-/* We would like gn to be const as well, but C doesn't allow this */
-/* TODO this is utility functionality (search for the index of a
- string in a collection), so should be refactored and located more
- centrally. Also, it nearly duplicates the same string in readir.c */
-static int search_string(const char *s, int ng, char *gn[])
-{
- int i;
-
- for (i = 0; (i < ng); i++)
- {
- if (gmx_strcasecmp(s, gn[i]) == 0)
- {
- return i;
- }
- }
-
- gmx_fatal(FARGS,
- "Group %s selected for embedding was not found in the index file.\n"
- "Group names must match either [moleculetype] names or custom index group\n"
- "names, in which case you must supply an index file to the '-n' option\n"
- "of grompp.",
- s);
-}
-
gmx_membed_t *init_membed(FILE *fplog, int nfile, const t_filenm fnm[], gmx_mtop_t *mtop,
t_inputrec *inputrec, t_state *state, t_commrec *cr, real *cpt)
{
- char *ins, **gnames;
- int i, rm_bonded_at, fr_id, fr_i = 0, tmp_id, warn = 0;
- int ng, j, max_lip_rm, ins_grp_id, ntype, lip_rm;
- real prot_area;
- rvec *r_ins = nullptr;
- t_block *ins_at, *rest_at;
- pos_ins_t *pos_ins;
- mem_t *mem_p;
- rm_t *rm_p;
- gmx_groups_t *groups;
- gmx_bool bExcl = FALSE;
- t_atoms atoms;
- t_pbc *pbc;
- char **piecename = nullptr;
- gmx_membed_t *membed = nullptr;
+ char *ins;
+ int i, rm_bonded_at, fr_id, fr_i = 0, tmp_id, warn = 0;
+ int ng, j, max_lip_rm, ins_grp_id, ntype, lip_rm;
+ real prot_area;
+ rvec *r_ins = nullptr;
+ t_block *ins_at, *rest_at;
+ pos_ins_t *pos_ins;
+ mem_t *mem_p;
+ rm_t *rm_p;
+ SimulationGroups *groups;
+ gmx_bool bExcl = FALSE;
+ t_atoms atoms;
+ t_pbc *pbc;
+ char **piecename = nullptr;
+ gmx_membed_t *membed = nullptr;
/* input variables */
real xy_fac = 0.5;
*cpt = -1;
}
groups = &(mtop->groups);
- snew(gnames, groups->ngrpname);
- for (i = 0; i < groups->ngrpname; i++)
+ std::vector<std::string> gnames;
+ for (const auto &groupName : groups->groupNames)
{
- gnames[i] = *(groups->grpname[i]);
+ gnames.emplace_back(*groupName);
}
atoms = gmx_mtop_global_atoms(mtop);
snew(mem_p, 1);
fprintf(stderr, "\nSelect a group to embed in the membrane:\n");
get_index(&atoms, opt2fn_null("-mn", nfile, fnm), 1, &(ins_at->nr), &(ins_at->index), &ins);
- ins_grp_id = search_string(ins, groups->ngrpname, gnames);
+
+ auto found = std::find_if(gnames.begin(), gnames.end(),
+ [&ins](const auto &name)
+ { return gmx::equalCaseInsensitive(ins, name); });
+
+ if (found == gnames.end())
+ {
+ gmx_fatal(FARGS,
+ "Group %s selected for embedding was not found in the index file.\n"
+ "Group names must match either [moleculetype] names or custom index group\n"
+ "names, in which case you must supply an index file to the '-n' option\n"
+ "of grompp.", ins);
+ }
+ else
+ {
+ ins_grp_id = std::distance(gnames.begin(), found);
+ }
fprintf(stderr, "\nSelect a group to embed %s into (e.g. the membrane):\n", ins);
get_index(&atoms, opt2fn_null("-mn", nfile, fnm), 1, &(mem_p->mem_at.nr), &(mem_p->mem_at.index), &(mem_p->name));
for (i = 0; i < inputrec->opts.ngfrz; i++)
{
- tmp_id = mtop->groups.grps[egcFREEZE].nm_ind[i];
+ tmp_id = mtop->groups.groups[SimulationAtomGroupType::Freeze].nm_ind[i];
if (ins_grp_id == tmp_id)
{
fr_id = tmp_id;
}
}
- ng = groups->grps[egcENER].nr;
+ ng = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
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->grps[egcENER].nm_ind[i] != ins_grp_id) ||
- (groups->grps[egcENER].nm_ind[j] != ins_grp_id) )
+ if ( (groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i] != ins_grp_id) ||
+ (groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[j] != ins_grp_id) )
{
gmx_fatal(FARGS, "Energy exclusions \"%s\" and \"%s\" do not match the group "
- "to embed \"%s\"", *groups->grpname[groups->grps[egcENER].nm_ind[i]],
- *groups->grpname[groups->grps[egcENER].nm_ind[j]], ins);
+ "to embed \"%s\"", *groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i]],
+ *groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[j]], ins);
}
}
}
nr_in_cg, maxcg);
}
- ngid = mtop->groups.grps[egcENER].nr;
+ ngid = mtop->groups.groups[SimulationAtomGroupType::EnergyOutput].nr;
snew(ns->bExcludeAlleg, ngid);
for (i = 0; i < ngid; i++)
{
sfree(ns);
}
-int search_neighbours(FILE *log,
- t_forcerec *fr,
- matrix box,
- gmx_localtop_t *top,
- const gmx_groups_t *groups,
- const t_commrec *cr,
- t_nrnb *nrnb,
- const t_mdatoms *md,
- gmx_bool bFillGrid)
+int search_neighbours(FILE *log,
+ t_forcerec *fr,
+ matrix box,
+ gmx_localtop_t *top,
+ const SimulationGroups *groups,
+ const t_commrec *cr,
+ t_nrnb *nrnb,
+ const t_mdatoms *md,
+ gmx_bool bFillGrid)
{
const t_block *cgs = &(top->cgs);
rvec box_size, grid_x0, grid_x1;
/* Set some local variables */
bGrid = fr->bGrid;
- ngid = groups->grps[egcENER].nr;
+ ngid = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
for (m = 0; (m < DIM); m++)
{
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/math/vectypes.h"
#include "gromacs/utility/basedefinitions.h"
-struct gmx_groups_t;
+struct SimulationGroups;
struct gmx_localtop_t;
struct gmx_mtop_t;
struct gmx_ns_t;
//! Destructor.
void done_ns(gmx_ns_t *ns, int numEnergyGroups);
-int search_neighbours(FILE *log,
- t_forcerec *fr,
- matrix box,
- gmx_localtop_t *top,
- const gmx_groups_t *groups,
- const t_commrec *cr,
- t_nrnb *nrnb,
- const t_mdatoms *md,
- gmx_bool bFillGrid);
+int search_neighbours(FILE *log,
+ t_forcerec *fr,
+ matrix box,
+ gmx_localtop_t *top,
+ const SimulationGroups *groups,
+ const t_commrec *cr,
+ t_nrnb *nrnb,
+ const t_mdatoms *md,
+ gmx_bool bFillGrid);
/* Debugging routines from wnblist.c */
std::vector<int> qmmmAtomIndices(const t_inputrec &ir, const gmx_mtop_t &mtop)
{
- const int numQmmmGroups = ir.opts.ngQM;
- const gmx_groups_t &groups = mtop.groups;
- std::vector<int> qmmmAtoms;
+ const int numQmmmGroups = ir.opts.ngQM;
+ const SimulationGroups &groups = mtop.groups;
+ std::vector<int> qmmmAtoms;
for (int i = 0; i < numQmmmGroups; i++)
{
for (const AtomProxy atomP : AtomRange(mtop))
{
int index = atomP.globalAtomNumber();
- if (getGroupType(groups, egcQMMM, index) == i)
+ if (getGroupType(groups, SimulationAtomGroupType::QuantumMechanics, index) == i)
{
qmmmAtoms.push_back(index);
}
const int vsite = atomOffset + ilist.iatoms[j ]; /* the vsite */
const int ai = atomOffset + ilist.iatoms[j+1]; /* constructing atom */
const int aj = atomOffset + ilist.iatoms[j+2]; /* constructing atom */
- if (getGroupType(groups, egcQMMM, vsite) == getGroupType(groups, egcQMMM, ai)
+ if (getGroupType(groups, SimulationAtomGroupType::QuantumMechanics, vsite) == getGroupType(groups, SimulationAtomGroupType::QuantumMechanics, ai)
&&
- getGroupType(groups, egcQMMM, vsite) == getGroupType(groups, egcQMMM, aj))
+ getGroupType(groups, SimulationAtomGroupType::QuantumMechanics, vsite) == getGroupType(groups, SimulationAtomGroupType::QuantumMechanics, aj))
{
/* this dummy link atom needs to be removed from qmmmAtoms
* before making the QMrec of this layer!
nullptr, nullptr, gmx::ConstraintVariable::Deriv_FlexCon);
}
-void relax_shell_flexcon(FILE *fplog,
- const t_commrec *cr,
- const gmx_multisim_t *ms,
- gmx_bool bVerbose,
- gmx_enfrot *enforcedRotation,
- int64_t mdstep,
- const t_inputrec *inputrec,
- gmx_bool bDoNS,
- int force_flags,
- gmx_localtop_t *top,
- gmx::Constraints *constr,
- gmx_enerdata_t *enerd,
- t_fcdata *fcd,
- t_state *state,
- gmx::ArrayRefWithPadding<gmx::RVec> f,
- tensor force_vir,
- const t_mdatoms *md,
- t_nrnb *nrnb,
- gmx_wallcycle_t wcycle,
- t_graph *graph,
- const gmx_groups_t *groups,
- gmx_shellfc_t *shfc,
- t_forcerec *fr,
- gmx::PpForceWorkload *ppForceWorkload,
- double t,
- rvec mu_tot,
- const gmx_vsite_t *vsite,
- const DDBalanceRegionHandler &ddBalanceRegionHandler)
+void relax_shell_flexcon(FILE *fplog,
+ const t_commrec *cr,
+ const gmx_multisim_t *ms,
+ gmx_bool bVerbose,
+ gmx_enfrot *enforcedRotation,
+ int64_t mdstep,
+ const t_inputrec *inputrec,
+ gmx_bool bDoNS,
+ int force_flags,
+ gmx_localtop_t *top,
+ gmx::Constraints *constr,
+ gmx_enerdata_t *enerd,
+ t_fcdata *fcd,
+ t_state *state,
+ gmx::ArrayRefWithPadding<gmx::RVec> f,
+ tensor force_vir,
+ const t_mdatoms *md,
+ t_nrnb *nrnb,
+ gmx_wallcycle_t wcycle,
+ t_graph *graph,
+ const SimulationGroups *groups,
+ gmx_shellfc_t *shfc,
+ t_forcerec *fr,
+ gmx::PpForceWorkload *ppForceWorkload,
+ double t,
+ rvec mu_tot,
+ const gmx_vsite_t *vsite,
+ const DDBalanceRegionHandler &ddBalanceRegionHandler)
{
int nshell;
t_shell *shell;
class DDBalanceRegionHandler;
struct gmx_enerdata_t;
struct gmx_enfrot;
-struct gmx_groups_t;
+struct SimulationGroups;
struct gmx_multisim_t;
struct gmx_shellfc_t;
struct gmx_mtop_t;
gmx_shellfc_t *shfc);
/* Optimize shell positions */
-void relax_shell_flexcon(FILE *log,
- const t_commrec *cr,
- const gmx_multisim_t *ms,
- gmx_bool bVerbose,
- gmx_enfrot *enforcedRotation,
- int64_t mdstep,
- const t_inputrec *inputrec,
- gmx_bool bDoNS,
- int force_flags,
- gmx_localtop_t *top,
- gmx::Constraints *constr,
- gmx_enerdata_t *enerd,
- t_fcdata *fcd,
- t_state *state,
- gmx::ArrayRefWithPadding<gmx::RVec> f,
- tensor force_vir,
- const t_mdatoms *md,
- t_nrnb *nrnb,
- gmx_wallcycle_t wcycle,
- t_graph *graph,
- const gmx_groups_t *groups,
- gmx_shellfc_t *shfc,
- t_forcerec *fr,
- gmx::PpForceWorkload *ppForceWorkload,
- double t,
- rvec mu_tot,
- const gmx_vsite_t *vsite,
- const DDBalanceRegionHandler &ddBalanceRegionHandler);
+void relax_shell_flexcon(FILE *log,
+ const t_commrec *cr,
+ const gmx_multisim_t *ms,
+ gmx_bool bVerbose,
+ gmx_enfrot *enforcedRotation,
+ int64_t mdstep,
+ const t_inputrec *inputrec,
+ gmx_bool bDoNS,
+ int force_flags,
+ gmx_localtop_t *top,
+ gmx::Constraints *constr,
+ gmx_enerdata_t *enerd,
+ t_fcdata *fcd,
+ t_state *state,
+ gmx::ArrayRefWithPadding<gmx::RVec> f,
+ tensor force_vir,
+ const t_mdatoms *md,
+ t_nrnb *nrnb,
+ gmx_wallcycle_t wcycle,
+ t_graph *graph,
+ const SimulationGroups *groups,
+ gmx_shellfc_t *shfc,
+ t_forcerec *fr,
+ gmx::PpForceWorkload *ppForceWorkload,
+ double t,
+ rvec mu_tot,
+ const gmx_vsite_t *vsite,
+ const DDBalanceRegionHandler &ddBalanceRegionHandler);
/* Print some final output */
void done_shellfc(FILE *fplog, gmx_shellfc_t *shellfc, int64_t numSteps);
t_nrnb *nrnb,
gmx_wallcycle_t wcycle,
const gmx_localtop_t *top,
- const gmx_groups_t * /* groups */,
+ const SimulationGroups * /* groups */,
matrix box, gmx::ArrayRefWithPadding<gmx::RVec> x,
history_t *hist,
gmx::ArrayRefWithPadding<gmx::RVec> force,
t_nrnb *nrnb,
gmx_wallcycle_t wcycle,
gmx_localtop_t *top,
- const gmx_groups_t *groups,
+ const SimulationGroups *groups,
matrix box, gmx::ArrayRefWithPadding<gmx::RVec> x,
history_t *hist,
gmx::ArrayRefWithPadding<gmx::RVec> force,
}
-void do_force(FILE *fplog,
- const t_commrec *cr,
- const gmx_multisim_t *ms,
- const t_inputrec *inputrec,
- gmx::Awh *awh,
- gmx_enfrot *enforcedRotation,
- int64_t step,
- t_nrnb *nrnb,
- gmx_wallcycle_t wcycle,
- gmx_localtop_t *top,
- const gmx_groups_t *groups,
- matrix box,
- gmx::ArrayRefWithPadding<gmx::RVec> x, //NOLINT(performance-unnecessary-value-param)
- history_t *hist,
- gmx::ArrayRefWithPadding<gmx::RVec> force, //NOLINT(performance-unnecessary-value-param)
- tensor vir_force,
- const t_mdatoms *mdatoms,
- gmx_enerdata_t *enerd,
- t_fcdata *fcd,
- gmx::ArrayRef<real> lambda,
- t_graph *graph,
- t_forcerec *fr,
- gmx::PpForceWorkload *ppForceWorkload,
- const gmx_vsite_t *vsite,
- rvec mu_tot,
- double t,
- gmx_edsam *ed,
- int flags,
- const DDBalanceRegionHandler &ddBalanceRegionHandler)
+void do_force(FILE *fplog,
+ const t_commrec *cr,
+ const gmx_multisim_t *ms,
+ const t_inputrec *inputrec,
+ gmx::Awh *awh,
+ gmx_enfrot *enforcedRotation,
+ int64_t step,
+ t_nrnb *nrnb,
+ gmx_wallcycle_t wcycle,
+ gmx_localtop_t *top,
+ const SimulationGroups *groups,
+ matrix box,
+ gmx::ArrayRefWithPadding<gmx::RVec> x, //NOLINT(performance-unnecessary-value-param)
+ history_t *hist,
+ gmx::ArrayRefWithPadding<gmx::RVec> force, //NOLINT(performance-unnecessary-value-param)
+ tensor vir_force,
+ const t_mdatoms *mdatoms,
+ gmx_enerdata_t *enerd,
+ t_fcdata *fcd,
+ gmx::ArrayRef<real> lambda,
+ t_graph *graph,
+ t_forcerec *fr,
+ gmx::PpForceWorkload *ppForceWorkload,
+ const gmx_vsite_t *vsite,
+ rvec mu_tot,
+ double t,
+ gmx_edsam *ed,
+ int flags,
+ const DDBalanceRegionHandler &ddBalanceRegionHandler)
{
/* modify force flag if not doing nonbonded */
if (!fr->bNonbonded)
{
if (ngacc > 0)
{
- const gmx_groups_t &groups = mtop->groups;
+ const SimulationGroups &groups = mtop->groups;
for (const AtomProxy atomP : AtomRange(*mtop))
{
const t_atom &local = atomP.atom();
int i = atomP.globalAtomNumber();
- int grp = getGroupType(groups, egcACC, i);
+ int grp = getGroupType(groups, SimulationAtomGroupType::Acceleration, i);
if ((grp < 0) && (grp >= ngacc))
{
gmx_incons("Input for acceleration groups wrong");
const rvec x[], rvec xprime[], rvec v[], const rvec f[],
int64_t step, int seed, const int *gatindex)
{
- // cTC, cACC and cFreeze can be nullptr any time, but various
+ // cTC, cACC and cFREEZE can be nullptr any time, but various
// instantiations do not make sense with particular pointer
// values.
if (updateType == SDUpdate::ForcesOnly)
#include "gromacs/utility/gmxomp.h"
#include "gromacs/utility/smalloc.h"
-t_vcm::t_vcm(const gmx_groups_t &groups, const t_inputrec &ir)
+t_vcm::t_vcm(const SimulationGroups &groups, const t_inputrec &ir)
{
mode = (ir.nstcomm > 0) ? ir.comm_mode : ecmNO;
ndim = ndof_com(&ir);
if (mode != ecmNO)
{
- nr = groups.grps[egcVCM].nr;
+ nr = groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nr;
/* 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.grpname[groups.grps[egcVCM].nm_ind[g]];
+ group_name[g] = *groups.groupNames[groups.groups[SimulationAtomGroupType::MassCenterVelocityRemoval].nm_ind[g]];
}
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
-struct gmx_groups_t;
+struct SimulationGroups;
struct t_inputrec;
struct t_mdatoms;
ivec *nFreeze; /* Tells whether dimensions are frozen per freeze group */
std::vector<t_vcm_thread> thread_vcm; /* Temporary data per thread and group */
- t_vcm(const gmx_groups_t &groups, const t_inputrec &ir);
+ t_vcm(const SimulationGroups &groups, const t_inputrec &ir);
~t_vcm();
};
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2008, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
void make_wall_tables(FILE *fplog,
const t_inputrec *ir, const char *tabfn,
- const gmx_groups_t *groups,
+ const SimulationGroups *groups,
t_forcerec *fr)
{
int negp_pp;
char buf[STRLEN];
negp_pp = ir->opts.ngener - ir->nwall;
- nm_ind = groups->grps[egcENER].nm_ind;
+ nm_ind = groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind;
if (fplog)
{
{
sprintf(buf, "%s", tabfn);
sprintf(buf + strlen(tabfn) - strlen(ftp2ext(efXVG)) - 1, "_%s_%s.%s",
- *groups->grpname[nm_ind[egp]],
- *groups->grpname[nm_ind[negp_pp+w]],
+ *groups->groupNames[nm_ind[egp]],
+ *groups->groupNames[nm_ind[negp_pp+w]],
ftp2ext(efXVG));
fr->wall_tab[w][egp] = make_tables(fplog, fr->ic, buf, 0,
GMX_MAKETABLES_FORCEUSER);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/math/vectypes.h"
-struct gmx_groups_t;
+struct SimulationGroups;
struct t_forcerec;
struct t_idef;
struct t_inputrec;
void make_wall_tables(FILE *fplog,
const t_inputrec *ir, const char *tabfn,
- const gmx_groups_t *groups,
+ const SimulationGroups *groups,
t_forcerec *fr);
real do_walls(const t_inputrec &ir,
PaddedVector<gmx::RVec> f {};
gmx_global_stat_t gstat;
t_graph *graph = nullptr;
- gmx_groups_t *groups;
gmx_shellfc_t *shellfc;
gmx_bool bSumEkinhOld, bDoReplEx, bExchanged, bNeedRepartition;
gmx_bool bTemp, bPres, bTrotter;
nstglobalcomm = check_nstglobalcomm(mdlog, nstglobalcomm, ir, cr);
bGStatEveryStep = (nstglobalcomm == 1);
- groups = &top_global->groups;
+ SimulationGroups *groups = &top_global->groups;
std::unique_ptr<EssentialDynamics> ed = nullptr;
if (opt2bSet("-ei", nfile, fnm) || observablesHistory->edsamHistory != nullptr)
ir->nstcalcenergy, DOMAINDECOMP(cr));
{
- double io = compute_io(ir, top_global->natoms, groups, energyOutput.numEnergyTerms(), 1);
+ double io = compute_io(ir, top_global->natoms, *groups, energyOutput.numEnergyTerms(), 1);
if ((io > 2000) && MASTER(cr))
{
fprintf(stderr,
PaddedVector<gmx::RVec> f {};
gmx_global_stat_t gstat;
t_graph *graph = nullptr;
- gmx_groups_t *groups;
gmx_shellfc_t *shellfc;
double cycles;
}
ir->nstxout_compressed = 0;
- groups = &top_global->groups;
+ SimulationGroups *groups = &top_global->groups;
top_global->intermolecularExclusionGroup = genQmmmIndices(*top_global);
initialize_lambdas(fplog, *ir, MASTER(cr), &state_global->fep_state, state_global->lambda, lam0);
ir->nstcalcenergy, DOMAINDECOMP(cr));
{
- double io = compute_io(ir, top_global->natoms, groups, energyOutput.numEnergyTerms(), 1);
+ double io = compute_io(ir, top_global->natoms, *groups, energyOutput.numEnergyTerms(), 1);
if ((io > 2000) && MASTER(cr))
{
fprintf(stderr,
} // namespace
//! Parallel utility summing energies and forces
-static double reorder_partsum(const t_commrec *cr, t_grpopts *opts, t_mdatoms *mdatoms,
+static double reorder_partsum(const t_commrec *cr, t_grpopts *opts,
gmx_mtop_t *top_global,
em_state_t *s_min, em_state_t *s_b)
{
t_block *cgs_gl;
int ncg, *cg_gl, *index, c, cg, i, a0, a1, a, gf, m;
double partsum;
- unsigned char *grpnrFREEZE;
if (debug)
{
partsum = 0;
i = 0;
gf = 0;
- grpnrFREEZE = top_global->groups.grpnr[egcFREEZE];
+ gmx::ArrayRef<unsigned char> grpnrFREEZE = top_global->groups.groupNumbers[SimulationAtomGroupType::Freeze];
for (c = 0; c < ncg; c++)
{
cg = cg_gl[c];
a1 = index[cg+1];
for (a = a0; a < a1; a++)
{
- if (mdatoms->cFREEZE && grpnrFREEZE)
+ if (!grpnrFREEZE.empty())
{
gf = grpnrFREEZE[i];
}
else
{
/* We need to reorder cgs while summing */
- sum = reorder_partsum(cr, opts, mdatoms, top_global, s_min, s_b);
+ sum = reorder_partsum(cr, opts, top_global, s_min, s_b);
}
if (PAR(cr))
{
PaddedVector<gmx::RVec> f {};
gmx_global_stat_t gstat;
t_graph *graph = nullptr;
- gmx_groups_t *groups;
gmx_shellfc_t *shellfc;
double cycles;
const bool bNS = true;
ir->nstxout_compressed = 0;
- groups = &top_global->groups;
+ SimulationGroups *groups = &top_global->groups;
if (ir->eI == eiMimic)
{
top_global->intermolecularExclusionGroup = genQmmmIndices(*top_global);
ir->nstcalcenergy, DOMAINDECOMP(cr));
{
- double io = compute_io(ir, top_global->natoms, groups, energyOutput.numEnergyTerms(), 1);
+ double io = compute_io(ir, top_global->natoms, *groups, energyOutput.numEnergyTerms(), 1);
if ((io > 2000) && MASTER(cr))
{
fprintf(stderr,
/* Energy terms and groups */
gmx_enerdata_t *enerd;
snew(enerd, 1);
- init_enerdata(mtop.groups.grps[egcENER].nr, inputrec->fepvals->n_lambda, enerd);
+ init_enerdata(mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].nr, inputrec->fepvals->n_lambda, enerd);
if (DOMAINDECOMP(cr))
{
free_gpu_resources(fr, physicalNodeComm);
free_gpu(nonbondedDeviceInfo);
free_gpu(pmeDeviceInfo);
- done_forcerec(fr, mtop.molblock.size(), mtop.groups.grps[egcENER].nr);
+ done_forcerec(fr, mtop.molblock.size(), mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].nr);
sfree(fcd);
if (doMembed)
Integrator::do_tpi()
{
gmx_localtop_t top;
- gmx_groups_t *groups;
PaddedVector<gmx::RVec> f {};
real lambda, t, temp, beta, drmax, epot;
double embU, sum_embU, *sum_UgembU, V, V_all, VembU_all;
gmx_mtop_generate_local_top(*top_global, &top, inputrec->efep != efepNO);
- groups = &top_global->groups;
+ SimulationGroups *groups = &top_global->groups;
bCavity = (inputrec->eI == eiTPIC);
if (bCavity)
}
}
- ngid = groups->grps[egcENER].nr;
+ ngid = groups->groups[SimulationAtomGroupType::EnergyOutput].nr;
gid_tp = GET_CGINFO_GID(fr->cginfo[cg_tp]);
nener = 1 + ngid;
if (bDispCorr)
for (i = 0; i < ngid; i++)
{
sprintf(str, "f. <U\\sVdW %s\\Ne\\S-\\betaU\\N>",
- *(groups->grpname[groups->grps[egcENER].nm_ind[i]]));
+ *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[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->grpname[groups->grps[egcENER].nm_ind[i]]));
+ *(groups->groupNames[groups->groups[SimulationAtomGroupType::EnergyOutput].nm_ind[i]]));
leg[e++] = gmx_strdup(str);
}
if (bRFExcl)
std::vector<int> genQmmmIndices(const gmx_mtop_t &mtop)
{
- std::vector<int> output;
- int global_at = 0;
- unsigned char *grpnr = mtop.groups.grpnr[egcQMMM];
+ std::vector<int> output;
+ int global_at = 0;
+ const unsigned char *grpnr = mtop.groups.groupNumbers[SimulationAtomGroupType::QuantumMechanics].data();
for (const gmx_molblock_t &molb : mtop.molblock)
{
for (int mol = 0; mol < molb.nmol; ++mol)
ir->eI == eiBD);
/* In parallel, store we need to extract localWeights from weights at DD time */
- std::vector<real> &weights = ((cr && PAR(cr)) ? pg->globalWeights : pg->localWeights);
+ std::vector<real> &weights = ((cr && PAR(cr)) ? pg->globalWeights : pg->localWeights);
- const gmx_groups_t &groups = mtop->groups;
+ const SimulationGroups &groups = mtop->groups;
/* Count frozen dimensions and (weighted) mass */
int nfrozen = 0;
for (int d = 0; d < DIM; d++)
{
if (pulldim_con[d] == 1 &&
- ir->opts.nFreeze[getGroupType(groups, egcFREEZE, ii)][d])
+ ir->opts.nFreeze[getGroupType(groups, SimulationAtomGroupType::Freeze, ii)][d])
{
nfrozen++;
}
}
else
{
- if (groups.grpnr[egcTC] == nullptr)
+ if (groups.groupNumbers[SimulationAtomGroupType::TemperatureCoupling].empty())
{
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.groupNumbers[SimulationAtomGroupType::TemperatureCoupling][ii]];
}
}
w *= m/mbd;
gmx_bool bOriginalInputrec)
{
FILE *gp;
- int indent, i, j, **gcount, atot;
+ int indent, atot;
t_state state;
t_tpxheader tpx;
gmx_mtop_t mtop;
pr_rvecs(stdout, indent, "v", tpx.bV ? state.v.rvec_array() : nullptr, state.natoms);
}
- const gmx_groups_t &groups = mtop.groups;
+ const SimulationGroups &groups = mtop.groups;
- snew(gcount, egcNR);
- for (i = 0; (i < egcNR); i++)
+ gmx::EnumerationArray < SimulationAtomGroupType, std::vector < int>> gcount;
+ for (auto group : keysOf(gcount))
{
- snew(gcount[i], groups.grps[i].nr);
+ gcount[group].resize(groups.groups[group].nr);
}
- for (i = 0; (i < mtop.natoms); i++)
+ for (int i = 0; (i < mtop.natoms); i++)
{
- for (j = 0; (j < egcNR); j++)
+ for (auto group : keysOf(gcount))
{
- gcount[j][getGroupType(groups, j, i)]++;
+ gcount[group][getGroupType(groups, group, i)]++;
}
}
printf("Group statistics\n");
- for (i = 0; (i < egcNR); i++)
+ for (auto group : keysOf(gcount))
{
atot = 0;
- printf("%-12s: ", gtypes[i]);
- for (j = 0; (j < groups.grps[i].nr); j++)
+ printf("%-12s: ", shortName(group));
+ for (int j = 0; (j < groups.groups[group].nr); j++)
{
- printf(" %5d", gcount[i][j]);
- atot += gcount[i][j];
+ printf(" %5d", gcount[group][j]);
+ atot += gcount[group][j];
}
printf(" (total %d atoms)\n", atot);
- sfree(gcount[i]);
}
- sfree(gcount);
}
}
#include "gromacs/utility/strconvert.h"
#include "gromacs/utility/txtdump.h"
-const char *gtypes[egcNR+1] = {
- "T-Coupling", "Energy Mon.", "Acceleration", "Freeze",
- "User1", "User2", "VCM", "Compressed X", "Or. Res. Fit", "QMMM", nullptr
-};
+gmx::EnumerationArray<SimulationAtomGroupType, const char *>
+c_simulationAtomGroupTypeShortNames
+ = { {
+ "T-Coupling",
+ "Energy Mon.",
+ "Acceleration",
+ "Freeze",
+ "User1",
+ "User2",
+ "VCM",
+ "Compressed X",
+ "Or. Res. Fit",
+ "QMMM"
+ } };
-static void init_groups(gmx_groups_t *groups)
+const char *shortName(SimulationAtomGroupType type)
{
- groups->ngrpname = 0;
- groups->grpname = nullptr;
- for (int g = 0; g < egcNR; g++)
+ return c_simulationAtomGroupTypeShortNames[type];
+}
+
+SimulationGroups::SimulationGroups()
+{
+ for (auto group : keysOf(groups))
{
- groups->grps[g].nr = 0;
- groups->grps[g].nm_ind = nullptr;
- groups->ngrpnr[g] = 0;
- groups->grpnr[g] = nullptr;
+ groups[group].nr = 0;
+ groups[group].nm_ind = nullptr;
}
}
done_blocka(&excls);
}
-void done_gmx_groups_t(gmx_groups_t *g)
+SimulationGroups::~SimulationGroups()
{
- int i;
-
- for (i = 0; (i < egcNR); i++)
+ for (auto group : keysOf(groups))
{
- if (nullptr != g->grps[i].nm_ind)
+ if (nullptr != groups[group].nm_ind)
{
- sfree(g->grps[i].nm_ind);
- g->grps[i].nm_ind = nullptr;
- }
- if (nullptr != g->grpnr[i])
- {
- sfree(g->grpnr[i]);
- g->grpnr[i] = nullptr;
+ sfree(groups[group].nm_ind);
+ groups[group].nm_ind = nullptr;
}
}
- /* The contents of this array is in symtab, don't free it here */
- sfree(g->grpname);
}
gmx_mtop_t::gmx_mtop_t()
{
init_atomtypes(&atomtypes);
- init_groups(&groups);
open_symtab(&symtab);
}
moltype.clear();
molblock.clear();
done_atomtypes(&atomtypes);
- done_gmx_groups_t(&groups);
}
void done_top(t_topology *top)
return mtop->moltype.empty() || mtop->moltype[0].atoms.havePdbInfo;
}
-static void pr_grps(FILE *fp, const char *title, const t_grps grps[], char **grpname[])
+static void pr_grps(FILE *fp,
+ const char *title,
+ gmx::ArrayRef<const t_grps> grps,
+ char ***grpname)
{
- int i, j;
-
- for (i = 0; (i < egcNR); i++)
+ int index = 0;
+ for (const auto &group : grps)
{
- fprintf(fp, "%s[%-12s] nr=%d, name=[", title, gtypes[i], grps[i].nr);
- for (j = 0; (j < grps[i].nr); j++)
+ fprintf(fp, "%s[%-12s] nr=%d, name=[", title, c_simulationAtomGroupTypeShortNames[index], group.nr);
+ for (int j = 0; (j < group.nr); j++)
{
- fprintf(fp, " %s", *(grpname[grps[i].nm_ind[j]]));
+ fprintf(fp, " %s", *(grpname[group.nm_ind[j]]));
}
fprintf(fp, "]\n");
+ index++;
}
}
static void pr_groups(FILE *fp, int indent,
- const gmx_groups_t *groups,
+ const SimulationGroups &groups,
gmx_bool bShowNumbers)
{
- int nat_max, i, g;
-
- pr_grps(fp, "grp", groups->grps, groups->grpname);
- pr_strings(fp, indent, "grpname", groups->grpname, groups->ngrpname, bShowNumbers);
+ pr_grps(fp,
+ "grp",
+ groups.groups,
+ const_cast<char ***>(groups.groupNames.data()));
+ pr_strings(fp, indent, "grpname", const_cast<char ***>(groups.groupNames.data()), groups.groupNames.size(), bShowNumbers);
pr_indent(fp, indent);
fprintf(fp, "groups ");
- for (g = 0; g < egcNR; g++)
+ for (const auto &group : c_simulationAtomGroupTypeShortNames)
{
- printf(" %5.5s", gtypes[g]);
+ printf(" %5.5s", group);
}
printf("\n");
pr_indent(fp, indent);
fprintf(fp, "allocated ");
- nat_max = 0;
- for (g = 0; g < egcNR; g++)
+ int nat_max = 0;
+ for (auto group : keysOf(groups.groups))
{
- printf(" %5d", groups->ngrpnr[g]);
- nat_max = std::max(nat_max, groups->ngrpnr[g]);
+ printf(" %5d", groups.numberOfGroupNumbers(group));
+ nat_max = std::max(nat_max, groups.numberOfGroupNumbers(group));
}
printf("\n");
{
pr_indent(fp, indent);
fprintf(fp, "groupnr[%5s] =", "*");
- for (g = 0; g < egcNR; g++)
+ for (auto gmx_unused group : keysOf(groups.groups))
{
fprintf(fp, " %3d ", 0);
}
}
else
{
- for (i = 0; i < nat_max; i++)
+ for (int i = 0; i < nat_max; i++)
{
pr_indent(fp, indent);
fprintf(fp, "groupnr[%5d] =", i);
- for (g = 0; g < egcNR; g++)
+ for (auto group : keysOf(groups.groups))
{
fprintf(fp, " %3d ",
- groups->grpnr[g] ? groups->grpnr[g][i] : 0);
+ !groups.groupNumbers[group].empty() ?
+ groups.groupNumbers[group][i] : 0);
}
fprintf(fp, "\n");
}
pr_moltype(fp, indent, "moltype", &mtop->moltype[mt], mt,
&mtop->ffparams, bShowNumbers, bShowParameters);
}
- pr_groups(fp, indent, &mtop->groups, bShowNumbers);
+ pr_groups(fp, indent, mtop->groups, bShowNumbers);
}
}
compareMoletypeAB(fp, mtop1.moltype, relativeTolerance, absoluteTolerance);
}
-void compareAtomGroups(FILE *fp, const gmx_groups_t &g0, const gmx_groups_t &g1,
+void compareAtomGroups(FILE *fp, const SimulationGroups &g0, const SimulationGroups &g1,
int natoms0, int natoms1)
{
fprintf(fp, "comparing groups\n");
- for (int i = 0; i < egcNR; i++)
+ for (auto group : keysOf(g0.groups))
{
- 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)
+ 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)
{
- for (int j = 0; j < g0.grps[i].nr; j++)
+ for (int j = 0; j < g0.groups[group].nr; j++)
{
- buf = gmx::formatString("grps[%d].name[%d]", i, j);
+ buf = gmx::formatString("grps[%d].name[%d]", static_cast<int>(group), j);
cmp_str(fp, buf.c_str(), -1,
- *g0.grpname[g0.grps[i].nm_ind[j]],
- *g1.grpname[g1.grps[i].nm_ind[j]]);
+ *g0.groupNames[g0.groups[group].nm_ind[j]],
+ *g1.groupNames[g1.groups[group].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", static_cast<int>(group), g0.numberOfGroupNumbers(group), g1.numberOfGroupNumbers(group));
+ if (g0.numberOfGroupNumbers(group) == g1.numberOfGroupNumbers(group) && natoms0 == natoms1 &&
+ (!g0.groupNumbers[group].empty() || !g1.groupNumbers[group].empty()))
{
for (int j = 0; j < natoms0; j++)
{
- cmp_int(fp, gtypes[i], j, getGroupType(g0, i, j), getGroupType(g1, i, j));
+ cmp_int(fp, c_simulationAtomGroupTypeShortNames[group], j, getGroupType(g0, group, j), getGroupType(g1, group, j));
}
}
}
*/
}
-int getGroupType(const gmx_groups_t &group, int type, int atom)
+int getGroupType(const SimulationGroups &group, SimulationAtomGroupType type, int atom)
{
- return (group.grpnr[type] ? group.grpnr[type][atom] : 0);
+ return (group.groupNumbers[type].empty() ? 0 : group.groupNumbers[type][atom]);
}
void copy_moltype(const gmx_moltype_t *src, gmx_moltype_t *dst)
#include "gromacs/topology/forcefieldparameters.h"
#include "gromacs/topology/idef.h"
#include "gromacs/topology/symtab.h"
+#include "gromacs/utility/enumerationhelpers.h"
#include "gromacs/utility/unique_cptr.h"
-enum
+enum class SimulationAtomGroupType : int
{
- egcTC, egcENER, egcACC, egcFREEZE,
- egcUser1, egcUser2, egcVCM, egcCompressedX,
- egcORFIT, egcQMMM,
- egcNR
+ TemperatureCoupling,
+ EnergyOutput,
+ Acceleration,
+ Freeze,
+ User1,
+ User2,
+ MassCenterVelocityRemoval,
+ CompressedPositionOutput,
+ OrientationRestraintsFit,
+ QuantumMechanics,
+ Count
};
-/* Names corresponding to groups */
-extern const char *gtypes[egcNR+1];
+
+//! Short strings used for describing atom groups in log and energy files
+const char *shortName(SimulationAtomGroupType type);
+
+//const char *shortName(int type); // if necessary
/*! \brief Molecules type data: atoms, interactions and exclusions */
struct gmx_moltype_t
int moleculeIndexStart; /**< Global molecule indexing starts from this value */
};
-typedef struct gmx_groups_t
+/*! \brief Contains the simulation atom groups.
+ *
+ * Organized as containers for the different
+ * SimulationAtomGroupTypes
+ */
+struct SimulationGroups
{
- t_grps grps[egcNR]; /* Groups of things */
- int ngrpname; /* Number of groupnames */
- char ***grpname; /* Names of the groups */
- int ngrpnr[egcNR];
- unsigned char *grpnr[egcNR]; /* Group numbers or NULL */
-} gmx_groups_t;
+ SimulationGroups();
+
+ ~SimulationGroups();
+
+ //! Groups of particles
+ gmx::EnumerationArray<SimulationAtomGroupType, t_grps> groups;
+ //! Names of groups, stored as pointer to the entries in the symbol table.
+ std::vector<char **> groupNames;
+ //! Group numbers for the different SimulationAtomGroupType groups.
+ gmx::EnumerationArray < SimulationAtomGroupType, std::vector < unsigned char>> groupNumbers;
+
+ /*! \brief
+ * Number of group numbers for a single SimulationGroup.
+ *
+ * \param[in] group Integer value for the group type.
+ */
+ int numberOfGroupNumbers(SimulationAtomGroupType group) const { return groupNumbers[group].size(); }
+};
/*! \brief
* Returns group number of an input group for a given atom.
* \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 SimulationGroups &group, SimulationAtomGroupType 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.
* List of intermolecular interactions using system wide
* atom indices, either NULL or size F_NRE
*/
- std::unique_ptr<InteractionLists> intermolecular_ilist = nullptr;
+ std::unique_ptr<InteractionLists> intermolecular_ilist = nullptr;
//! Number of global atoms.
- int natoms = 0;
+ int natoms = 0;
//! Parameter for residue numbering.
- int maxres_renum = 0;
+ int maxres_renum = 0;
//! The maximum residue number in moltype
- int maxresnr = -1;
+ int maxresnr = -1;
//! Atomtype properties
- t_atomtypes atomtypes;
+ t_atomtypes atomtypes;
//! Groups of atoms for different purposes
- gmx_groups_t groups;
+ SimulationGroups groups;
//! The symbol table
- t_symtab symtab;
+ t_symtab symtab;
//! Tells whether we have valid molecule indices
- bool haveMoleculeIndices = false;
+ bool haveMoleculeIndices = false;
/*! \brief List of global atom indices of atoms between which
* non-bonded interactions must be excluded.
*/
std::vector<MoleculeBlockIndices> moleculeBlockIndices;
};
-/* \brief
+/*! \brief
* The fully written out topology for a domain over its lifetime
*
* Also used in some analysis code.
} t_topology;
void init_top(t_topology *top);
-void done_gmx_groups_t(gmx_groups_t *g);
void done_top(t_topology *top);
// Frees both t_topology and gmx_mtop_t when the former has been created from
// the latter.
* \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,
+void compareAtomGroups(FILE *fp, const SimulationGroups &g0, const SimulationGroups &g1,
int natoms0, int natoms1);
//! Typedef for gmx_localtop in analysis tools.
#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2010,2011,2012,2013,2014,2015,2017,2018, by the GROMACS development team, led by
+# Copyright (c) 2010,2011,2012,2013,2014,2015,2017,2018,2019, by the GROMACS development team, led by
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
# and including many others, as listed in the AUTHORS file in the
# top-level source directory and at http://www.gromacs.org.
cstringutil.h
current_function.h
datafilefinder.h
+ enumerationhelpers.h
errorcodes.h
exceptions.h
fatalerror.h
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
-/*! \libinternal
- * \file
+/*! \file
* \brief Defines helper types for class enumerations.
*
* These helper types facilitate iterating over class enums, and
//! Returns a const raw pointer to the contents of the array.
const_pointer data() const { return &m_elements[0]; }
+ //! Returns a raw pointer to the contents of the array.
+ pointer data() { return &m_elements[0]; }
};
/*! \brief Returns an object that provides iterators over the keys