* For PME-only ranks, gmx_pmeonly() has its own call to gmx_pme_reinit_atoms().
*/
const int numPmeAtoms = numHomeAtoms - fr->n_tpi;
- gmx_pme_reinit_atoms(fr->pmedata, numPmeAtoms, mdatoms->chargeA, mdatoms->chargeB);
+ gmx_pme_reinit_atoms(fr->pmedata,
+ numPmeAtoms,
+ gmx::arrayRefFromArray(mdatoms->chargeA, mdatoms->nr),
+ gmx::arrayRefFromArray(mdatoms->chargeB, mdatoms->nr));
}
if (constr)
*/
if (!pme_src->gpu && pme_src->nnodes == 1)
{
- gmx_pme_reinit_atoms(*pmedata, pme_src->atc[0].numAtoms(), nullptr, nullptr);
+ gmx_pme_reinit_atoms(*pmedata,
+ pme_src->atc[0].numAtoms(),
+ {},
+ {});
}
// TODO this is mostly passing around current values
}
/* We would like to reuse the fft grids, but that's harder */
}
-void gmx_pme_calc_energy(gmx_pme_t* pme, gmx::ArrayRef<const gmx::RVec> x, gmx::ArrayRef<const real> q, real* V)
+real gmx_pme_calc_energy(gmx_pme_t* pme, gmx::ArrayRef<const gmx::RVec> x, gmx::ArrayRef<const real> q)
{
pmegrids_t* grid;
/* Only calculate the spline coefficients, don't actually spread */
spread_on_grid(pme, atc, nullptr, TRUE, FALSE, pme->fftgrid[PME_GRID_QA], FALSE, PME_GRID_QA);
- *V = gather_energy_bsplines(pme, grid->grid.grid, atc);
+ return gather_energy_bsplines(pme, grid->grid.grid, atc);
}
/*! \brief Calculate initial Lorentz-Berthelot coefficients for LJ-PME */
delete pme;
}
-void gmx_pme_reinit_atoms(gmx_pme_t* pme, const int numAtoms, const real* chargesA, const real* chargesB)
+void gmx_pme_reinit_atoms(gmx_pme_t* pme,
+ const int numAtoms,
+ gmx::ArrayRef<const real> chargesA,
+ gmx::ArrayRef<const real> chargesB)
{
if (pme->gpu != nullptr)
{
- GMX_ASSERT(!(pme->bFEP_q && chargesB == nullptr),
+ GMX_ASSERT(!(pme->bFEP_q && !chargesB.empty()),
"B state charges must be specified if running Coulomb FEP on the GPU");
- pme_gpu_reinit_atoms(pme->gpu, numAtoms, chargesA, pme->bFEP_q ? chargesB : nullptr);
+ pme_gpu_reinit_atoms(pme->gpu, numAtoms, chargesA.data(), pme->bFEP_q ? chargesB.data() : nullptr);
}
else
{
* pme struct. Currently does not work in parallel or with free
* energy.
*/
-void gmx_pme_calc_energy(gmx_pme_t* pme, gmx::ArrayRef<const gmx::RVec> x, gmx::ArrayRef<const real> q, real* V);
+real gmx_pme_calc_energy(gmx_pme_t* pme, gmx::ArrayRef<const gmx::RVec> x, gmx::ArrayRef<const real> q);
/*! \brief
* This function updates the local atom data on GPU after DD (charges, coordinates, etc.).
* \param[in] chargesB The pointer to the array of particle charges in state B. Only used if
* charges are perturbed and can otherwise be nullptr.
*/
-void gmx_pme_reinit_atoms(gmx_pme_t* pme, int numAtoms, const real* chargesA, const real* chargesB);
+void gmx_pme_reinit_atoms(gmx_pme_t* pme,
+ int numAtoms,
+ gmx::ArrayRef<const real> chargesA,
+ gmx::ArrayRef<const real> chargesB);
/* A block of PME GPU functions */
{
if (atomSetChanged)
{
- gmx_pme_reinit_atoms(pme, nat, pme_pp->chargeA.data(), pme_pp->chargeB.data());
+ gmx_pme_reinit_atoms(pme, nat, pme_pp->chargeA, pme_pp->chargeB);
if (useGpuForPme)
{
stateGpu->reinit(nat, nat);
atc = &(pme->atc[0]);
atc->x = coordinates;
atc->coefficient = charges;
- gmx_pme_reinit_atoms(pme, atomCount, charges.data(), nullptr);
+ gmx_pme_reinit_atoms(pme, atomCount, charges, {});
/* With decomposition there would be more boilerplate atc code here, e.g. do_redist_pos_coeffs */
break;
atc = &(pme->atc[0]);
// We need to set atc->n for passing the size in the tests
atc->setNumAtoms(atomCount);
- gmx_pme_reinit_atoms(pme, atomCount, charges.data(), nullptr);
+ gmx_pme_reinit_atoms(pme, atomCount, charges, {});
stateGpu->reinit(atomCount, atomCount);
stateGpu->copyCoordinatesToGpu(arrayRefFromArray(coordinates.data(), coordinates.size()),
/* Determine the PME grid energy of the test molecule
* with the PME grid potential of the other charges.
*/
- gmx_pme_calc_energy(
+ Vlr_q = gmx_pme_calc_energy(
fr->pmedata,
coordinates.subArray(md->homenr - fr->n_tpi, fr->n_tpi),
- gmx::arrayRefFromArray(md->chargeA + md->homenr - fr->n_tpi, fr->n_tpi),
- &Vlr_q);
+ gmx::arrayRefFromArray(md->chargeA + md->homenr - fr->n_tpi, fr->n_tpi));
}
}
}
if (EEL_PME(fr->ic->eeltype))
{
- gmx_pme_reinit_atoms(fr->pmedata, a_tp0, nullptr, nullptr);
+ gmx_pme_reinit_atoms(fr->pmedata, a_tp0, {}, {});
}
/* With reacion-field we have distance dependent potentials