}
-static void do_single_flood(FILE* edo,
- const rvec x[],
- rvec force[],
- t_edpar* edi,
- int64_t step,
- const matrix box,
- const t_commrec* cr,
- gmx_bool bNS) /* Are we in a neighbor searching step? */
+static void do_single_flood(FILE* edo,
+ gmx::ArrayRef<const gmx::RVec> coords,
+ gmx::ArrayRef<gmx::RVec> force,
+ t_edpar* edi,
+ int64_t step,
+ const matrix box,
+ const t_commrec* cr,
+ gmx_bool bNS) /* Are we in a neighbor searching step? */
{
int i;
matrix rotmat; /* rotation matrix */
buf->shifts_xcoll,
buf->extra_shifts_xcoll,
bNS,
- x,
+ as_rvec_array(coords.data()),
edi->sav.nr,
edi->sav.nr_loc,
edi->sav.anrs_loc,
buf->shifts_xc_ref,
buf->extra_shifts_xc_ref,
bNS,
- x,
+ as_rvec_array(coords.data()),
edi->sref.nr,
edi->sref.nr_loc,
edi->sref.anrs_loc,
/* Main flooding routine, called from do_force */
-void do_flood(const t_commrec* cr,
- const t_inputrec& ir,
- const rvec x[],
- rvec force[],
- gmx_edsam* ed,
- const matrix box,
- int64_t step,
- bool bNS)
+void do_flood(const t_commrec* cr,
+ const t_inputrec& ir,
+ gmx::ArrayRef<const gmx::RVec> coords,
+ gmx::ArrayRef<gmx::RVec> force,
+ gmx_edsam* ed,
+ const matrix box,
+ int64_t step,
+ bool bNS)
{
/* Write time to edo, when required. Output the time anyhow since we need
* it in the output file for ED constraints. */
/* Call flooding for one matrix */
if (edi.flood.vecs.neig)
{
- do_single_flood(ed->edo, x, force, &edi, step, box, cr, bNS);
+ do_single_flood(ed->edo, coords, force, &edi, step, box, cr, bNS);
}
}
}
}
-void do_edsam(const t_inputrec* ir, int64_t step, const t_commrec* cr, rvec xs[], rvec v[], const matrix box, gmx_edsam* ed)
+void do_edsam(const t_inputrec* ir,
+ int64_t step,
+ const t_commrec* cr,
+ gmx::ArrayRef<gmx::RVec> coords,
+ gmx::ArrayRef<gmx::RVec> velocities,
+ const matrix box,
+ gmx_edsam* ed)
{
int i, edinr, iupdate = 500;
matrix rotmat; /* rotation matrix */
buf->shifts_xcoll,
buf->extra_shifts_xcoll,
PAR(cr) ? buf->bUpdateShifts : TRUE,
- xs,
+ as_rvec_array(coords.data()),
edi.sav.nr,
edi.sav.nr_loc,
edi.sav.anrs_loc,
buf->shifts_xc_ref,
buf->extra_shifts_xc_ref,
PAR(cr) ? buf->bUpdateShifts : TRUE,
- xs,
+ as_rvec_array(coords.data()),
edi.sref.nr,
edi.sref.nr_loc,
edi.sref.anrs_loc,
box, buf->xcoll[edi.sav.c_ind[i]], buf->shifts_xcoll[edi.sav.c_ind[i]], x_unsh);
/* dx is the ED correction to the positions: */
- rvec_sub(x_unsh, xs[edi.sav.anrs_loc[i]], dx);
+ rvec_sub(x_unsh, coords[edi.sav.anrs_loc[i]], dx);
- if (v != nullptr)
+ if (!velocities.empty())
{
/* dv is the ED correction to the velocity: */
svmul(dt_1, dx, dv);
/* apply the velocity correction: */
- rvec_inc(v[edi.sav.anrs_loc[i]], dv);
+ rvec_inc(velocities[edi.sav.anrs_loc[i]], dv);
}
/* Finally apply the position correction due to ED: */
- copy_rvec(x_unsh, xs[edi.sav.anrs_loc[i]]);
+ copy_rvec(x_unsh, coords[edi.sav.anrs_loc[i]]);
}
}
} /* END of if ( bNeedDoEdsam(edi) ) */
#include <memory>
#include "gromacs/math/vectypes.h"
-#include "gromacs/utility/basedefinitions.h"
/*! \brief Abstract type for essential dynamics
*
{
enum class StartingBehavior;
class Constraints;
+template<typename>
+class ArrayRef;
+
class EssentialDynamics
{
public:
* \param ir MD input parameter record.
* \param step Number of the time step.
* \param cr Data needed for MPI communication.
- * \param xs The local positions on this processor.
- * \param v The local velocities.
+ * \param coords The local positions on this processor.
+ * \param velocities The local velocities.
* \param box The simulation box.
* \param ed The essential dynamics data.
*/
-void do_edsam(const t_inputrec* ir,
- int64_t step,
- const t_commrec* cr,
- rvec xs[],
- rvec v[],
- const matrix box,
- gmx_edsam* ed);
+void do_edsam(const t_inputrec* ir,
+ int64_t step,
+ const t_commrec* cr,
+ gmx::ArrayRef<gmx::RVec> coords,
+ gmx::ArrayRef<gmx::RVec> velocities,
+ const matrix box,
+ gmx_edsam* ed);
/*! \brief Initializes the essential dynamics and flooding module.
*
* \param cr Data needed for MPI communication.
* \param ir MD input parameter record.
- * \param x Positions on the local processor.
+ * \param coords Positions on the local processor.
* \param force Forcefield forces to which the flooding forces are added.
* \param ed The essential dynamics data.
* \param box The simulation box.
* \param step Number of the time step.
* \param bNS Are we in a neighbor searching step?
*/
-void do_flood(const t_commrec* cr,
- const t_inputrec& ir,
- const rvec x[],
- rvec force[],
- gmx_edsam* ed,
- const matrix box,
- int64_t step,
- bool bNS);
+void do_flood(const t_commrec* cr,
+ const t_inputrec& ir,
+ gmx::ArrayRef<const gmx::RVec> coords,
+ gmx::ArrayRef<gmx::RVec> force,
+ gmx_edsam* ed,
+ const matrix box,
+ int64_t step,
+ bool bNS);
#endif
/*! \brief Removes shifts of molecules diffused outside of the box. */
void removeMolecularShifts(const matrix box);
/*! \brief Initialize arrays used to assemble the positions from the other nodes. */
- void prepareForPositionAssembly(const t_commrec* cr, const rvec x[]);
+ void prepareForPositionAssembly(const t_commrec* cr, gmx::ArrayRef<const gmx::RVec> coords);
/*! \brief Interact with any connected VMD session */
- bool run(int64_t step, bool bNS, const matrix box, const rvec x[], double t);
+ bool run(int64_t step, bool bNS, const matrix box, gmx::ArrayRef<const gmx::RVec> coords, double t);
// TODO rename all the data members to have underscore suffixes
}
-void ImdSession::Impl::prepareForPositionAssembly(const t_commrec* cr, const rvec x[])
+void ImdSession::Impl::prepareForPositionAssembly(const t_commrec* cr, gmx::ArrayRef<const gmx::RVec> coords)
{
snew(xa, nat);
snew(xa_ind, nat);
for (int i = 0; i < nat; i++)
{
int ii = ind[i];
- copy_rvec(x[ii], xa_old[i]);
+ copy_rvec(coords[ii], xa_old[i]);
}
}
}
}
-std::unique_ptr<ImdSession> makeImdSession(const t_inputrec* ir,
- const t_commrec* cr,
- gmx_wallcycle* wcycle,
- gmx_enerdata_t* enerd,
- const gmx_multisim_t* ms,
- const gmx_mtop_t& top_global,
- const MDLogger& mdlog,
- const rvec x[],
- int nfile,
- const t_filenm fnm[],
- const gmx_output_env_t* oenv,
- const ImdOptions& options,
- const gmx::StartingBehavior startingBehavior)
+std::unique_ptr<ImdSession> makeImdSession(const t_inputrec* ir,
+ const t_commrec* cr,
+ gmx_wallcycle* wcycle,
+ gmx_enerdata_t* enerd,
+ const gmx_multisim_t* ms,
+ const gmx_mtop_t& top_global,
+ const MDLogger& mdlog,
+ gmx::ArrayRef<const gmx::RVec> coords,
+ int nfile,
+ const t_filenm fnm[],
+ const gmx_output_env_t* oenv,
+ const ImdOptions& options,
+ const gmx::StartingBehavior startingBehavior)
{
std::unique_ptr<ImdSession> session(new ImdSession(mdlog));
auto impl = session->impl_.get();
impl->syncNodes(cr, 0);
/* Initialize arrays used to assemble the positions from the other nodes */
- impl->prepareForPositionAssembly(cr, x);
+ impl->prepareForPositionAssembly(cr, coords);
/* Initialize molecule blocks to make them whole later...*/
if (MASTER(cr))
}
-bool ImdSession::Impl::run(int64_t step, bool bNS, const matrix box, const rvec x[], double t)
+bool ImdSession::Impl::run(int64_t step, bool bNS, const matrix box, gmx::ArrayRef<const gmx::RVec> coords, double t)
{
/* IMD at all? */
if (!sessionPossible)
/* Transfer the IMD positions to the master node. Every node contributes
* its local positions x and stores them in the assembled xa array. */
communicate_group_positions(
- cr, xa, xa_shifts, xa_eshifts, true, x, nat, nat_loc, ind_loc, xa_ind, xa_old, box);
+ cr, xa, xa_shifts, xa_eshifts, true, as_rvec_array(coords.data()), nat, nat_loc, ind_loc, xa_ind, xa_old, box);
/* If connected and master -> remove shifts */
if ((imdstep && bConnected) && MASTER(cr))
return imdstep;
}
-bool ImdSession::run(int64_t step, bool bNS, const matrix box, const rvec x[], double t)
+bool ImdSession::run(int64_t step, bool bNS, const matrix box, gmx::ArrayRef<const gmx::RVec> coords, double t)
{
- return impl_->run(step, bNS, box, x, t);
+ return impl_->run(step, bNS, box, coords, t);
}
void ImdSession::fillEnergyRecord(int64_t step, bool bHaveNewEnergies)
wallcycle_stop(impl_->wcycle, ewcIMD);
}
-void ImdSession::applyForces(rvec* f)
+void ImdSession::applyForces(gmx::ArrayRef<gmx::RVec> force)
{
if (!impl_->sessionPossible || !impl_->bForceActivated)
{
j = *locndx;
}
- rvec_inc(f[j], impl_->f[i]);
+ rvec_inc(force[j], impl_->f[i]);
}
wallcycle_stop(impl_->wcycle, ewcIMD);
#include <memory>
#include "gromacs/math/vectypes.h"
-#include "gromacs/utility/basedefinitions.h"
struct gmx_domdec_t;
struct gmx_enerdata_t;
class MDLogger;
struct ImdOptions;
struct MdrunOptions;
+template<typename>
+class ArrayRef;
/*! \brief
* Creates a module for interactive molecular dynamics.
* \param ms Handler for multi-simulations.
* \param top_global The topology of the whole system.
* \param mdlog Logger
- * \param x The starting positions of the atoms.
+ * \param coords The starting positions of the atoms.
* \param nfile Number of files.
* \param fnm Struct containing file names etc.
* \param oenv Output options.
* \param options Options for interactive MD.
* \param startingBehavior Describes whether this is a restart appending to output files
*/
-std::unique_ptr<ImdSession> makeImdSession(const t_inputrec* ir,
- const t_commrec* cr,
- gmx_wallcycle* wcycle,
- gmx_enerdata_t* enerd,
- const gmx_multisim_t* ms,
- const gmx_mtop_t& top_global,
- const MDLogger& mdlog,
- const rvec x[],
- int nfile,
- const t_filenm fnm[],
- const gmx_output_env_t* oenv,
- const ImdOptions& options,
- StartingBehavior startingBehavior);
+std::unique_ptr<ImdSession> makeImdSession(const t_inputrec* ir,
+ const t_commrec* cr,
+ gmx_wallcycle* wcycle,
+ gmx_enerdata_t* enerd,
+ const gmx_multisim_t* ms,
+ const gmx_mtop_t& top_global,
+ const MDLogger& mdlog,
+ gmx::ArrayRef<const gmx::RVec> coords,
+ int nfile,
+ const t_filenm fnm[],
+ const gmx_output_env_t* oenv,
+ const ImdOptions& options,
+ StartingBehavior startingBehavior);
class ImdSession
{
* \param step The time step.
* \param bNS Is this a neighbor searching step?
* \param box The simulation box.
- * \param x The local atomic positions on this node.
+ * \param coords The local atomic positions on this node.
* \param t The time.
*
* \returns Whether or not we have to do IMD communication at this step.
*/
- bool run(int64_t step, bool bNS, const matrix box, const rvec x[], double t);
+ bool run(int64_t step, bool bNS, const matrix box, gmx::ArrayRef<const gmx::RVec> coords, double t);
/*! \brief Add external forces from a running interactive molecular dynamics session.
*
- * \param f The forces.
+ * \param force The forces.
*/
- void applyForces(rvec* f);
+ void applyForces(gmx::ArrayRef<gmx::RVec> force);
/*! \brief Copy energies and convert to float from enerdata to the IMD energy record.
*
public:
// Befriend the factory function.
- friend std::unique_ptr<ImdSession> makeImdSession(const t_inputrec* ir,
- const t_commrec* cr,
- gmx_wallcycle* wcycle,
- gmx_enerdata_t* enerd,
- const gmx_multisim_t* ms,
- const gmx_mtop_t& top_global,
- const MDLogger& mdlog,
- const rvec x[],
- int nfile,
- const t_filenm fnm[],
- const gmx_output_env_t* oenv,
- const ImdOptions& options,
- StartingBehavior startingBehavior);
+ friend std::unique_ptr<ImdSession> makeImdSession(const t_inputrec* ir,
+ const t_commrec* cr,
+ gmx_wallcycle* wcycle,
+ gmx_enerdata_t* enerd,
+ const gmx_multisim_t* ms,
+ const gmx_mtop_t& top_global,
+ const MDLogger& mdlog,
+ gmx::ArrayRef<const gmx::RVec> coords,
+ int nfile,
+ const t_filenm fnm[],
+ const gmx_output_env_t* oenv,
+ const ImdOptions& options,
+ StartingBehavior startingBehavior);
};
} // namespace gmx
if (ed && delta_step > 0)
{
/* apply the essential dynamics constraints here */
- do_edsam(&ir,
- step,
- cr,
- as_rvec_array(xprime.unpaddedArrayRef().data()),
- as_rvec_array(v.unpaddedArrayRef().data()),
- box,
- ed);
+ do_edsam(&ir, step, cr, xprime.unpaddedArrayRef(), v.unpaddedArrayRef(), box, ed);
}
}
wallcycle_stop(wcycle, ewcCONSTR);
fplog);
}
}
-
- rvec* f = as_rvec_array(forceWithVirialMtsLevel0->force_.data());
-
/* Add the forces from enforced rotation potentials (if any) */
if (inputrec.bRot)
{
wallcycle_start(wcycle, ewcROTadd);
- enerd->term[F_COM_PULL] += add_rot_forces(enforcedRotation, f, cr, step, t);
+ enerd->term[F_COM_PULL] +=
+ add_rot_forces(enforcedRotation, forceWithVirialMtsLevel0->force_, cr, step, t);
wallcycle_stop(wcycle, ewcROTadd);
}
* Thus if no other algorithm (e.g. PME) requires it, the forces
* here will contribute to the virial.
*/
- do_flood(cr, inputrec, as_rvec_array(x.data()), f, ed, box, step, didNeighborSearch);
+ do_flood(cr, inputrec, x, forceWithVirialMtsLevel0->force_, ed, box, step, didNeighborSearch);
}
/* Add forces from interactive molecular dynamics (IMD), if any */
if (inputrec.bIMD && stepWork.computeForces)
{
- imdSession->applyForces(f);
+ imdSession->applyForces(forceWithVirialMtsLevel0->force_);
}
}
if (inputrec.bRot)
{
wallcycle_start(wcycle, ewcROT);
- do_rotation(cr, enforcedRotation, box, as_rvec_array(x.unpaddedArrayRef().data()), t, step, stepWork.doNeighborSearch);
+ do_rotation(cr, enforcedRotation, box, x.unpaddedConstArrayRef(), t, step, stepWork.doNeighborSearch);
wallcycle_stop(wcycle, ewcROT);
}
mdrunOptions.writeConfout,
bSumEkinhOld);
/* Check if IMD step and do IMD communication, if bIMD is TRUE. */
- bInteractiveMDstep = imdSession->run(step, bNS, state->box, state->x.rvec_array(), t);
+ bInteractiveMDstep = imdSession->run(step, bNS, state->box, state->x, t);
/* kludge -- virial is lost with restart for MTTK NPT control. Must reload (saved earlier). */
if (startingBehavior != StartingBehavior::NewSimulation && bFirstStep
}
/* Send energies and positions to the IMD client if bIMD is TRUE. */
- if (MASTER(cr) && imdSession->run(step, TRUE, state_global->box, state_global->x.rvec_array(), 0))
+ if (MASTER(cr) && imdSession->run(step, TRUE, state_global->box, state_global->x, 0))
{
imdSession->sendPositionsAndEnergies();
}
}
/* Send x and E to IMD client, if bIMD is TRUE. */
- if (imdSession->run(step, TRUE, state_global->box, state_global->x.rvec_array(), 0) && MASTER(cr))
+ if (imdSession->run(step, TRUE, state_global->box, state_global->x, 0) && MASTER(cr))
{
imdSession->sendPositionsAndEnergies();
}
if (imdSession->run(count,
TRUE,
MASTER(cr) ? state_global->box : nullptr,
- MASTER(cr) ? state_global->x.rvec_array() : nullptr,
+ MASTER(cr) ? state_global->x : gmx::ArrayRef<gmx::RVec>(),
0)
&& MASTER(cr))
{
ms,
mtop,
mdlog,
- MASTER(cr) ? globalState->x.rvec_array() : nullptr,
+ MASTER(cr) ? globalState->x : gmx::ArrayRef<gmx::RVec>(),
filenames.size(),
filenames.data(),
oenv,
/* Add the forces from enforced rotation potential to the local forces.
* Should be called after the SR forces have been evaluated */
-real add_rot_forces(gmx_enfrot* er, rvec f[], const t_commrec* cr, int64_t step, real t)
+real add_rot_forces(gmx_enfrot* er, gmx::ArrayRef<gmx::RVec> force, const t_commrec* cr, int64_t step, real t)
{
real Vrot = 0.0; /* If more than one rotation group is present, Vrot
assembles the local parts from all groups */
/* Get the right index of the local force */
int ii = localRotationGroupIndex[l];
/* Add */
- rvec_inc(f[ii], erg->f_rot_loc[l]);
+ rvec_inc(force[ii], erg->f_rot_loc[l]);
}
}
}
-static real do_flex2_lowlevel(gmx_enfrotgrp* erg,
- real sigma, /* The Gaussian width sigma */
- rvec x[],
- gmx_bool bOutstepRot,
- gmx_bool bOutstepSlab,
- const matrix box)
+static real do_flex2_lowlevel(gmx_enfrotgrp* erg,
+ real sigma, /* The Gaussian width sigma */
+ gmx::ArrayRef<const gmx::RVec> coords,
+ gmx_bool bOutstepRot,
+ gmx_bool bOutstepSlab,
+ const matrix box)
{
int count, ii, iigrp;
rvec xj; /* position in the i-sum */
* Note that erg->xc_center contains the center of mass in case the flex2-t
* potential was chosen. For the flex2 potential erg->xc_center must be
* zero. */
- rvec_sub(x[ii], erg->xc_center, xj);
+ rvec_sub(coords[ii], erg->xc_center, xj);
/* Shift this atom such that it is near its reference */
shift_single_coord(box, xj, erg->xc_shifts[iigrp]);
static real do_flex_lowlevel(gmx_enfrotgrp* erg,
- real sigma, /* The Gaussian width sigma */
- rvec x[],
- gmx_bool bOutstepRot,
- gmx_bool bOutstepSlab,
- const matrix box)
+ real sigma, /* The Gaussian width sigma */
+ gmx::ArrayRef<const gmx::RVec> coords,
+ gmx_bool bOutstepRot,
+ gmx_bool bOutstepSlab,
+ const matrix box)
{
int count, iigrp;
rvec xj, yj0; /* current and reference position */
* Note that erg->xc_center contains the center of mass in case the flex-t
* potential was chosen. For the flex potential erg->xc_center must be
* zero. */
- rvec_sub(x[ii], erg->xc_center, xj);
+ rvec_sub(coords[ii], erg->xc_center, xj);
/* Shift this atom such that it is near its reference */
shift_single_coord(box, xj, erg->xc_shifts[iigrp]);
static void do_flexible(gmx_bool bMaster,
gmx_enfrot* enfrot, /* Other rotation data */
gmx_enfrotgrp* erg,
- rvec x[], /* The local positions */
- const matrix box,
- double t, /* Time in picoseconds */
- gmx_bool bOutstepRot, /* Output to main rotation output file */
- gmx_bool bOutstepSlab) /* Output per-slab data */
+ gmx::ArrayRef<const gmx::RVec> coords, /* The local positions */
+ const matrix box,
+ double t, /* Time in picoseconds */
+ gmx_bool bOutstepRot, /* Output to main rotation output file */
+ gmx_bool bOutstepSlab) /* Output per-slab data */
{
int nslabs;
real sigma; /* The Gaussian width sigma */
if (erg->rotg->eType == EnforcedRotationGroupType::Flex
|| erg->rotg->eType == EnforcedRotationGroupType::Flext)
{
- erg->V = do_flex_lowlevel(erg, sigma, x, bOutstepRot, bOutstepSlab, box);
+ erg->V = do_flex_lowlevel(erg, sigma, coords, bOutstepRot, bOutstepSlab, box);
}
else if (erg->rotg->eType == EnforcedRotationGroupType::Flex2
|| erg->rotg->eType == EnforcedRotationGroupType::Flex2t)
{
- erg->V = do_flex2_lowlevel(erg, sigma, x, bOutstepRot, bOutstepSlab, box);
+ erg->V = do_flex2_lowlevel(erg, sigma, coords, bOutstepRot, bOutstepSlab, box);
}
else
{
/* Calculate the radial motion pivot-free potential and forces */
-static void do_radial_motion_pf(gmx_enfrotgrp* erg,
- rvec x[], /* The positions */
- const matrix box, /* The simulation box */
- gmx_bool bOutstepRot, /* Output to main rotation output file */
- gmx_bool bOutstepSlab) /* Output per-slab data */
+static void do_radial_motion_pf(gmx_enfrotgrp* erg,
+ gmx::ArrayRef<const gmx::RVec> coords, /* The positions */
+ const matrix box, /* The simulation box */
+ gmx_bool bOutstepRot, /* Output to main rotation output file */
+ gmx_bool bOutstepSlab) /* Output per-slab data */
{
rvec xj; /* Current position */
rvec xj_xc; /* xj - xc */
wj = N_M * mj;
/* Current position of this atom: x[ii][XX/YY/ZZ] */
- copy_rvec(x[ii], xj);
+ copy_rvec(coords[ii], xj);
/* Shift this atom such that it is near its reference */
shift_single_coord(box, xj, erg->xc_shifts[iigrp]);
/* Calculate the radial motion 2 potential and forces */
-static void do_radial_motion2(gmx_enfrotgrp* erg,
- rvec x[], /* The positions */
- const matrix box, /* The simulation box */
+static void do_radial_motion2(gmx_enfrotgrp* erg,
+ gmx::ArrayRef<const gmx::RVec> coords, /* The positions */
+ const matrix box, /* The simulation box */
gmx_bool bOutstepRot, /* Output to main rotation output file */
gmx_bool bOutstepSlab) /* Output per-slab data */
{
mj = erg->mc[iigrp];
/* Current position of this atom: x[ii] */
- copy_rvec(x[ii], xj);
+ copy_rvec(coords[ii], xj);
/* Shift this atom such that it is near its reference */
shift_single_coord(box, xj, erg->xc_shifts[iigrp]);
/* Select the PBC representation for each local x position and store that
* for later usage. We assume the right PBC image of an x is the one nearest to
* its rotated reference */
-static void choose_pbc_image(rvec x[], gmx_enfrotgrp* erg, const matrix box, int npbcdim)
+static void choose_pbc_image(gmx::ArrayRef<const gmx::RVec> coords, gmx_enfrotgrp* erg, const matrix box, int npbcdim)
{
const auto& localRotationGroupIndex = erg->atomSet->localIndex();
for (gmx::index i = 0; i < localRotationGroupIndex.ssize(); i++)
copy_rvec(erg->xr_loc[i], xref);
rvec_inc(xref, erg->xc_ref_center);
- copy_correct_pbc_image(x[ii], erg->x_loc_pbc[i], xref, box, npbcdim);
+ copy_correct_pbc_image(coords[ii], erg->x_loc_pbc[i], xref, box, npbcdim);
}
}
-void do_rotation(const t_commrec* cr, gmx_enfrot* er, const matrix box, rvec x[], real t, int64_t step, gmx_bool bNS)
+void do_rotation(const t_commrec* cr,
+ gmx_enfrot* er,
+ const matrix box,
+ gmx::ArrayRef<const gmx::RVec> coords,
+ real t,
+ int64_t step,
+ gmx_bool bNS)
{
gmx_bool outstep_slab, outstep_rot;
gmx_bool bColl;
erg->xc_shifts,
erg->xc_eshifts,
bNS,
- x,
+ as_rvec_array(coords.data()),
rotg->nat,
erg->atomSet->numAtomsLocal(),
erg->atomSet->localIndex().data(),
/* Choose the nearest PBC images of the group atoms with respect
* to the rotated reference positions */
- choose_pbc_image(x, erg, box, 3);
+ choose_pbc_image(coords, erg, box, 3);
/* Get the center of the rotation group */
if ((rotg->eType == EnforcedRotationGroupType::Isopf)
do_radial_motion(erg, outstep_rot, outstep_slab);
break;
case EnforcedRotationGroupType::Rmpf:
- do_radial_motion_pf(erg, x, box, outstep_rot, outstep_slab);
+ do_radial_motion_pf(erg, coords, box, outstep_rot, outstep_slab);
break;
case EnforcedRotationGroupType::Rm2:
case EnforcedRotationGroupType::Rm2pf:
- do_radial_motion2(erg, x, box, outstep_rot, outstep_slab);
+ do_radial_motion2(erg, coords, box, outstep_rot, outstep_slab);
break;
case EnforcedRotationGroupType::Flext:
case EnforcedRotationGroupType::Flex2t:
get_center(erg->xc, erg->mc, rotg->nat, erg->xc_center);
svmul(-1.0, erg->xc_center, transvec);
translate_x(erg->xc, rotg->nat, transvec);
- do_flexible(MASTER(cr), er, erg, x, box, t, outstep_rot, outstep_slab);
+ do_flexible(MASTER(cr), er, erg, coords, box, t, outstep_rot, outstep_slab);
break;
case EnforcedRotationGroupType::Flex:
case EnforcedRotationGroupType::Flex2:
/* Do NOT subtract the center of mass in the low level routines! */
clear_rvec(erg->xc_center);
- do_flexible(MASTER(cr), er, erg, x, box, t, outstep_rot, outstep_slab);
+ do_flexible(MASTER(cr), er, erg, coords, box, t, outstep_rot, outstep_slab);
break;
default: gmx_fatal(FARGS, "No such rotation potential.");
}
#include <memory>
#include "gromacs/math/vectypes.h"
-#include "gromacs/utility/basedefinitions.h"
struct gmx_domdec_t;
struct gmx_enfrot;
enum class StartingBehavior;
class LocalAtomSetManager;
struct MdrunOptions;
+template<typename>
+class ArrayRef;
class EnforcedRotation
{
* \param cr Pointer to MPI communication data.
* \param er Pointer to the enforced rotation working data.
* \param box Simulation box, needed to make group whole.
- * \param x The positions of all the local particles.
+ * \param coords The positions of all the local particles.
* \param t Time.
* \param step The time step.
* \param bNS After domain decomposition / neighbor searching several
* local arrays have to be updated (masses, shifts)
*/
-void do_rotation(const t_commrec* cr, gmx_enfrot* er, const matrix box, rvec x[], real t, int64_t step, gmx_bool bNS);
+void do_rotation(const t_commrec* cr,
+ gmx_enfrot* er,
+ const matrix box,
+ gmx::ArrayRef<const gmx::RVec> coords,
+ real t,
+ int64_t step,
+ bool bNS);
/*! \brief Add the enforced rotation forces to the official force array.
* the potential, the angle of the group(s), and torques).
*
* \param er Pointer to the enforced rotation working data.
- * \param f The local forces to which the rotational forces have
+ * \param force The local forces to which the rotational forces have
* to be added.
* \param cr Pointer to MPI communication data.
* \param step The time step, used for output.
* \param t Time, used for output.
* \returns The potential energy of the rotation potentials.
*/
-real add_rot_forces(gmx_enfrot* er, rvec f[], const t_commrec* cr, int64_t step, real t);
+real add_rot_forces(gmx_enfrot* er, gmx::ArrayRef<gmx::RVec> force, const t_commrec* cr, int64_t step, real t);
#endif