Separate Element from FreeEnergyPerturbationData
authorPascal Merz <pascal.merz@me.com>
Thu, 11 Jun 2020 06:48:11 +0000 (00:48 -0600)
committerPascal Merz <pascal.merz@me.com>
Wed, 15 Jul 2020 17:33:47 +0000 (17:33 +0000)
Mirroring the StatePropagatorData and EnergyData, the free energy
element is split up into a data part that is accessed by other
elements, and a member class which implements the ISimulatorElement
to allow for updating and checkpointing of lambda values.

Refs #3437

16 files changed:
docs/doxygen/lib/modularsimulator.md
src/gromacs/modularsimulator/computeglobalselement.cpp
src/gromacs/modularsimulator/computeglobalselement.h
src/gromacs/modularsimulator/constraintelement.cpp
src/gromacs/modularsimulator/constraintelement.h
src/gromacs/modularsimulator/energydata.cpp
src/gromacs/modularsimulator/energydata.h
src/gromacs/modularsimulator/forceelement.cpp
src/gromacs/modularsimulator/forceelement.h
src/gromacs/modularsimulator/freeenergyperturbationdata.cpp [moved from src/gromacs/modularsimulator/freeenergyperturbationelement.cpp with 64% similarity]
src/gromacs/modularsimulator/freeenergyperturbationdata.h [moved from src/gromacs/modularsimulator/freeenergyperturbationelement.h with 77% similarity]
src/gromacs/modularsimulator/modularsimulator.cpp
src/gromacs/modularsimulator/simulatoralgorithm.cpp
src/gromacs/modularsimulator/simulatoralgorithm.h
src/gromacs/modularsimulator/statepropagatordata.cpp
src/gromacs/modularsimulator/statepropagatordata.h

index a1431bf4d07259a63e37f710bfffc0c467843670..cab2e2731e61528d8805b81650de08fbf7130566 100644 (file)
@@ -459,13 +459,12 @@ It integrates the Parrinello-Rahman box velocity equations, takes a
 callback to the propagator to update the velocity scaling factor, and
 scales the box and the positions of the system.
 
-#### `FreeEnergyPerturbationElement`
-The `FreeEnergyPerturbationElement` holds the lambda vector and the
-current FEP state, offering access to its values via getter
-functions. The FreeEnergyPerturbationElement does update the lambda
+#### `FreeEnergyPerturbationData::Element`
+The `FreeEnergyPerturbationData::Element` is a member class of
+`FreeEnergyPerturbationData` that updates the lambda
 values during the simulation run if lambda is non-static. It
-implements the checkpointing client interface to save its current
-state for restart.
+implements the checkpointing client interface to save the current
+state of `FreeEnergyPerturbationData` for restart.
 
 ## Data structures
 
@@ -507,6 +506,11 @@ The EnergyData offers an interface to add virial contributions,
 but also allows access to the raw pointers to tensor data, the
 dipole vector, and the legacy energy data structures.
 
+### `FreeEnergyPerturbationData`
+The `FreeEnergyPerturbationData` holds the lambda vector and the
+current FEP state, offering access to its values via getter
+functions.
+
 ### `TopologyHolder`
 The topology object owns the local topology and holds a constant reference
 to the global topology owned by the ISimulator.
index 76709232dc986b10e0432b28bf3d784edcc09f72..5759fe1aef395842017efea5161544776ca10d67 100644 (file)
 #include "gromacs/mdtypes/mdatom.h"
 #include "gromacs/topology/topology.h"
 
