/* find heavy atom bound to this hydrogen */
heavy = NOTSET;
- for (int i = 0; (i < psb->nr) && (heavy == NOTSET); i++)
+ for (auto parm = psb->interactionTypes.begin(); (parm != psb->interactionTypes.end()) && (heavy == NOTSET); parm++)
{
- if (psb->param[i].ai() == atom)
+ if (parm->ai() == atom)
{
- heavy = psb->param[i].aj();
+ heavy = parm->aj();
}
- else if (psb->param[i].aj() == atom)
+ else if (parm->aj() == atom)
{
- heavy = psb->param[i].ai();
+ heavy = parm->ai();
}
}
if (heavy == NOTSET)
nrb = 0;
nrH = 0;
nrhv = 0;
- for (int i = 0; i < psb->nr; i++)
+ for (const auto &parm : psb->interactionTypes)
{
- if (psb->param[i].ai() == heavy)
+ if (parm.ai() == heavy)
{
- other = psb->param[i].aj();
+ other = parm.aj();
}
- else if (psb->param[i].aj() == heavy)
+ else if (parm.aj() == heavy)
{
- other = psb->param[i].ai();
+ other = parm.ai();
}
if (other != NOTSET)
{
{
/* find more heavy atoms */
other = moreheavy = NOTSET;
- for (int j = 0; (j < plist[F_BONDS].nr) && (moreheavy == NOTSET); j++)
+ for (auto parm = plist[F_BONDS].interactionTypes.begin();
+ (parm != plist[F_BONDS].interactionTypes.end()) && (moreheavy == NOTSET); parm++)
{
- if (plist[F_BONDS].param[j].ai() == heavies[0])
+ if (parm->ai() == heavies[0])
{
- other = plist[F_BONDS].param[j].aj();
+ other = parm->aj();
}
- else if (plist[F_BONDS].param[j].aj() == heavies[0])
+ else if (parm->aj() == heavies[0])
{
- other = plist[F_BONDS].param[j].ai();
+ other = parm->ai();
}
if ( (other != NOTSET) && (other != Heavy) )
{
char tpname[32], nexttpname[32];
int *o2n, *newvsite_type, *newcgnr, ats[MAXATOMSPERRESIDUE];
t_atom *newatom;
- InteractionTypeParameters *params;
char ***newatomname;
char *resnm = nullptr;
int cmplength;
InteractionTypeParameters *params = &(plist[ftype]);
if (debug)
{
- fprintf(debug, "Renumbering %d %s\n", params->nr,
+ fprintf(debug, "Renumbering %zu %s\n", params->size(),
interaction_function[ftype].longname);
}
- for (int i = 0; i < params->nr; i++)
+ /* Horrible hacks needed here to get this to work */
+ for (auto parm = params->interactionTypes.begin(); parm != params->interactionTypes.end(); parm++)
{
+ gmx::ArrayRef<const int> atomNumbers(parm->atoms());
+ std::vector<int> newAtomNumber;
for (int j = 0; j < NRAL(ftype); j++)
{
- if (params->param[i].a[j] >= add_shift)
+ if (atomNumbers[j] >= add_shift)
{
if (debug)
{
- fprintf(debug, " [%d -> %d]", params->param[i].a[j],
- params->param[i].a[j]-add_shift);
+ fprintf(debug, " [%d -> %d]", atomNumbers[j],
+ atomNumbers[j]-add_shift);
}
- params->param[i].a[j] = params->param[i].a[j]-add_shift;
+ newAtomNumber.emplace_back(atomNumbers[j]-add_shift);
}
else
{
if (debug)
{
- fprintf(debug, " [%d -> %d]", params->param[i].a[j],
- o2n[params->param[i].a[j]]);
+ fprintf(debug, " [%d -> %d]", atomNumbers[j],
+ o2n[atomNumbers[j]]);
}
- params->param[i].a[j] = o2n[params->param[i].a[j]];
+ newAtomNumber.emplace_back(o2n[atomNumbers[j]]);
}
}
+ *parm = InteractionType(newAtomNumber, parm->forceParam(), parm->interactionTypeName());
if (debug)
{
fprintf(debug, "\n");
}
}
}
- /* now check if atoms in the added constraints are in increasing order */
- params = &(plist[F_CONSTRNC]);
- for (int i = 0; i < params->nr; i++)
+ /* sort constraint parameters */
+ InteractionTypeParameters *params = &(plist[F_CONSTRNC]);
+ for (auto &type : params->interactionTypes)
{
- if (params->param[i].ai() > params->param[i].aj())
- {
- int j = params->param[i].aj();
- params->param[i].aj() = params->param[i].ai();
- params->param[i].ai() = j;
- }
+ type.sortAtomIds();
}
/* clean up */
/* tell the user what we did */
fprintf(stderr, "Marked %d virtual sites\n", nvsite);
fprintf(stderr, "Added %d dummy masses\n", nadd);
- fprintf(stderr, "Added %d new constraints\n", plist[F_CONSTRNC].nr);
+ fprintf(stderr, "Added %zu new constraints\n", plist[F_CONSTRNC].size());
}
void do_h_mass(InteractionTypeParameters *psb, int vsite_type[], t_atoms *at, real mHmult,
{
/* find bonded heavy atom */
int a = NOTSET;
- for (int j = 0; (j < psb->nr) && (a == NOTSET); j++)
+ for (auto parm = psb->interactionTypes.begin(); (parm != psb->interactionTypes.end()) && (a == NOTSET); parm++)
{
/* if other atom is not a virtual site, it is the one we want */
- if ( (psb->param[j].ai() == i) &&
- !is_vsite(vsite_type[psb->param[j].aj()]) )
+ if ( (parm->ai() == i) &&
+ !is_vsite(vsite_type[parm->aj()]) )
{
- a = psb->param[j].aj();
+ a = parm->aj();
}
- else if ( (psb->param[j].aj() == i) &&
- !is_vsite(vsite_type[psb->param[j].ai()]) )
+ else if ( (parm->aj() == i) &&
+ !is_vsite(vsite_type[parm->ai()]) )
{
- a = psb->param[j].ai();
+ a = parm->ai();
}
}
if (a == NOTSET)