*/
#include "gmxpre.h"
+#include "gromacs/utility/arrayref.h"
+#include "gromacs/utility/enumerationhelpers.h"
#include "listed_forces.h"
#include <cassert>
f_t->grpp.ener[i][j] = 0;
}
}
- for (int i = 0; i < efptNR; i++)
+ for (auto i : keysOf(f_t->dvdl))
{
f_t->dvdl[i] = 0;
}
void reduce_thread_output(gmx::ForceWithShiftForces* forceWithShiftForces,
real* ener,
gmx_grppairener_t* grpp,
- real* dvdl,
+ gmx::ArrayRef<real> dvdl,
const bonded_threading_t* bt,
const gmx::StepWorkload& stepWork)
{
}
if (stepWork.computeDhdl)
{
- for (int i = 0; i < efptNR; i++)
+ for (auto i : keysOf(f_t[1]->dvdl))
{
for (int t = 1; t < bt->nthreads; t++)
{
- dvdl[i] += f_t[t]->dvdl[i];
+ dvdl[static_cast<int>(i)] += f_t[t]->dvdl[i];
}
}
}
const t_pbc* pbc,
gmx_grppairener_t* grpp,
t_nrnb* nrnb,
- const real* lambda,
- real* dvdl,
+ gmx::ArrayRef<const real> lambda,
+ gmx::ArrayRef<real> dvdl,
const t_mdatoms* md,
t_fcdata* fcd,
const gmx::StepWorkload& stepWork,
(idef.ilsort == ilsortFE_SORTED && numNonperturbedInteractions < iatoms.ssize());
BondedKernelFlavor flavor =
selectBondedKernelFlavor(stepWork, fr->use_simd_kernels, havePerturbedInteractions);
- int efptFTYPE;
+ FreeEnergyPerturbationCouplingType efptFTYPE;
if (IS_RESTRAINT_TYPE(ftype))
{
- efptFTYPE = efptRESTRAINT;
+ efptFTYPE = FreeEnergyPerturbationCouplingType::Restraint;
}
else
{
- efptFTYPE = efptBONDED;
+ efptFTYPE = FreeEnergyPerturbationCouplingType::Bonded;
}
const int nat1 = interaction_function[ftype].nratoms + 1;
f,
fshift,
pbc,
- lambda[efptFTYPE],
- &(dvdl[efptFTYPE]),
+ lambda[static_cast<int>(efptFTYPE)],
+ &(dvdl[static_cast<int>(efptFTYPE)]),
md,
fcd,
nullptr,
f,
fshift,
pbc,
- lambda[efptFTYPE],
- &(dvdl[efptFTYPE]),
+ lambda[static_cast<int>(efptFTYPE)],
+ &(dvdl[static_cast<int>(efptFTYPE)]),
md,
fcd,
fcd->disres,
f,
fshift,
pbc,
- lambda,
- dvdl,
+ lambda.data(),
+ dvdl.data(),
md,
fr,
havePerturbedInteractions,
rvec* fshiftMasterBuffer,
gmx_enerdata_t* enerd,
t_nrnb* nrnb,
- const real* lambda,
- real* dvdl,
+ gmx::ArrayRef<const real> lambda,
+ gmx::ArrayRef<real> dvdl,
const t_mdatoms* md,
t_fcdata* fcd,
const gmx::StepWorkload& stepWork,
int ftype;
real * epot, v;
/* thread stuff */
- rvec* fshift;
- real* dvdlt;
- gmx_grppairener_t* grpp;
+ rvec* fshift;
+ gmx::ArrayRef<real> dvdlt;
+ gmx_grppairener_t* grpp;
zero_thread_output(&threadBuffers);
const t_pbc* pbc,
gmx_enerdata_t* enerd,
t_nrnb* nrnb,
- const real* lambda,
+ gmx::ArrayRef<const real> lambda,
const t_mdatoms* md,
t_fcdata* fcd,
int* global_atom_index,
wallcycle_sub_start(wcycle, ewcsLISTED);
/* The dummy array is to have a place to store the dhdl at other values
of lambda, which will be thrown away in the end */
- real dvdl[efptNR] = { 0 };
+ gmx::EnumerationArray<FreeEnergyPerturbationCouplingType, real> dvdl = { 0 };
calcBondedForces(idef,
bt,
x,
if (stepWork.computeDhdl)
{
- for (int i = 0; i < efptNR; i++)
+ for (auto i : keysOf(enerd->dvdl_lin))
{
enerd->dvdl_nonlin[i] += dvdl[i];
}
real* epot,
gmx::ArrayRef<real> dvdl,
t_nrnb* nrnb,
- const real* lambda,
+ gmx::ArrayRef<const real> lambda,
const t_mdatoms* md,
t_fcdata* fcd,
int* global_atom_index)
grpp,
nrnb,
lambda,
- dvdl.data(),
+ dvdl,
md,
fcd,
tempFlags,
const struct t_pbc* pbc,
gmx_enerdata_t* enerd,
t_nrnb* nrnb,
- const real* lambda,
+ gmx::ArrayRef<const real> lambda,
const t_mdatoms* md,
int* global_atom_index,
const gmx::StepWorkload& stepWork)
*/
if (fepvals->n_lambda > 0 && stepWork.computeDhdl)
{
- real dvdl[efptNR] = { 0 };
+ gmx::EnumerationArray<FreeEnergyPerturbationCouplingType, real> dvdl = { 0 };
if (!idef.il[F_POSRES].empty())
{
posres_wrapper_lambda(wcycle, fepvals, idef, &pbc_full, x, enerd, lambda, fr);
}
for (int i = 0; i < 1 + enerd->foreignLambdaTerms.numLambdas(); i++)
{
- real lam_i[efptNR];
+ gmx::EnumerationArray<FreeEnergyPerturbationCouplingType, real> lam_i;
reset_foreign_enerdata(enerd);
- for (int j = 0; j < efptNR; j++)
+ for (auto j : keysOf(lam_i))
{
- lam_i[j] = (i == 0 ? lambda[j] : fepvals->all_lambda[j][i - 1]);
+ lam_i[j] = (i == 0 ? lambda[static_cast<int>(j)] : fepvals->all_lambda[j][i - 1]);
}
calc_listed_lambda(idef,
threading_.get(),