-#include "freeenergyperturbationelement.h"
+#include "freeenergyperturbationdata.h"
 
 namespace gmx
 {
 template<ComputeGlobalsAlgorithm algorithm>
 ComputeGlobalsElement<algorithm>::ComputeGlobalsElement(StatePropagatorData* statePropagatorData,
                                                         EnergyData*          energyData,
-                                                        FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
+                                                        FreeEnergyPerturbationData* freeEnergyPerturbationData,
                                                         SimulationSignals* signals,
                                                         int                nstglobalcomm,
                                                         FILE*              fplog,
@@ -91,7 +91,7 @@ ComputeGlobalsElement<algorithm>::ComputeGlobalsElement(StatePropagatorData* sta
     statePropagatorData_(statePropagatorData),
     energyData_(energyData),
     localTopology_(nullptr),
-    freeEnergyPerturbationElement_(freeEnergyPerturbationElement),
+    freeEnergyPerturbationData_(freeEnergyPerturbationData),
     vcm_(global_top->groups, *inputrec),
     signals_(signals),
     fplog_(fplog),
index 02f4e1ab7a31575bc32b469924d070ab34168d7e..d8800bc09729615754fbad1ce1bc9c69550c79e9 100644 (file)
@@ -58,7 +58,7 @@ struct t_nrnb;
 
 namespace gmx
 {
-class FreeEnergyPerturbationElement;
+class FreeEnergyPerturbationData;
 class MDAtoms;
 class MDLogger;
 
@@ -106,22 +106,22 @@ class ComputeGlobalsElement final :
 {
 public:
     //! Constructor
-    ComputeGlobalsElement(StatePropagatorData*           statePropagatorData,
-                          EnergyData*                    energyData,
-                          FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
-                          SimulationSignals*             signals,
-                          int                            nstglobalcomm,
-                          FILE*                          fplog,
-                          const MDLogger&                mdlog,
-                          t_commrec*                     cr,
-                          const t_inputrec*              inputrec,
-                          const MDAtoms*                 mdAtoms,
-                          t_nrnb*                        nrnb,
-                          gmx_wallcycle*                 wcycle,
-                          t_forcerec*                    fr,
-                          const gmx_mtop_t*              global_top,
-                          Constraints*                   constr,
-                          bool                           hasReadEkinState);
+    ComputeGlobalsElement(StatePropagatorData*        statePropagatorData,
+                          EnergyData*                 energyData,
+                          FreeEnergyPerturbationData* freeEnergyPerturbationData,
+                          SimulationSignals*          signals,
+                          int                         nstglobalcomm,
+                          FILE*                       fplog,
+                          const MDLogger&             mdlog,
+                          t_commrec*                  cr,
+                          const t_inputrec*           inputrec,
+                          const MDAtoms*              mdAtoms,
+                          t_nrnb*                     nrnb,
+                          gmx_wallcycle*              wcycle,
+                          t_forcerec*                 fr,
+                          const gmx_mtop_t*           global_top,
+                          Constraints*                constr,
+                          bool                        hasReadEkinState);
 
     //! Destructor
     ~ComputeGlobalsElement() override;
@@ -217,8 +217,8 @@ private:
     EnergyData* energyData_;
     //! Pointer to the local topology (only needed for checkNumberOfBondedInteractions)
     const gmx_localtop_t* localTopology_;
-    //! Pointer to the free energy perturbation element
-    FreeEnergyPerturbationElement* freeEnergyPerturbationElement_;
+    //! Pointer to the free energy perturbation data
+    FreeEnergyPerturbationData* freeEnergyPerturbationData_;
 
     //! Center of mass motion removal
     t_vcm vcm_;
index 9e7c7c8f43a22b5e2b210eeb82003d7b58dd4962..6625bf58e7dc3a84b85be179b820c05157faee42 100644 (file)
 #include "gromacs/utility/fatalerror.h"
 
 #include "energydata.h"
-#include "freeenergyperturbationelement.h"
+#include "freeenergyperturbationdata.h"
 #include "statepropagatordata.h"
 
 namespace gmx
 {
 template<ConstraintVariable variable>
-ConstraintsElement<variable>::ConstraintsElement(Constraints*                   constr,
-                                                 StatePropagatorData*           statePropagatorData,
-                                                 EnergyData*                    energyData,
-                                                 FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
-                                                 bool                           isMaster,
-                                                 FILE*                          fplog,
-                                                 const t_inputrec*              inputrec,
-                                                 const t_mdatoms*               mdAtoms) :
+ConstraintsElement<variable>::ConstraintsElement(Constraints*                constr,
+                                                 StatePropagatorData*        statePropagatorData,
+                                                 EnergyData*                 energyData,
+                                                 FreeEnergyPerturbationData* freeEnergyPerturbationData,
+                                                 bool                        isMaster,
+                                                 FILE*                       fplog,
+                                                 const t_inputrec*           inputrec,
+                                                 const t_mdatoms*            mdAtoms) :
     nextVirialCalculationStep_(-1),
     nextEnergyWritingStep_(-1),
     nextLogWritingStep_(-1),
     isMasterRank_(isMaster),
     statePropagatorData_(statePropagatorData),
     energyData_(energyData),
-    freeEnergyPerturbationElement_(freeEnergyPerturbationElement),
+    freeEnergyPerturbationData_(freeEnergyPerturbationData),
     constr_(constr),
     fplog_(fplog),
     inputrec_(inputrec),
@@ -86,8 +86,8 @@ void ConstraintsElement<variable>::elementSetup()
         && ((variable == ConstraintVariable::Positions && inputrec_->eI == eiMD)
             || (variable == ConstraintVariable::Velocities && inputrec_->eI == eiVV)))
     {
-        const real lambdaBonded = freeEnergyPerturbationElement_
-                                          ? freeEnergyPerturbationElement_->constLambdaView()[efptBONDED]
+        const real lambdaBonded = freeEnergyPerturbationData_
+                                          ? freeEnergyPerturbationData_->constLambdaView()[efptBONDED]
                                           : 0;
         // Constrain the initial coordinates and velocities
         do_constrain_first(
@@ -132,9 +132,8 @@ void ConstraintsElement<variable>::apply(Step step, bool calculateVirial, bool w
     ArrayRef<RVec>            min_proj;
     ArrayRefWithPadding<RVec> v;
 
-    const real lambdaBonded = freeEnergyPerturbationElement_
-                                      ? freeEnergyPerturbationElement_->constLambdaView()[efptBONDED]
-                                      : 0;
+    const real lambdaBonded =
+            freeEnergyPerturbationData_ ? freeEnergyPerturbationData_->constLambdaView()[efptBONDED] : 0;
     real dvdlambda = 0;
 
     switch (variable)
index 88e7b359ce1fdcbde4f0043a0c1f654d6b17e167..24dc0b1a0773e6f3b881a64ae3b8044e345e0c1d 100644 (file)
@@ -52,7 +52,7 @@ namespace gmx
 {
 class Constraints;
 class EnergyData;
-class FreeEnergyPerturbationElement;
+class FreeEnergyPerturbationData;
 class StatePropagatorData;
 
 /*! \internal
@@ -75,14 +75,14 @@ class ConstraintsElement final :
 {
 public:
     //! Constructor
-    ConstraintsElement(Constraints*                   constr,
-                       StatePropagatorData*           statePropagatorData,
-                       EnergyData*                    energyData,
-                       FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
-                       bool                           isMaster,
-                       FILE*                          fplog,
-                       const t_inputrec*              inputrec,
-                       const t_mdatoms*               mdAtoms);
+    ConstraintsElement(Constraints*                constr,
+                       StatePropagatorData*        statePropagatorData,
+                       EnergyData*                 energyData,
+                       FreeEnergyPerturbationData* freeEnergyPerturbationData,
+                       bool                        isMaster,
+                       FILE*                       fplog,
+                       const t_inputrec*           inputrec,
+                       const t_mdatoms*            mdAtoms);
 
     /*! \brief Register constraining function for step / time
      *
@@ -131,8 +131,8 @@ private:
     StatePropagatorData* statePropagatorData_;
     //! Pointer to the energy data
     EnergyData* energyData_;
-    //! Pointer to the free energy perturbation element
-    FreeEnergyPerturbationElement* freeEnergyPerturbationElement_;
+    //! Pointer to the free energy perturbation data
+    FreeEnergyPerturbationData* freeEnergyPerturbationData_;
 
     // Access to ISimulator data
     //! Handles constraints.
index 1146ee7f7cfbf57a53e04026a27505c75172589e..61a971762ed8422ee6998aa819446427df2c594c 100644 (file)
@@ -62,7 +62,7 @@
 #include "gromacs/mdtypes/state.h"
 #include "gromacs/topology/topology.h"
 
-#include "freeenergyperturbationelement.h"
+#include "freeenergyperturbationdata.h"
 #include "parrinellorahmanbarostat.h"
 #include "statepropagatordata.h"
 #include "vrescalethermostat.h"
@@ -74,20 +74,20 @@ namespace gmx
 {
 class Awh;
 
-EnergyData::EnergyData(StatePropagatorData*           statePropagatorData,
-                       FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
-                       const gmx_mtop_t*              globalTopology,
-                       const t_inputrec*              inputrec,
-                       const MDAtoms*                 mdAtoms,
-                       gmx_enerdata_t*                enerd,
-                       gmx_ekindata_t*                ekind,
-                       const Constraints*             constr,
-                       FILE*                          fplog,
-                       t_fcdata*                      fcd,
-                       const MdModulesNotifier&       mdModulesNotifier,
-                       bool                           isMasterRank,
-                       ObservablesHistory*            observablesHistory,
-                       StartingBehavior               startingBehavior) :
+EnergyData::EnergyData(StatePropagatorData*        statePropagatorData,
+                       FreeEnergyPerturbationData* freeEnergyPerturbationData,
+                       const gmx_mtop_t*           globalTopology,
+                       const t_inputrec*           inputrec,
+                       const MDAtoms*              mdAtoms,
+                       gmx_enerdata_t*             enerd,
+                       gmx_ekindata_t*             ekind,
+                       const Constraints*          constr,
+                       FILE*                       fplog,
+                       t_fcdata*                   fcd,
+                       const MdModulesNotifier&    mdModulesNotifier,
+                       bool                        isMasterRank,
+                       ObservablesHistory*         observablesHistory,
+                       StartingBehavior            startingBehavior) :
     element_(std::make_unique<Element>(this, isMasterRank)),
     isMasterRank_(isMasterRank),
     forceVirialStep_(-1),
@@ -97,7 +97,7 @@ EnergyData::EnergyData(StatePropagatorData*           statePropagatorData,
     needToSumEkinhOld_(false),
     startingBehavior_(startingBehavior),
     statePropagatorData_(statePropagatorData),
-    freeEnergyPerturbationElement_(freeEnergyPerturbationElement),
+    freeEnergyPerturbationData_(freeEnergyPerturbationData),
     vRescaleThermostat_(nullptr),
     parrinelloRahmanBarostat_(nullptr),
     inputrec_(inputrec),
@@ -118,7 +118,7 @@ EnergyData::EnergyData(StatePropagatorData*           statePropagatorData,
     clear_mat(pressure_);
     clear_rvec(muTot_);
 
-    if (freeEnergyPerturbationElement_)
+    if (freeEnergyPerturbationData_)
     {
         dummyLegacyState_.flags = (1U << estFEPSTATE);
     }
@@ -240,11 +240,11 @@ void EnergyData::doStep(Time time, bool isEnergyCalculationStep, bool isFreeEner
     {
         dummyLegacyState_.therm_integral = vRescaleThermostat_->thermostatIntegral();
     }
-    if (freeEnergyPerturbationElement_)
+    if (freeEnergyPerturbationData_)
     {
-        accumulateKineticLambdaComponents(enerd_, freeEnergyPerturbationElement_->constLambdaView(),
+        accumulateKineticLambdaComponents(enerd_, freeEnergyPerturbationData_->constLambdaView(),
                                           *inputrec_->fepvals);
-        dummyLegacyState_.fep_state = freeEnergyPerturbationElement_->currentFEPState();
+        dummyLegacyState_.fep_state = freeEnergyPerturbationData_->currentFEPState();
     }
     if (parrinelloRahmanBarostat_)
     {
index 935df8c51305d3378ef2b05485d39bcf6dee3308..7efd1cec0ff5c7639bf33addd869e5beab404349 100644 (file)
@@ -62,7 +62,7 @@ namespace gmx
 enum class StartingBehavior;
 class Constraints;
 class EnergyOutput;
-class FreeEnergyPerturbationElement;
+class FreeEnergyPerturbationData;
 class MDAtoms;
 class ParrinelloRahmanBarostat;
 class StatePropagatorData;
@@ -91,20 +91,20 @@ class EnergyData final
 {
 public:
     //! Constructor
-    EnergyData(StatePropagatorData*           statePropagatorData,
-               FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
-               const gmx_mtop_t*              globalTopology,
-               const t_inputrec*              inputrec,
-               const MDAtoms*                 mdAtoms,
-               gmx_enerdata_t*                enerd,
-               gmx_ekindata_t*                ekind,
-               const Constraints*             constr,
-               FILE*                          fplog,
-               t_fcdata*                      fcd,
-               const MdModulesNotifier&       mdModulesNotifier,
-               bool                           isMasterRank,
-               ObservablesHistory*            observablesHistory,
-               StartingBehavior               startingBehavior);
+    EnergyData(StatePropagatorData*        statePropagatorData,
+               FreeEnergyPerturbationData* freeEnergyPerturbationData,
+               const gmx_mtop_t*           globalTopology,
+               const t_inputrec*           inputrec,
+               const MDAtoms*              mdAtoms,
+               gmx_enerdata_t*             enerd,
+               gmx_ekindata_t*             ekind,
+               const Constraints*          constr,
+               FILE*                       fplog,
+               t_fcdata*                   fcd,
+               const MdModulesNotifier&    mdModulesNotifier,
+               bool                        isMasterRank,
+               ObservablesHistory*         observablesHistory,
+               StartingBehavior            startingBehavior);
 
     /*! \brief Final output
      *
@@ -276,8 +276,8 @@ private:
     // TODO: Clarify relationship to data objects and find a more robust alternative to raw pointers (#3583)
     //! Pointer to the state propagator data
     StatePropagatorData* statePropagatorData_;
-    //! Pointer to the free energy perturbation element
-    FreeEnergyPerturbationElement* freeEnergyPerturbationElement_;
+    //! Pointer to the free energy perturbation data
+    FreeEnergyPerturbationData* freeEnergyPerturbationData_;
     //! Pointer to the vrescale thermostat
     const VRescaleThermostat* vRescaleThermostat_;
     //! Pointer to the Parrinello-Rahman barostat
index 531686f26a12577b7cf6e161e59a0719cd8d5ec1..856d27ea03f9c0fc5026cd971e500efd84a89770 100644 (file)
@@ -55,7 +55,7 @@
 #include "gromacs/pbcutil/pbc.h"
 
 #include "energydata.h"
-#include "freeenergyperturbationelement.h"
+#include "freeenergyperturbationdata.h"
 #include "statepropagatordata.h"
 
 struct gmx_edsam;
@@ -65,25 +65,26 @@ class history_t;
 
 namespace gmx
 {
-ForceElement::ForceElement(StatePropagatorData*           statePropagatorData,
-                           EnergyData*                    energyData,
-                           FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
-                           bool                           isVerbose,
-                           bool                           isDynamicBox,
-                           FILE*                          fplog,
-                           const t_commrec*               cr,
-                           const t_inputrec*              inputrec,
-                           const MDAtoms*                 mdAtoms,
-                           t_nrnb*                        nrnb,
-                           t_forcerec*                    fr,
-                           gmx_wallcycle*                 wcycle,
-                           MdrunScheduleWorkload*         runScheduleWork,
-                           VirtualSitesHandler*           vsite,
-                           ImdSession*                    imdSession,
-                           pull_t*                        pull_work,
-                           Constraints*                   constr,
-                           const gmx_mtop_t*              globalTopology,
-                           gmx_enfrot*                    enforcedRotation) :
+ForceElement::ForceElement(StatePropagatorData*        statePropagatorData,
+                           EnergyData*                 energyData,
+                           FreeEnergyPerturbationData* freeEnergyPerturbationData,
+                           bool                        isVerbose,
+                           bool                        isDynamicBox,
+                           FILE*                       fplog,
+                           const t_commrec*            cr,
+                           const t_inputrec*           inputrec,
+                           const MDAtoms*              mdAtoms,
+                           t_nrnb*                     nrnb,
+                           t_forcerec*                 fr,
+
+                           gmx_wallcycle*         wcycle,
+                           MdrunScheduleWorkload* runScheduleWork,
+                           VirtualSitesHandler*   vsite,
+                           ImdSession*            imdSession,
+                           pull_t*                pull_work,
+                           Constraints*           constr,
+                           const gmx_mtop_t*      globalTopology,
+                           gmx_enfrot*            enforcedRotation) :
     shellfc_(init_shell_flexcon(fplog,
                                 globalTopology,
                                 constr ? constr->numFlexibleConstraints() : 0,
@@ -96,7 +97,7 @@ ForceElement::ForceElement(StatePropagatorData*           statePropagatorData,
     nextFreeEnergyCalculationStep_(-1),
     statePropagatorData_(statePropagatorData),
     energyData_(energyData),
-    freeEnergyPerturbationElement_(freeEnergyPerturbationElement),
+    freeEnergyPerturbationData_(freeEnergyPerturbationData),
     localTopology_(nullptr),
     isDynamicBox_(isDynamicBox),
     isVerbose_(isVerbose),
@@ -181,7 +182,7 @@ void ForceElement::run(Step step, Time time, unsigned int flags)
     tensor force_vir = { { 0 } };
     // TODO: Make lambda const (needs some adjustments in lower force routines)
     ArrayRef<real> lambda =
-            freeEnergyPerturbationElement_ ? freeEnergyPerturbationElement_->lambdaView() : lambda_;
+            freeEnergyPerturbationData_ ? freeEnergyPerturbationData_->lambdaView() : lambda_;
 
     if (doShellFC)
     {
index 561ce8829ba642a464e44d11d651b392d409606e..d7a8689494809273e5af1b01a0ce56de6320e9dd 100644 (file)
@@ -66,7 +66,7 @@ namespace gmx
 {
 class Awh;
 class EnergyData;
-class FreeEnergyPerturbationElement;
+class FreeEnergyPerturbationData;
 class ImdSession;
 class MDAtoms;
 class MdrunScheduleWorkload;
@@ -88,25 +88,26 @@ class ForceElement final :
 {
 public:
     //! Constructor
-    ForceElement(StatePropagatorData*           statePropagatorData,
-                 EnergyData*                    energyData,
-                 FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
-                 bool                           isVerbose,
-                 bool                           isDynamicBox,
-                 FILE*                          fplog,
-                 const t_commrec*               cr,
-                 const t_inputrec*              inputrec,
-                 const MDAtoms*                 mdAtoms,
-                 t_nrnb*                        nrnb,
-                 t_forcerec*                    fr,
-                 gmx_wallcycle*                 wcycle,
-                 MdrunScheduleWorkload*         runScheduleWork,
-                 VirtualSitesHandler*           vsite,
-                 ImdSession*                    imdSession,
-                 pull_t*                        pull_work,
-                 Constraints*                   constr,
-                 const gmx_mtop_t*              globalTopology,
-                 gmx_enfrot*                    enforcedRotation);
+    ForceElement(StatePropagatorData*        statePropagatorData,
+                 EnergyData*                 energyData,
+                 FreeEnergyPerturbationData* freeEnergyPerturbationData,
+                 bool                        isVerbose,
+                 bool                        isDynamicBox,
+                 FILE*                       fplog,
+                 const t_commrec*            cr,
+                 const t_inputrec*           inputrec,
+                 const MDAtoms*              mdAtoms,
+                 t_nrnb*                     nrnb,
+                 t_forcerec*                 fr,
+
+                 gmx_wallcycle*         wcycle,
+                 MdrunScheduleWorkload* runScheduleWork,
+                 VirtualSitesHandler*   vsite,
+                 ImdSession*            imdSession,
+                 pull_t*                pull_work,
+                 Constraints*           constr,
+                 const gmx_mtop_t*      globalTopology,
+                 gmx_enfrot*            enforcedRotation);
 
     /*! \brief Register force calculation for step / time
      *
@@ -151,8 +152,8 @@ private:
     StatePropagatorData* statePropagatorData_;
     //! Pointer to the energy data
     EnergyData* energyData_;
-    //! Pointer to the free energy perturbation element
-    FreeEnergyPerturbationElement* freeEnergyPerturbationElement_;
+    //! Pointer to the free energy perturbation data
+    FreeEnergyPerturbationData* freeEnergyPerturbationData_;
 
     //! The local topology - updated by Topology via Client system
     const gmx_localtop_t* localTopology_;
similarity index 64%
rename from src/gromacs/modularsimulator/freeenergyperturbationelement.cpp
rename to src/gromacs/modularsimulator/freeenergyperturbationdata.cpp
index b3f23dab818f282ae69adf95d24b58ca07cde46b..8b7687746b0b0e6a886c197d0d2b2b1e8d1555c6 100644 (file)
@@ -41,7 +41,7 @@
 
 #include "gmxpre.h"
 
-#include "freeenergyperturbationelement.h"
+#include "freeenergyperturbationdata.h"
 
 #include "gromacs/mdlib/md_support.h"
 #include "gromacs/mdlib/mdatoms.h"
 namespace gmx
 {
 
-FreeEnergyPerturbationElement::FreeEnergyPerturbationElement(FILE*             fplog,
-                                                             const t_inputrec* inputrec,
-                                                             MDAtoms*          mdAtoms) :
+FreeEnergyPerturbationData::FreeEnergyPerturbationData(FILE* fplog, const t_inputrec* inputrec, MDAtoms* mdAtoms) :
+    element_(std::make_unique<Element>(this, inputrec->fepvals->delta_lambda)),
     lambda_(),
     lambda0_(),
     currentFEPState_(0),
-    lambdasChange_(inputrec->fepvals->delta_lambda != 0),
     fplog_(fplog),
     inputrec_(inputrec),
     mdAtoms_(mdAtoms)
@@ -69,44 +67,56 @@ FreeEnergyPerturbationElement::FreeEnergyPerturbationElement(FILE*             f
     update_mdatoms(mdAtoms_->mdatoms(), lambda_[efptMASS]);
 }
 
-void FreeEnergyPerturbationElement::scheduleTask(Step step,
-                                                 Time gmx_unused               time,
-                                                 const RegisterRunFunctionPtr& registerRunFunction)
+void FreeEnergyPerturbationData::Element::scheduleTask(Step step,
+                                                       Time gmx_unused               time,
+                                                       const RegisterRunFunctionPtr& registerRunFunction)
 {
     if (lambdasChange_)
     {
-        (*registerRunFunction)(
-                std::make_unique<SimulatorRunFunction>([this, step]() { updateLambdas(step); }));
+        (*registerRunFunction)(std::make_unique<SimulatorRunFunction>(
+                [this, step]() { freeEnergyPerturbationData_->updateLambdas(step); }));
     }
 }
 
-void FreeEnergyPerturbationElement::updateLambdas(Step step)
+void FreeEnergyPerturbationData::updateLambdas(Step step)
 {
     // at beginning of step (if lambdas change...)
     setCurrentLambdasLocal(step, inputrec_->fepvals, lambda0_.data(), lambda_, currentFEPState_);
     update_mdatoms(mdAtoms_->mdatoms(), lambda_[efptMASS]);
 }
 
-ArrayRef<real> FreeEnergyPerturbationElement::lambdaView()
+ArrayRef<real> FreeEnergyPerturbationData::lambdaView()
 {
     return lambda_;
 }
 
-ArrayRef<const real> FreeEnergyPerturbationElement::constLambdaView()
+ArrayRef<const real> FreeEnergyPerturbationData::constLambdaView()
 {
     return lambda_;
 }
 
-int FreeEnergyPerturbationElement::currentFEPState()
+int FreeEnergyPerturbationData::currentFEPState()
 {
     return currentFEPState_;
 }
 
-void FreeEnergyPerturbationElement::writeCheckpoint(t_state* localState, t_state gmx_unused* globalState)
+void FreeEnergyPerturbationData::Element::writeCheckpoint(t_state* localState, t_state gmx_unused* globalState)
 {
-    localState->fep_state = currentFEPState_;
-    localState->lambda    = lambda_;
+    localState->fep_state = freeEnergyPerturbationData_->currentFEPState_;
+    localState->lambda    = freeEnergyPerturbationData_->lambda_;
     localState->flags |= (1U << estLAMBDA) | (1U << estFEPSTATE);
 }
 
+FreeEnergyPerturbationData::Element::Element(FreeEnergyPerturbationData* freeEnergyPerturbationElement,
+                                             double                      deltaLambda) :
+    freeEnergyPerturbationData_(freeEnergyPerturbationElement),
+    lambdasChange_(deltaLambda != 0)
+{
+}
+
+FreeEnergyPerturbationData::Element* FreeEnergyPerturbationData::element()
+{
+    return element_.get();
+}
+
 } // namespace gmx
similarity index 77%
rename from src/gromacs/modularsimulator/freeenergyperturbationelement.h
rename to src/gromacs/modularsimulator/freeenergyperturbationdata.h
index 5be5dd2d34616f418adf49bbea829ffeac8db419..ab89d087cfdfe59cf4f23686c837d8d35c1c4b25 100644 (file)
@@ -58,20 +58,18 @@ class MDAtoms;
 
 /*! \internal
  * \ingroup module_modularsimulator
- * \brief The free energy perturbation element
+ * \brief The free energy perturbation data
  *
  * The lambda vector and the current FEP state are held by the
- * FreeEnergyPerturbationElement, offering access to its values via getter
- * functions. The FreeEnergyPerturbationElement does update the lambda
- * values during the simulation run if lambda is non-static. It does
- * implement the checkpointing client interface to save its current
- * state for restart.
+ * FreeEnergyPerturbationData, offering access to its values via getter
+ * functions. The FreeEnergyPerturbationData::Element is responsible for
+ * lambda update (if applicable) and checkpointing.
  */
-class FreeEnergyPerturbationElement final : public ISimulatorElement, public ICheckpointHelperClient
+class FreeEnergyPerturbationData final
 {
 public:
     //! Constructor
-    FreeEnergyPerturbationElement(FILE* fplog, const t_inputrec* inputrec, MDAtoms* mdAtoms);
+    FreeEnergyPerturbationData(FILE* fplog, const t_inputrec* inputrec, MDAtoms* mdAtoms);
 
     //! Get a view of the current lambda vector
     ArrayRef<real> lambdaView();
@@ -80,21 +78,18 @@ public:
     //! Get the current FEP state
     int currentFEPState();
 
-    //! Update lambda and mdatoms
-    void scheduleTask(Step step, Time time, const RegisterRunFunctionPtr& registerRunFunction) override;
-
-    //! No setup needed
-    void elementSetup() override{};
-
-    //! No teardown needed
-    void elementTeardown() override{};
+    //! The element taking part in the simulator loop
+    class Element;
+    //! Get pointer to element (whose lifetime is managed by this)
+    Element* element();
 
 private:
-    //! ICheckpointHelperClient implementation
-    void writeCheckpoint(t_state* localState, t_state* globalState) override;
     //! Update the lambda values
     void updateLambdas(Step step);
 
+    //! The element
+    std::unique_ptr<Element> element_;
+
     //! The lambda vector
     std::array<real, efptNR> lambda_;
     //! The starting lambda vector
@@ -102,9 +97,6 @@ private:
     //! The current free energy state
     int currentFEPState_;
 
-    //! Whether lambda values are non-static
-    const bool lambdasChange_;
-
     //! Handles logging.
     FILE* fplog_;
     //! Contains user input mdp options.
@@ -113,6 +105,41 @@ private:
     MDAtoms* mdAtoms_;
 };
 
+
+/*! \internal
+ * \ingroup module_modularsimulator
+ * \brief The free energy perturbation data element
+ *
+ * The FreeEnergyPerturbationData::Element does update the lambda
+ * values during the simulation run if lambda is non-static. It does
+ * implement the checkpointing client interface to save its current
+ * state for restart.
+ */
+class FreeEnergyPerturbationData::Element final : public ISimulatorElement, public ICheckpointHelperClient
+{
+public:
+    //! Constructor
+    explicit Element(FreeEnergyPerturbationData* freeEnergyPerturbationElement, double deltaLambda);
+
+    //! Update lambda and mdatoms
+    void scheduleTask(Step step, Time time, const RegisterRunFunctionPtr& registerRunFunction) override;
+
+    //! No setup needed
+    void elementSetup() override{};
+
+    //! No teardown needed
+    void elementTeardown() override{};
+
+private:
+    //! The free energy data
+    FreeEnergyPerturbationData* freeEnergyPerturbationData_;
+    //! Whether lambda values are non-static
+    const bool lambdasChange_;
+
+    //! ICheckpointHelperClient implementation
+    void writeCheckpoint(t_state* localState, t_state* globalState) override;
+};
+
 } // namespace gmx
 
 #endif // GMX_MODULARSIMULATOR_FREEENERGYPERTURBATIONELEMENT_H
index 0f48566ce4f1477e30b8a97c431669e9581c6bb5..594fc55941a99b61c25c3bf0df1a201c772b3eed 100644 (file)
@@ -79,7 +79,7 @@
 #include "constraintelement.h"
 #include "energydata.h"
 #include "forceelement.h"
-#include "freeenergyperturbationelement.h"
+#include "freeenergyperturbationdata.h"
 #include "parrinellorahmanbarostat.h"
 #include "propagator.h"
 #include "signallers.h"
@@ -109,14 +109,14 @@ std::unique_ptr<ISimulatorElement> ModularSimulatorAlgorithmBuilder::buildForces
         SignallerBuilder<EnergySignaller>*         energySignallerBuilder,
         StatePropagatorData*                       statePropagatorDataPtr,
         EnergyData*                                energyDataPtr,
-        FreeEnergyPerturbationElement*             freeEnergyPerturbationElement,
+        FreeEnergyPerturbationData*                freeEnergyPerturbationDataPtr,
         TopologyHolder*                            topologyHolder)
 {
     const bool isVerbose    = mdrunOptions.verbose;
     const bool isDynamicBox = inputrecDynamicBox(inputrec);
 
     auto forceElement = std::make_unique<ForceElement>(
-            statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationElement, isVerbose,
+            statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationDataPtr, isVerbose,
             isDynamicBox, fplog, cr, inputrec, mdAtoms, nrnb, fr, wcycle, runScheduleWork, vsite,
             imdSession, pull_work, constr, top_global, enforcedRotation);
     topologyHolder->registerClient(forceElement.get());
@@ -138,14 +138,14 @@ std::unique_ptr<ISimulatorElement> ModularSimulatorAlgorithmBuilder::buildIntegr
         CheckBondedInteractionsCallbackPtr*        checkBondedInteractionsCallback,
         compat::not_null<StatePropagatorData*>     statePropagatorDataPtr,
         compat::not_null<EnergyData*>              energyDataPtr,
-        FreeEnergyPerturbationElement*             freeEnergyPerturbationElementPtr,
+        FreeEnergyPerturbationData*                freeEnergyPerturbationDataPtr,
         bool                                       hasReadEkinState,
         TopologyHolder*                            topologyHolder,
         SimulationSignals*                         signals)
 {
     auto forceElement = buildForces(neighborSearchSignallerBuilder, energySignallerBuilder,
                                     statePropagatorDataPtr, energyDataPtr,
-                                    freeEnergyPerturbationElementPtr, topologyHolder);
+                                    freeEnergyPerturbationDataPtr, topologyHolder);
 
     // list of elements owned by the simulator composite object
     std::vector<std::unique_ptr<ISimulatorElement>> elementsOwnershipList;
@@ -157,7 +157,7 @@ std::unique_ptr<ISimulatorElement> ModularSimulatorAlgorithmBuilder::buildIntegr
     {
         auto computeGlobalsElement =
                 std::make_unique<ComputeGlobalsElement<ComputeGlobalsAlgorithm::LeapFrog>>(
-                        statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationElementPtr,
+                        statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationDataPtr,
                         signals, nstglobalcomm_, fplog, mdlog, cr, inputrec, mdAtoms, nrnb, wcycle,
                         fr, top_global, constr, hasReadEkinState);
         topologyHolder->registerClient(computeGlobalsElement.get());
@@ -174,7 +174,7 @@ std::unique_ptr<ISimulatorElement> ModularSimulatorAlgorithmBuilder::buildIntegr
         addToCallListAndMove(std::move(forceElement), elementCallList, elementsOwnershipList);
         auto stateElement = compat::make_not_null(statePropagatorDataPtr->element(
                 fplog, cr, inputrec->nstxout, inputrec->nstvout, inputrec->nstfout,
-                inputrec->nstxout_compressed, freeEnergyPerturbationElementPtr, fr->bMolPBC,
+                inputrec->nstxout_compressed, freeEnergyPerturbationDataPtr, fr->bMolPBC,
                 mdrunOptions.writeConfout, opt2fn("-c", nfile, fnm), inputrec, top_global));
         trajectoryElementBuilder->registerWriterClient(stateElement);
         trajectorySignallerBuilder->registerSignallerClient(stateElement);
@@ -214,7 +214,7 @@ std::unique_ptr<ISimulatorElement> ModularSimulatorAlgorithmBuilder::buildIntegr
         if (constr)
         {
             auto constraintElement = std::make_unique<ConstraintsElement<ConstraintVariable::Positions>>(
-                    constr, statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationElementPtr,
+                    constr, statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationDataPtr,
                     MASTER(cr), fplog, inputrec, mdAtoms->mdatoms());
             auto constraintElementPtr = compat::make_not_null(constraintElement.get());
             energySignallerBuilder->registerSignallerClient(constraintElementPtr);
@@ -241,7 +241,7 @@ std::unique_ptr<ISimulatorElement> ModularSimulatorAlgorithmBuilder::buildIntegr
     {
         auto computeGlobalsElement =
                 std::make_unique<ComputeGlobalsElement<ComputeGlobalsAlgorithm::VelocityVerlet>>(
-                        statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationElementPtr,
+                        statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationDataPtr,
                         signals, nstglobalcomm_, fplog, mdlog, cr, inputrec, mdAtoms, nrnb, wcycle,
                         fr, &topologyHolder->globalTopology(), constr, hasReadEkinState);
         topologyHolder->registerClient(computeGlobalsElement.get());
@@ -277,7 +277,7 @@ std::unique_ptr<ISimulatorElement> ModularSimulatorAlgorithmBuilder::buildIntegr
         if (constr)
         {
             auto constraintElement = std::make_unique<ConstraintsElement<ConstraintVariable::Velocities>>(
-                    constr, statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationElementPtr,
+                    constr, statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationDataPtr,
                     MASTER(cr), fplog, inputrec, mdAtoms->mdatoms());
             energySignallerBuilder->registerSignallerClient(compat::make_not_null(constraintElement.get()));
             trajectorySignallerBuilder->registerSignallerClient(
@@ -290,7 +290,7 @@ std::unique_ptr<ISimulatorElement> ModularSimulatorAlgorithmBuilder::buildIntegr
         addToCallList(compat::make_not_null(computeGlobalsElement.get()), elementCallList);
         auto stateElement = compat::make_not_null(statePropagatorDataPtr->element(
                 fplog, cr, inputrec->nstxout, inputrec->nstvout, inputrec->nstfout,
-                inputrec->nstxout_compressed, freeEnergyPerturbationElementPtr, fr->bMolPBC,
+                inputrec->nstxout_compressed, freeEnergyPerturbationDataPtr, fr->bMolPBC,
                 mdrunOptions.writeConfout, opt2fn("-c", nfile, fnm), inputrec, top_global));
         trajectoryElementBuilder->registerWriterClient(stateElement);
         trajectorySignallerBuilder->registerSignallerClient(stateElement);
@@ -319,7 +319,7 @@ std::unique_ptr<ISimulatorElement> ModularSimulatorAlgorithmBuilder::buildIntegr
         if (constr)
         {
             auto constraintElement = std::make_unique<ConstraintsElement<ConstraintVariable::Positions>>(
-                    constr, statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationElementPtr,
+                    constr, statePropagatorDataPtr, energyDataPtr, freeEnergyPerturbationDataPtr,
                     MASTER(cr), fplog, inputrec, mdAtoms->mdatoms());
             energySignallerBuilder->registerSignallerClient(compat::make_not_null(constraintElement.get()));
             trajectorySignallerBuilder->registerSignallerClient(
index b0e27018cb0161876e4d4378ada8dc3e216b95ec..e2f3930efbcfa4ce0e37c620fb25dbc5bc0b3d75 100644 (file)
@@ -77,7 +77,7 @@
 #include "gromacs/utility/fatalerror.h"
 
 #include "domdechelper.h"
-#include "freeenergyperturbationelement.h"
+#include "freeenergyperturbationdata.h"
 #include "modularsimulator.h"
 #include "parrinellorahmanbarostat.h"
 #include "signallers.h"
@@ -99,6 +99,7 @@ ModularSimulatorAlgorithm::ModularSimulatorAlgorithm(std::string              to
     taskIterator_(taskQueue_.end()),
     statePropagatorData_(nullptr),
     energyData_(nullptr),
+    freeEnergyPerturbationData_(nullptr),
     step_(-1),
     runFinished_(false),
     topologyName_(std::move(topologyName)),
@@ -417,21 +418,20 @@ ModularSimulatorAlgorithm ModularSimulatorAlgorithmBuilder::constructElementsAnd
     algorithm.topologyHolder_ =
             std::make_unique<TopologyHolder>(*top_global, cr, inputrec, fr, mdAtoms, constr, vsite);
 
-    std::unique_ptr<FreeEnergyPerturbationElement> freeEnergyPerturbationElement    = nullptr;
-    FreeEnergyPerturbationElement*                 freeEnergyPerturbationElementPtr = nullptr;
     if (inputrec->efep != efepNO)
     {
-        freeEnergyPerturbationElement =
-                std::make_unique<FreeEnergyPerturbationElement>(fplog, inputrec, mdAtoms);
-        freeEnergyPerturbationElementPtr = freeEnergyPerturbationElement.get();
+        algorithm.freeEnergyPerturbationData_ =
+                std::make_unique<FreeEnergyPerturbationData>(fplog, inputrec, mdAtoms);
     }
+    FreeEnergyPerturbationData* freeEnergyPerturbationDataPtr =
+            algorithm.freeEnergyPerturbationData_.get();
 
     algorithm.statePropagatorData_ = std::make_unique<StatePropagatorData>(
             top_global->natoms, cr, state_global, fr->nbv->useGpu(), inputrec, mdAtoms->mdatoms());
     auto statePropagatorDataPtr = compat::make_not_null(algorithm.statePropagatorData_.get());
 
     algorithm.energyData_ = std::make_unique<EnergyData>(
-            statePropagatorDataPtr, freeEnergyPerturbationElementPtr, top_global, inputrec, mdAtoms,
+            statePropagatorDataPtr, freeEnergyPerturbationDataPtr, top_global, inputrec, mdAtoms,
             enerd, ekind, constr, fplog, &fr->listedForces->fcdata(), mdModulesNotifier, MASTER(cr),
             observablesHistory, startingBehavior);
     auto energyDataPtr = compat::make_not_null(algorithm.energyData_.get());
@@ -467,15 +467,22 @@ ModularSimulatorAlgorithm ModularSimulatorAlgorithmBuilder::constructElementsAnd
      * have a full timestep state.
      */
     // TODO: Make a CheckpointHelperBuilder
-    std::vector<ICheckpointHelperClient*> checkpointClients = { freeEnergyPerturbationElementPtr };
+    std::vector<ICheckpointHelperClient*> checkpointClients;
     CheckBondedInteractionsCallbackPtr    checkBondedInteractionsCallback = nullptr;
     auto                                  integrator                      = buildIntegrator(
             &neighborSearchSignallerBuilder, &lastStepSignallerBuilder, &energySignallerBuilder,
             &loggingSignallerBuilder, &trajectorySignallerBuilder, &trajectoryElementBuilder,
             &checkpointClients, &checkBondedInteractionsCallback, statePropagatorDataPtr,
-            energyDataPtr, freeEnergyPerturbationElementPtr, hasReadEkinState,
+            energyDataPtr, freeEnergyPerturbationDataPtr, hasReadEkinState,
             algorithm.topologyHolder_.get(), &algorithm.signals_);
 
+    FreeEnergyPerturbationData::Element* freeEnergyPerturbationElement = nullptr;
+    if (algorithm.freeEnergyPerturbationData_)
+    {
+        freeEnergyPerturbationElement = algorithm.freeEnergyPerturbationData_->element();
+        checkpointClients.emplace_back(freeEnergyPerturbationElement);
+    }
+
     /*
      * Build infrastructure elements
      */
@@ -572,8 +579,7 @@ ModularSimulatorAlgorithm ModularSimulatorAlgorithmBuilder::constructElementsAnd
     addToCallList(algorithm.checkpointHelper_, algorithm.elementCallList_);
     if (freeEnergyPerturbationElement)
     {
-        addToCallListAndMove(std::move(freeEnergyPerturbationElement), algorithm.elementCallList_,
-                             algorithm.elementsOwnershipList_);
+        addToCallList(freeEnergyPerturbationElement, algorithm.elementCallList_);
     }
     addToCallListAndMove(std::move(integrator), algorithm.elementCallList_, algorithm.elementsOwnershipList_);
     addToCallListAndMove(std::move(trajectoryElement), algorithm.elementCallList_,
index 74e7e63d3a570ee857da34b857d433086da26cef..d6a803e290af5fc496c4b8a8804dc02b3e9e0eed 100644 (file)
@@ -55,6 +55,7 @@
 #include "checkpointhelper.h"
 #include "computeglobalselement.h"
 #include "domdechelper.h"
+#include "freeenergyperturbationdata.h"
 #include "modularsimulatorinterfaces.h"
 #include "pmeloadbalancehelper.h"
 
@@ -62,7 +63,6 @@ namespace gmx
 {
 class EnergyData;
 class EnergySignaller;
-class FreeEnergyPerturbationElement;
 class LoggingSignaller;
 class ModularSimulator;
 class NeighborSearchSignaller;
@@ -201,6 +201,8 @@ private:
     std::unique_ptr<StatePropagatorData> statePropagatorData_;
     //! The energy data
     std::unique_ptr<EnergyData> energyData_;
+    //! The free energy data
+    std::unique_ptr<FreeEnergyPerturbationData> freeEnergyPerturbationData_;
 
     //! The current step
     Step step_;
@@ -309,7 +311,7 @@ private:
                     CheckBondedInteractionsCallbackPtr*        checkBondedInteractionsCallback,
                     compat::not_null<StatePropagatorData*>     statePropagatorDataPtr,
                     compat::not_null<EnergyData*>              energyDataPtr,
-                    FreeEnergyPerturbationElement*             freeEnergyPerturbationElementPtr,
+                    FreeEnergyPerturbationData*                freeEnergyPerturbationDataPtr,
                     bool                                       hasReadEkinState,
                     TopologyHolder*                            topologyHolder,
                     SimulationSignals*                         signals);
@@ -320,7 +322,7 @@ private:
                 SignallerBuilder<EnergySignaller>*         energySignallerBuilder,
                 StatePropagatorData*                       statePropagatorDataPtr,
                 EnergyData*                                energyDataPtr,
-                FreeEnergyPerturbationElement*             freeEnergyPerturbationElement,
+                FreeEnergyPerturbationData*                freeEnergyPerturbationDataPtr,
                 TopologyHolder*                            topologyHolder);
 
     //! \cond
index 4880bb59d5b23c05cd1c819350829bf7f8a07c7c..ce6ea478cacc4b801b18d7b9abf06badf42adbde 100644 (file)
@@ -59,7 +59,7 @@
 #include "gromacs/topology/atoms.h"
 #include "gromacs/topology/topology.h"
 
-#include "freeenergyperturbationelement.h"
+#include "freeenergyperturbationdata.h"
 
 namespace gmx
 {
@@ -146,7 +146,7 @@ StatePropagatorData::Element* StatePropagatorData::element(FILE*            fplo
                                                            int              nstvout,
                                                            int              nstfout,
                                                            int              nstxout_compressed,
-                                                           FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
+                                                           FreeEnergyPerturbationData* freeEnergyPerturbationData,
                                                            bool canMoleculesBeDistributedOverPBC,
                                                            bool writeFinalConfiguration,
                                                            std::string finalConfigurationFilename,
@@ -157,12 +157,13 @@ StatePropagatorData::Element* StatePropagatorData::element(FILE*            fplo
     {
         element_ = std::make_unique<Element>(
                 this, fplog, cr, nstxout, nstvout, nstfout, nstxout_compressed,
-                freeEnergyPerturbationElement, canMoleculesBeDistributedOverPBC,
+                freeEnergyPerturbationData, canMoleculesBeDistributedOverPBC,
                 writeFinalConfiguration, std::move(finalConfigurationFilename), inputrec, globalTop);
     }
     else
     {
-        GMX_THROW(InconsistentInputError("Attempted to build StatePropagatorData::Element more than once."));
+        GMX_THROW(InconsistentInputError(
+                "Attempted to build StatePropagatorData::Element more than once."));
     }
     return element_.get();
 }
@@ -344,12 +345,12 @@ void StatePropagatorData::Element::saveState()
 {
     GMX_ASSERT(!localStateBackup_, "Save state called again before previous state was written.");
     localStateBackup_ = statePropagatorData_->localState();
-    if (freeEnergyPerturbationElement_)
+    if (freeEnergyPerturbationData_)
     {
-        localStateBackup_->fep_state = freeEnergyPerturbationElement_->currentFEPState();
+        localStateBackup_->fep_state = freeEnergyPerturbationData_->currentFEPState();
         for (unsigned long i = 0; i < localStateBackup_->lambda.size(); ++i)
         {
-            localStateBackup_->lambda[i] = freeEnergyPerturbationElement_->constLambdaView()[i];
+            localStateBackup_->lambda[i] = freeEnergyPerturbationData_->constLambdaView()[i];
         }
         localStateBackup_->flags |= (1U << estLAMBDA) | (1U << estFEPSTATE);
     }
@@ -518,26 +519,26 @@ SignallerCallbackPtr StatePropagatorData::Element::registerLastStepCallback()
     });
 }
 
-StatePropagatorData::Element::Element(StatePropagatorData*           statePropagatorData,
-                                      FILE*                          fplog,
-                                      const t_commrec*               cr,
-                                      int                            nstxout,
-                                      int                            nstvout,
-                                      int                            nstfout,
-                                      int                            nstxout_compressed,
-                                      FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
-                                      bool              canMoleculesBeDistributedOverPBC,
-                                      bool              writeFinalConfiguration,
-                                      std::string       finalConfigurationFilename,
-                                      const t_inputrec* inputrec,
-                                      const gmx_mtop_t* globalTop) :
+StatePropagatorData::Element::Element(StatePropagatorData*        statePropagatorData,
+                                      FILE*                       fplog,
+                                      const t_commrec*            cr,
+                                      int                         nstxout,
+                                      int                         nstvout,
+                                      int                         nstfout,
+                                      int                         nstxout_compressed,
+                                      FreeEnergyPerturbationData* freeEnergyPerturbationData,
+                                      bool                        canMoleculesBeDistributedOverPBC,
+                                      bool                        writeFinalConfiguration,
+                                      std::string                 finalConfigurationFilename,
+                                      const t_inputrec*           inputrec,
+                                      const gmx_mtop_t*           globalTop) :
     statePropagatorData_(statePropagatorData),
     nstxout_(nstxout),
     nstvout_(nstvout),
     nstfout_(nstfout),
     nstxout_compressed_(nstxout_compressed),
     writeOutStep_(-1),
-    freeEnergyPerturbationElement_(freeEnergyPerturbationElement),
+    freeEnergyPerturbationData_(freeEnergyPerturbationData),
     isRegularSimulationEnd_(false),
     lastStep_(-1),
     canMoleculesBeDistributedOverPBC_(canMoleculesBeDistributedOverPBC),
index 8d5560dd260b3732c82bdb0a93ead74da51d46c7..16b6c97d311d306cfc507275fc0e54efe8a44b44 100644 (file)
@@ -61,7 +61,7 @@ struct t_mdatoms;
 namespace gmx
 {
 enum class ConstraintVariable;
-class FreeEnergyPerturbationElement;
+class FreeEnergyPerturbationData;
 
 /*! \internal
  * \ingroup module_modularsimulator
@@ -131,18 +131,18 @@ public:
     //! The element taking part in the simulator loop
     class Element;
     //! Get pointer to element (whose lifetime is managed by this)
-    Element* element(FILE*                          fplog,
-                     const t_commrec*               cr,
-                     int                            nstxout,
-                     int                            nstvout,
-                     int                            nstfout,
-                     int                            nstxout_compressed,
-                     FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
-                     bool                           canMoleculesBeDistributedOverPBC,
-                     bool                           writeFinalConfiguration,
-                     std::string                    finalConfigurationFilename,
-                     const t_inputrec*              inputrec,
-                     const gmx_mtop_t*              globalTop);
+    Element* element(FILE*                       fplog,
+                     const t_commrec*            cr,
+                     int                         nstxout,
+                     int                         nstvout,
+                     int                         nstfout,
+                     int                         nstxout_compressed,
+                     FreeEnergyPerturbationData* freeEnergyPerturbationData,
+                     bool                        canMoleculesBeDistributedOverPBC,
+                     bool                        writeFinalConfiguration,
+                     std::string                 finalConfigurationFilename,
+                     const t_inputrec*           inputrec,
+                     const gmx_mtop_t*           globalTop);
     //! Initial set up for the associated element
     void setup();
 
@@ -236,19 +236,19 @@ class StatePropagatorData::Element final :
 {
 public:
     //! Constructor
-    Element(StatePropagatorData*           statePropagatorData,
-            FILE*                          fplog,
-            const t_commrec*               cr,
-            int                            nstxout,
-            int                            nstvout,
-            int                            nstfout,
-            int                            nstxout_compressed,
-            FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
-            bool                           canMoleculesBeDistributedOverPBC,
-            bool                           writeFinalConfiguration,
-            std::string                    finalConfigurationFilename,
-            const t_inputrec*              inputrec,
-            const gmx_mtop_t*              globalTop);
+    Element(StatePropagatorData*        statePropagatorData,
+            FILE*                       fplog,
+            const t_commrec*            cr,
+            int                         nstxout,
+            int                         nstvout,
+            int                         nstfout,
+            int                         nstxout_compressed,
+            FreeEnergyPerturbationData* freeEnergyPerturbationData,
+            bool                        canMoleculesBeDistributedOverPBC,
+            bool                        writeFinalConfiguration,
+            std::string                 finalConfigurationFilename,
+            const t_inputrec*           inputrec,
+            const gmx_mtop_t*           globalTop);
 
     /*! \brief Register run function for step / time
      *
@@ -315,8 +315,8 @@ private:
     void write(gmx_mdoutf* outf, Step step, Time time);
 
     // TODO: Clarify relationship to data objects and find a more robust alternative to raw pointers (#3583)
-    //! Pointer to the free energy perturbation element (for trajectory writing only)
-    FreeEnergyPerturbationElement* freeEnergyPerturbationElement_;
+    //! Pointer to the free energy perturbation data (for trajectory writing only)
+    FreeEnergyPerturbationData* freeEnergyPerturbationData_;
 
     //! No trajectory writer setup needed
     void trajectoryWriterSetup(gmx_mdoutf gmx_unused* outf) override {}