real dvdl_walls = do_walls(inputrec,
*fr,
box,
- *mdatoms,
+ gmx::arrayRefFromArray(mdatoms->typeA, mdatoms->nr),
+ gmx::arrayRefFromArray(mdatoms->typeB, mdatoms->nr),
+ gmx::arrayRefFromArray(mdatoms->cENER, mdatoms->nr),
+ mdatoms->homenr,
+ mdatoms->nPerturbed,
x.unpaddedConstArrayRef(),
&forceOutMtsLevel0.forceWithVirial(),
lambda[static_cast<int>(FreeEnergyPerturbationCouplingType::Vdw)],
- enerd->grpp.energyGroupPairTerms[NonBondedEnergyTerms::LJSR].data(),
+ enerd->grpp.energyGroupPairTerms[NonBondedEnergyTerms::LJSR],
nrnb);
enerd->dvdl_lin[FreeEnergyPerturbationCouplingType::Vdw] += dvdl_walls;
}
}
}
-real do_walls(const t_inputrec& ir,
- const t_forcerec& fr,
- const matrix box,
- const t_mdatoms& md,
- gmx::ArrayRef<const gmx::RVec> x,
- gmx::ForceWithVirial* forceWithVirial,
- real lambda,
- real Vlj[],
- t_nrnb* nrnb)
+real do_walls(const t_inputrec& ir,
+ const t_forcerec& fr,
+ const matrix box,
+ gmx::ArrayRef<const int> typeA,
+ gmx::ArrayRef<const int> typeB,
+ gmx::ArrayRef<const unsigned short> cENER,
+ const int homenr,
+ const int numPerturbedAtoms,
+ gmx::ArrayRef<const gmx::RVec> x,
+ gmx::ForceWithVirial* forceWithVirial,
+ real lambda,
+ gmx::ArrayRef<real> Vlj,
+ t_nrnb* nrnb)
{
constexpr real sixth = 1.0 / 6.0;
constexpr real twelfth = 1.0 / 12.0;
- int ntw[2];
- real fac_d[2], fac_r[2];
- const unsigned short* gid = md.cENER;
+ int ntw[2];
+ real fac_d[2], fac_r[2];
const int nwall = ir.nwall;
const int ngid = ir.opts.ngener;
real dvdlambda = 0;
double sumRF = 0;
- for (int lam = 0; lam < (md.nPerturbed ? 2 : 1); lam++)
+ for (int lam = 0; lam < (numPerturbedAtoms ? 2 : 1); lam++)
{
- real lamfac;
- const int* type;
- if (md.nPerturbed)
+ real lamfac;
+ gmx::ArrayRef<const int> type;
+ if (numPerturbedAtoms != 0)
{
if (lam == 0)
{
lamfac = 1 - lambda;
- type = md.typeA;
+ type = typeA;
}
else
{
lamfac = lambda;
- type = md.typeB;
+ type = typeB;
}
}
else
{
lamfac = 1;
- type = md.typeA;
+ type = typeA;
}
real Vlambda = 0;
- for (int i = 0; i < md.homenr; i++)
+ for (int i = 0; i < homenr; i++)
{
for (int w = 0; w < std::min(nwall, 2); w++)
{
/* The wall energy groups are always at the end of the list */
- const int ggid = gid[i] * ngid + ngid - nwall + w;
+ const int ggid = cENER[i] * ngid + ngid - nwall + w;
const int at = type[i];
/* nbfp now includes the 6/12 derivative prefactors */
const real Cd = nbfp[ntw[w] + 2 * at] * sixth;
switch (ir.wall_type)
{
case WallType::Table:
- tableForce(r, *fr.wall_tab[w][gid[i]], Cd, Cr, &V, &F);
+ tableForce(r, *fr.wall_tab[w][cENER[i]], Cd, Cr, &V, &F);
F *= lamfac;
break;
case WallType::NineThree:
}
}
}
- if (md.nPerturbed)
+ if (numPerturbedAtoms != 0)
{
dvdlambda += (lam == 0 ? -1 : 1) * Vlambda;
}
- inc_nrnb(nrnb, eNR_WALLS, md.homenr);
+ inc_nrnb(nrnb, eNR_WALLS, homenr);
}
if (forceWithVirial->computeVirial_)
const SimulationGroups* groups,
t_forcerec* fr);
-real do_walls(const t_inputrec& ir,
- const t_forcerec& fr,
- const matrix box,
- const t_mdatoms& md,
- gmx::ArrayRef<const gmx::RVec> x,
- gmx::ForceWithVirial* forceWithVirial,
- real lambda,
- real Vlj[],
- t_nrnb* nrnb);
+real do_walls(const t_inputrec& ir,
+ const t_forcerec& fr,
+ const matrix box,
+ gmx::ArrayRef<const int> typeA,
+ gmx::ArrayRef<const int> typeB,
+ gmx::ArrayRef<const unsigned short> cENER,
+ int homenr,
+ int numPerturbedAtoms,
+ gmx::ArrayRef<const gmx::RVec> x,
+ gmx::ForceWithVirial* forceWithVirial,
+ real lambda,
+ gmx::ArrayRef<real> Vlj,
+ t_nrnb* nrnb);
#endif