#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/md_enums.h"
#include "gromacs/mdtypes/mdatom.h"
+#include "gromacs/mdtypes/state.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/topology/mtop_lookup.h"
#include "gromacs/topology/topology.h"
comm->bParticipate = bWillParticipate;
comm->nparticipate = count[0];
+
+ /* When we use the previous COM for PBC, we need to broadcast
+ * the previous COM to ranks that have joined the communicator.
+ */
+ for (pull_group_work_t &group : pull->group)
+ {
+ if (group.epgrppbc == epgrppbcPREVSTEPCOM)
+ {
+ GMX_ASSERT(comm->bParticipate || !MASTER(cr),
+ "The master rank has to participate, as it should pass an up to date prev. COM "
+ "to bcast here as well as to e.g. checkpointing");
+
+ gmx_bcast(sizeof(dvec), group.x_prev_step, cr);
+ }
+ }
}
}
/* Set up the global to local atom mapping for PBC atoms */
for (pull_group_work_t &group : pull->group)
{
- if (group.epgrppbc == epgrppbcREFAT)
+ if (group.epgrppbc == epgrppbcREFAT || group.epgrppbc == epgrppbcPREVSTEPCOM)
{
/* pbcAtomSet consists of a single atom */
group.pbcAtomSet = gmx::compat::make_unique<gmx::LocalAtomSet>(atomSets->add({&group.params.pbcatom, &group.params.pbcatom + 1}));
pull->bFOutAverage = pull_params->bFOutAverage;
GMX_RELEASE_ASSERT(pull->group[0].params.nat == 0, "pull group 0 is an absolute reference group and should not contain atoms");
- pull->group[0].x_prev_step[XX] = NAN;
pull->numCoordinatesWithExternalPotential = 0;
init_pull_group_index(fplog, cr, g, pgrp,
bConstraint, pulldim_con,
mtop, ir, lambda);
-
- pgrp->x_prev_step[XX] = NAN;
}
else
{
delete pull;
}
+void preparePrevStepPullCom(const t_inputrec *ir, const t_mdatoms *md, t_state *state, const t_state *state_global, const t_commrec *cr, bool startingFromCheckpoint)
+{
+ if (!ir->pull || !ir->pull->bSetPbcRefToPrevStepCOM)
+ {
+ return;
+ }
+ allocStatePrevStepPullCom(state, ir->pull_work);
+ if (startingFromCheckpoint)
+ {
+ if (MASTER(cr))
+ {
+ state->pull_com_prev_step = state_global->pull_com_prev_step;
+ }
+ if (PAR(cr))
+ {
+ /* Only the master rank has the checkpointed COM from the previous step */
+ gmx_bcast(sizeof(double) * state->pull_com_prev_step.size(), &state->pull_com_prev_step[0], cr);
+ }
+ setPrevStepPullComFromState(ir->pull_work, state);
+ }
+ else
+ {
+ t_pbc pbc;
+ set_pbc(&pbc, ir->ePBC, state->box);
+ initPullComFromPrevStep(cr, ir->pull_work, md, &pbc, state->x.rvec_array());
+ updatePrevStepPullCom(ir->pull_work, state);
+ }
+}
+
void finish_pull(struct pull_t *pull)
{
check_external_potential_registration(pull);