#include "calc_verletbuf.h"
-#include <assert.h>
-#include <stdlib.h>
-
+#include <cassert>
#include <cmath>
+#include <cstdlib>
#include <algorithm>
#include "gromacs/topology/topology.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
+#include "gromacs/utility/strconvert.h"
/* The code in this file estimates a pairlist buffer length
* given a target energy drift per atom per picosecond.
break;
case F_VSITEN:
gmx_incons("Invalid vsite type");
- break;
default:
/* Use the mass of the lightest constructing atom.
* This is an approximation.
{
verletbuf_atomtype_t *att;
int natt;
- int mb, nmol, ft, i, a1, a2, a3, a;
- const t_atoms *atoms;
+ int ft, i, a1, a2, a3, a;
const t_ilist *il;
const t_iparams *ip;
atom_nonbonded_kinetic_prop_t *prop;
*n_nonlin_vsite = 0;
}
- for (mb = 0; mb < mtop->nmolblock; mb++)
+ for (const gmx_molblock_t &molblock : mtop->molblock)
{
- nmol = mtop->molblock[mb].nmol;
-
- atoms = &mtop->moltype[mtop->molblock[mb].type].atoms;
+ int nmol = molblock.nmol;
+ const gmx_moltype_t &moltype = mtop->moltype[molblock.type];
+ const t_atoms *atoms = &moltype.atoms;
/* Check for constraints, as they affect the kinetic energy.
* For virtual sites we need the masses and geometry of
for (ft = F_CONSTR; ft <= F_CONSTRNC; ft++)
{
- il = &mtop->moltype[mtop->molblock[mb].type].ilist[ft];
+ il = &moltype.ilist[ft];
for (i = 0; i < il->nr; i += 1+NRAL(ft))
{
}
}
- il = &mtop->moltype[mtop->molblock[mb].type].ilist[F_SETTLE];
+ il = &moltype.ilist[F_SETTLE];
for (i = 0; i < il->nr; i += 1+NRAL(F_SETTLE))
{
prop[a3].con_len = ip->settle.doh;
}
- get_vsite_masses(&mtop->moltype[mtop->molblock[mb].type],
+ get_vsite_masses(&moltype,
&mtop->ffparams,
setMassesToOne,
vsite_m,
{
for (a = 0; a < natt; a++)
{
- fprintf(debug, "type %d: m %5.2f t %d q %6.3f con %d con_m %5.3f con_l %5.3f n %d\n",
+ fprintf(debug, "type %d: m %5.2f t %d q %6.3f con %s con_m %5.3f con_l %5.3f n %d\n",
a, att[a].prop.mass, att[a].prop.type, att[a].prop.q,
- att[a].prop.bConstr, att[a].prop.con_mass, att[a].prop.con_len,
+ gmx::boolToString(att[a].prop.bConstr), att[a].prop.con_mass, att[a].prop.con_len,
att[a].n);
}
}
/* Multiply by the number of atom pairs */
if (j == i)
{
- pot *= (double)att[i].n*(att[i].n - 1)/2;
+ pot *= static_cast<double>(att[i].n)*(att[i].n - 1)/2;
}
else
{
- pot *= (double)att[i].n*att[j].n;
+ pot *= static_cast<double>(att[i].n)*att[j].n;
}
/* We need the line density to get the energy drift of the system.
* The effective average r^2 is close to (rlist+sigma)^2.
break;
default:
gmx_incons("surface_frac called with unsupported cluster_size");
- area_rel = 1.0;
}
return area_rel/cluster_size;
*/
const bool setMassesToOne = (ir->eI == eiBD && ir->bd_fric > 0);
get_verlet_buffer_atomtypes(mtop, setMassesToOne, &att, &natt, n_nonlin_vsite);
- assert(att != NULL && natt >= 0);
+ assert(att != nullptr && natt >= 0);
if (debug)
{
/* Search using bisection */
ib0 = -1;
/* The drift will be neglible at 5 times the max sigma */
- ib1 = (int)(5*maxSigma(kT_fac, natt, att)/resolution) + 1;
+ ib1 = static_cast<int>(5*maxSigma(kT_fac, natt, att)/resolution) + 1;
while (ib1 - ib0 > 1)
{
ib = (ib0 + ib1)/2;
/* Search using bisection, avoid 0 and start at 1 */
int ib0 = 0;
/* The chance will be neglible at 10 times the max sigma */
- int ib1 = (int)(10*maxSigma(kT_fac, natt, att)/resolution) + 1;
+ int ib1 = int(10*maxSigma(kT_fac, natt, att)/resolution) + 1;
real cellSize = 0;
while (ib1 - ib0 > 1)
{