* perturbations. The parameter vectors for LJ-PME are likewise
* undefined when LJ-PME is not active. This works because
* bHaveChargeOrTypePerturbed handles the control flow. */
-void ewald_LRcorrection(const int numAtomsLocal,
- const t_commrec* cr,
- int numThreads,
- int thread,
- const t_forcerec& fr,
- const t_inputrec& ir,
- const real* chargeA,
- const real* chargeB,
- gmx_bool bHaveChargePerturbed,
- const rvec x[],
- const matrix box,
- const rvec mu_tot[],
- rvec* f,
- real* Vcorr_q,
- real lambda_q,
- real* dvdlambda_q)
+void ewald_LRcorrection(const int numAtomsLocal,
+ const t_commrec* cr,
+ int numThreads,
+ int thread,
+ const t_forcerec& fr,
+ const t_inputrec& ir,
+ gmx::ArrayRef<const real> chargeA,
+ gmx::ArrayRef<const real> chargeB,
+ bool bHaveChargePerturbed,
+ gmx::ArrayRef<const gmx::RVec> x,
+ const matrix box,
+ gmx::ArrayRef<const gmx::RVec> mu_tot,
+ gmx::ArrayRef<gmx::RVec> f,
+ real* Vcorr_q,
+ real lambda_q,
+ real* dvdlambda_q)
{
/* We need to correct only self interactions */
const int start = (numAtomsLocal * thread) / numThreads;
* We could implement a reduction over threads,
* but this case is rarely used.
*/
- const real* qPtr = (q == 0 ? chargeA : chargeB);
- real sumQZ2 = 0;
+ gmx::ArrayRef<const real> charge = (q == 0 ? chargeA : chargeB);
+ real sumQZ2 = 0;
for (int i = 0; i < numAtomsLocal; i++)
{
- sumQZ2 += qPtr[i] * x[i][ZZ] * x[i][ZZ];
+ sumQZ2 += charge[i] * x[i][ZZ] * x[i][ZZ];
}
Vdipole[q] -= dipole_coeff * fr.qsum[q]
* (sumQZ2 + fr.qsum[q] * box[ZZ][ZZ] * box[ZZ][ZZ] / 12);
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#define GMX_EWALD_LONG_RANGE_CORRECTION_H
#include "gromacs/math/vectypes.h"
-#include "gromacs/topology/block.h"
-#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
struct t_commrec;
struct t_forcerec;
struct t_inputrec;
+namespace gmx
+{
+template<typename>
+class ArrayRef;
+}
+
/*! \brief Calculate long-range Ewald correction terms.
*
* Calculate correction for electrostatic surface dipole terms.
*/
-void ewald_LRcorrection(int numAtomsLocal,
- const t_commrec* cr,
- int numThreads,
- int thread,
- const t_forcerec& fr,
- const t_inputrec& ir,
- const real* chargeA,
- const real* chargeB,
- gmx_bool bHaveChargePerturbed,
- const rvec x[],
- const matrix box,
- const rvec mu_tot[],
- rvec* f,
- real* Vcorr_q,
- real lambda_q,
- real* dvdlambda_q);
+void ewald_LRcorrection(int numAtomsLocal,
+ const t_commrec* cr,
+ int numThreads,
+ int thread,
+ const t_forcerec& fr,
+ const t_inputrec& ir,
+ gmx::ArrayRef<const real> chargeA,
+ gmx::ArrayRef<const real> chargeB,
+ bool bHaveChargePerturbed,
+ gmx::ArrayRef<const gmx::RVec> x,
+ const matrix box,
+ gmx::ArrayRef<const gmx::RVec> mu_tot,
+ gmx::ArrayRef<gmx::RVec> f,
+ real* Vcorr_q,
+ real lambda_q,
+ real* dvdlambda_q);
#endif
}
}
-void calculateLongRangeNonbondeds(t_forcerec* fr,
- const t_inputrec& ir,
- const t_commrec* cr,
- t_nrnb* nrnb,
- gmx_wallcycle_t wcycle,
- const t_mdatoms* md,
- gmx::ArrayRef<const RVec> coordinates,
- gmx::ForceWithVirial* forceWithVirial,
- gmx_enerdata_t* enerd,
- const matrix box,
- const real* lambda,
- const rvec* mu_tot,
- const gmx::StepWorkload& stepWork,
- const DDBalanceRegionHandler& ddBalanceRegionHandler)
+void calculateLongRangeNonbondeds(t_forcerec* fr,
+ const t_inputrec& ir,
+ const t_commrec* cr,
+ t_nrnb* nrnb,
+ gmx_wallcycle_t wcycle,
+ const t_mdatoms* md,
+ gmx::ArrayRef<const RVec> coordinates,
+ gmx::ForceWithVirial* forceWithVirial,
+ gmx_enerdata_t* enerd,
+ const matrix box,
+ gmx::ArrayRef<const real> lambda,
+ gmx::ArrayRef<const gmx::RVec> mu_tot,
+ const gmx::StepWorkload& stepWork,
+ const DDBalanceRegionHandler& ddBalanceRegionHandler)
{
const bool computePmeOnCpu = (EEL_PME(fr->ic->eeltype) || EVDW_PME(fr->ic->vdwtype))
&& thisRankHasDuty(cr, DUTY_PME)
* exclusion forces) are calculated, so we can store
* the forces in the normal, single forceWithVirial->force_ array.
*/
- const rvec* x = as_rvec_array(coordinates.data());
ewald_LRcorrection(
md->homenr,
cr,
t,
*fr,
ir,
- md->chargeA,
- md->chargeB,
+ gmx::constArrayRefFromArray(md->chargeA, md->nr),
+ gmx::constArrayRefFromArray(md->chargeB, md->nr),
(md->nChargePerturbed != 0),
- x,
+ coordinates,
box,
mu_tot,
- as_rvec_array(forceWithVirial->force_.data()),
+ forceWithVirial->force_,
&ewc_t.Vcorr_q,
lambda[static_cast<int>(FreeEnergyPerturbationCouplingType::Coul)],
&ewc_t.dvdl[FreeEnergyPerturbationCouplingType::Coul]);
gmx::ForceWithVirial* forceWithVirial,
gmx_enerdata_t* enerd,
const matrix box,
- const real* lambda,
- const rvec* mu_tot,
+ gmx::ArrayRef<const real> lambda,
+ gmx::ArrayRef<const gmx::RVec> mu_tot,
const gmx::StepWorkload& stepWork,
const DDBalanceRegionHandler& ddBalanceRegionHandler);
&forceOutMtsLevel1->forceWithVirial(),
enerd,
box,
- lambda.data(),
- as_rvec_array(dipoleData.muStateAB),
+ lambda,
+ dipoleData.muStateAB,
stepWork,
ddBalanceRegionHandler);
}