From d88f5b69d03da3d429465080f48e0dfd91d03258 Mon Sep 17 00:00:00 2001 From: ejjordan Date: Wed, 28 Apr 2021 14:56:28 +0200 Subject: [PATCH] Remove mdatoms from do_walls Also changed one pointer arg to ArrayRef. --- src/gromacs/mdlib/sim_util.cpp | 8 ++++-- src/gromacs/mdlib/wall.cpp | 51 ++++++++++++++++++---------------- src/gromacs/mdlib/wall.h | 22 +++++++++------ 3 files changed, 46 insertions(+), 35 deletions(-) diff --git a/src/gromacs/mdlib/sim_util.cpp b/src/gromacs/mdlib/sim_util.cpp index 232b587eb4..540bad7f00 100644 --- a/src/gromacs/mdlib/sim_util.cpp +++ b/src/gromacs/mdlib/sim_util.cpp @@ -1832,11 +1832,15 @@ void do_force(FILE* fplog, 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(FreeEnergyPerturbationCouplingType::Vdw)], - enerd->grpp.energyGroupPairTerms[NonBondedEnergyTerms::LJSR].data(), + enerd->grpp.energyGroupPairTerms[NonBondedEnergyTerms::LJSR], nrnb); enerd->dvdl_lin[FreeEnergyPerturbationCouplingType::Vdw] += dvdl_walls; } diff --git a/src/gromacs/mdlib/wall.cpp b/src/gromacs/mdlib/wall.cpp index 2b9942a1f4..89a3adb2e7 100644 --- a/src/gromacs/mdlib/wall.cpp +++ b/src/gromacs/mdlib/wall.cpp @@ -165,22 +165,25 @@ static void tableForce(real r, const t_forcetable& tab, real Cd, real Cr, real* } } -real do_walls(const t_inputrec& ir, - const t_forcerec& fr, - const matrix box, - const t_mdatoms& md, - gmx::ArrayRef 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 typeA, + gmx::ArrayRef typeB, + gmx::ArrayRef cENER, + const int homenr, + const int numPerturbedAtoms, + gmx::ArrayRef x, + gmx::ForceWithVirial* forceWithVirial, + real lambda, + gmx::ArrayRef 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; @@ -210,36 +213,36 @@ real do_walls(const t_inputrec& ir, 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 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; @@ -274,7 +277,7 @@ real do_walls(const t_inputrec& ir, 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: @@ -324,12 +327,12 @@ real do_walls(const t_inputrec& ir, } } } - 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_) diff --git a/src/gromacs/mdlib/wall.h b/src/gromacs/mdlib/wall.h index 7beff73de3..01126f6862 100644 --- a/src/gromacs/mdlib/wall.h +++ b/src/gromacs/mdlib/wall.h @@ -58,14 +58,18 @@ void make_wall_tables(FILE* fplog, 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 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 typeA, + gmx::ArrayRef typeB, + gmx::ArrayRef cENER, + int homenr, + int numPerturbedAtoms, + gmx::ArrayRef x, + gmx::ForceWithVirial* forceWithVirial, + real lambda, + gmx::ArrayRef Vlj, + t_nrnb* nrnb); #endif -- 2.22.0