Merge force and shellFC elements
authorPascal Merz <pascal.merz@me.com>
Mon, 10 Feb 2020 23:08:46 +0000 (16:08 -0700)
committerPascal Merz <pascal.merz@me.com>
Tue, 7 Apr 2020 21:50:43 +0000 (21:50 +0000)
In the previous implementation, ForceElement was handling the call to
do_force, while ShellFCElement was handling the call to relax_shell_flexcon.
This lead to two nearly identical elements. The current change merges
the two elements minimizing code duplication.

Change-Id: Ief6e962e3780153d43ba4ea07eea40ed5b8d4ef8

src/gromacs/modularsimulator/forceelement.cpp
src/gromacs/modularsimulator/forceelement.h
src/gromacs/modularsimulator/modularsimulator.cpp
src/gromacs/modularsimulator/shellfcelement.cpp [deleted file]
src/gromacs/modularsimulator/shellfcelement.h [deleted file]

index 7f29d2f11a0851eb88d25cfa18a0eb9e4f65dd72..734ba4eda49981a0b06b87c7083bd0bdcca1ec45 100644 (file)
 
 #include "forceelement.h"
 
+#include "gromacs/domdec/mdsetup.h"
 #include "gromacs/math/vectypes.h"
+#include "gromacs/mdlib/constr.h"
 #include "gromacs/mdlib/force.h"
 #include "gromacs/mdlib/force_flags.h"
 #include "gromacs/mdlib/mdatoms.h"
+#include "gromacs/mdrun/shellfc.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/mdatom.h"
 #include "gromacs/pbcutil/pbc.h"
@@ -65,6 +68,7 @@ namespace gmx
 ForceElement::ForceElement(StatePropagatorData*           statePropagatorData,
                            EnergyElement*                 energyElement,
                            FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
+                           bool                           isVerbose,
                            bool                           isDynamicBox,
                            FILE*                          fplog,
                            const t_commrec*               cr,
@@ -78,7 +82,15 @@ ForceElement::ForceElement(StatePropagatorData*           statePropagatorData,
                            gmx_vsite_t*                   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,
+                                inputrec->nstcalcenergy,
+                                DOMAINDECOMP(cr))),
+    doShellFC_(shellfc_ != nullptr),
     nextNSStep_(-1),
     nextEnergyCalculationStep_(-1),
     nextVirialCalculationStep_(-1),
@@ -88,6 +100,8 @@ ForceElement::ForceElement(StatePropagatorData*           statePropagatorData,
     freeEnergyPerturbationElement_(freeEnergyPerturbationElement),
     localTopology_(nullptr),
     isDynamicBox_(isDynamicBox),
+    isVerbose_(isVerbose),
+    nShellRelaxationSteps_(0),
     ddBalanceRegionHandler_(cr),
     lambda_(),
     fplog_(fplog),
@@ -102,9 +116,17 @@ ForceElement::ForceElement(StatePropagatorData*           statePropagatorData,
     pull_work_(pull_work),
     fcd_(fcd),
     runScheduleWork_(runScheduleWork),
+    constr_(constr),
     enforcedRotation_(enforcedRotation)
 {
     lambda_.fill(0);
+
+    if (doShellFC_ && !DOMAINDECOMP(cr))
+    {
+        // This was done in mdAlgorithmsSetupAtomData(), but shellfc
+        // won't be available outside this element.
+        make_local_shells(cr, mdAtoms->mdatoms(), shellfc_);
+    }
 }
 
 void ForceElement::scheduleTask(Step step, Time time, const RegisterRunFunctionPtr& registerRunFunction)
@@ -114,10 +136,18 @@ void ForceElement::scheduleTask(Step step, Time time, const RegisterRunFunctionP
              | (nextVirialCalculationStep_ == step ? GMX_FORCE_VIRIAL : 0)
              | (nextEnergyCalculationStep_ == step ? GMX_FORCE_ENERGY : 0)
              | (nextFreeEnergyCalculationStep_ == step ? GMX_FORCE_DHDL : 0)
-             | (nextNSStep_ == step ? GMX_FORCE_NS : 0));
-
-    (*registerRunFunction)(std::make_unique<SimulatorRunFunction>(
-            [this, step, time, flags]() { run(step, time, flags); }));
+             | (!doShellFC_ && nextNSStep_ == step ? GMX_FORCE_NS : 0));
+
+    (*registerRunFunction)(std::make_unique<SimulatorRunFunction>([this, step, time, flags]() {
+        if (doShellFC_)
+        {
+            run<true>(step, time, flags);
+        }
+        else
+        {
+            run<false>(step, time, flags);
+        }
+    }));
 }
 
 void ForceElement::elementSetup()
@@ -125,12 +155,12 @@ void ForceElement::elementSetup()
     GMX_ASSERT(localTopology_, "Setup called before local topology was set.");
 }
 
+template<bool doShellFC>
 void ForceElement::run(Step step, Time time, unsigned int flags)
 {
     // Disabled functionality
-    Awh*            awh = nullptr;
-    gmx_edsam*      ed  = nullptr;
-    gmx_multisim_t* ms  = nullptr;
+    gmx_multisim_t* ms = nullptr;
+
 
     if (!DOMAINDECOMP(cr_) && (flags & GMX_FORCE_NS) && inputrecDynamicBox(inputrec_))
     {
@@ -155,13 +185,40 @@ void ForceElement::run(Step step, Time time, unsigned int flags)
     ArrayRef<real> lambda =
             freeEnergyPerturbationElement_ ? freeEnergyPerturbationElement_->lambdaView() : lambda_;
 
-    do_force(fplog_, cr_, ms, inputrec_, awh, enforcedRotation_, imdSession_, pull_work_, step,
-             nrnb_, wcycle_, localTopology_, box, x, hist, forces, force_vir, mdAtoms_->mdatoms(),
-             energyElement_->enerdata(), fcd_, lambda, fr_, runScheduleWork_, vsite_,
-             energyElement_->muTot(), time, ed, static_cast<int>(flags), ddBalanceRegionHandler_);
+    if (doShellFC)
+    {
+        auto v = statePropagatorData_->velocitiesView();
+
+        relax_shell_flexcon(
+                fplog_, cr_, ms, isVerbose_, enforcedRotation_, step, inputrec_, imdSession_,
+                pull_work_, step == nextNSStep_, static_cast<int>(flags), localTopology_, constr_,
+                energyElement_->enerdata(), fcd_, statePropagatorData_->localNumAtoms(), x, v, box,
+                lambda, hist, forces, force_vir, mdAtoms_->mdatoms(), nrnb_, wcycle_, shellfc_, fr_,
+                runScheduleWork_, time, energyElement_->muTot(), vsite_, ddBalanceRegionHandler_);
+        nShellRelaxationSteps_++;
+    }
+    else
+    {
+        // Disabled functionality
+        Awh*       awh = nullptr;
+        gmx_edsam* ed  = nullptr;
+
+        do_force(fplog_, cr_, ms, inputrec_, awh, enforcedRotation_, imdSession_, pull_work_, step,
+                 nrnb_, wcycle_, localTopology_, box, x, hist, forces, force_vir, mdAtoms_->mdatoms(),
+                 energyElement_->enerdata(), fcd_, lambda, fr_, runScheduleWork_, vsite_,
+                 energyElement_->muTot(), time, ed, static_cast<int>(flags), ddBalanceRegionHandler_);
+    }
     energyElement_->addToForceVirial(force_vir, step);
 }
 
+void ForceElement::elementTeardown()
+{
+    if (doShellFC_)
+    {
+        done_shellfc(fplog_, shellfc_, nShellRelaxationSteps_);
+    }
+}
+
 void ForceElement::setTopology(const gmx_localtop_t* top)
 {
     localTopology_ = top;
index a244bc432cf42dde731363642703e626d9482eed..6bf90b37a4d9f46d590a24b77fa46324e4ef15d4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, 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.
@@ -35,6 +35,9 @@
 /*! \libinternal \file
  * \brief Declares the force element for the modular simulator
  *
+ * This element calculates the forces, with or without shells or
+ * flexible constraints.
+ *
  * \author Pascal Merz <pascal.merz@me.com>
  * \ingroup module_modularsimulator
  */
@@ -52,6 +55,7 @@
 #include "topologyholder.h"
 
 struct gmx_enfrot;
+struct gmx_shellfc_t;
 struct gmx_wallcycle;
 struct pull_t;
 struct t_fcdata;
@@ -71,7 +75,8 @@ class StatePropagatorData;
  * \ingroup module_modularsimulator
  * \brief Force element
  *
- * The force element manages the call to do_force(...)
+ * The force element manages the call to either
+ * do_force(...) or relax_shell_flexcon(...)
  */
 class ForceElement final :
     public ISimulatorElement,
@@ -84,6 +89,7 @@ public:
     ForceElement(StatePropagatorData*           statePropagatorData,
                  EnergyElement*                 energyElement,
                  FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
+                 bool                           isVerbose,
                  bool                           isDynamicBox,
                  FILE*                          fplog,
                  const t_commrec*               cr,
@@ -97,6 +103,8 @@ public:
                  gmx_vsite_t*                   vsite,
                  ImdSession*                    imdSession,
                  pull_t*                        pull_work,
+                 Constraints*                   constr,
+                 const gmx_mtop_t*              globalTopology,
                  gmx_enfrot*                    enforcedRotation);
 
     /*! \brief Register force calculation for step / time
@@ -109,8 +117,8 @@ public:
 
     //! Check that we got the local topology
     void elementSetup() override;
-    //! No element teardown needed
-    void elementTeardown() override {}
+    //! Print some final output
+    void elementTeardown() override;
 
 private:
     //! ITopologyHolderClient implementation
@@ -120,8 +128,14 @@ private:
     //! IEnergySignallerClient implementation
     SignallerCallbackPtr registerEnergyCallback(EnergySignallerEvent event) override;
     //! The actual do_force call
+    template<bool doShellFC>
     void run(Step step, Time time, unsigned int flags);
 
+    //! The shell / FC helper struct
+    gmx_shellfc_t* shellfc_;
+    //! Whether shells or flexible constraints are present
+    const bool doShellFC_;
+
     //! The next NS step
     Step nextNSStep_;
     //! The next energy calculation step
@@ -143,6 +157,10 @@ private:
 
     //! Whether we're having a dynamic box
     const bool isDynamicBox_;
+    //! Whether we're being verbose
+    const bool isVerbose_;
+    //! The number of shell relaxation steps we did
+    Step nShellRelaxationSteps_;
 
     //! DD / DLB helper object
     const DDBalanceRegionHandler ddBalanceRegionHandler_;
@@ -179,6 +197,8 @@ private:
     t_fcdata* fcd_;
     //! Schedule of work for each MD step for this task.
     MdrunScheduleWorkload* runScheduleWork_;
+    //! Handles constraints.
+    Constraints* constr_;
     //! Handles enforced rotation.
     gmx_enfrot* enforcedRotation_;
 };
index c71d731e5f293f36380b257eab936ba0c50c7113..d4bf96184140130af893055dc71af801c18355e4 100644 (file)
@@ -86,7 +86,6 @@
 #include "freeenergyperturbationelement.h"
 #include "parrinellorahmanbarostat.h"
 #include "propagator.h"
-#include "shellfcelement.h"
 #include "signallers.h"
 #include "statepropagatordata.h"
 #include "trajectoryelement.h"
@@ -542,35 +541,17 @@ ModularSimulator::buildForces(SignallerBuilder<NeighborSearchSignaller>* neighbo
 {
     const bool isVerbose    = mdrunOptions.verbose;
     const bool isDynamicBox = inputrecDynamicBox(inputrec);
-    // Check for polarizable models and flexible constraints
-    if (ShellFCElement::doShellsOrFlexConstraints(topologyHolder_->globalTopology(),
-                                                  constr ? constr->numFlexibleConstraints() : 0))
-    {
-        auto shellFCElement = std::make_unique<ShellFCElement>(
-                statePropagatorDataPtr, energyElementPtr, freeEnergyPerturbationElement, isVerbose,
-                isDynamicBox, fplog, cr, inputrec, mdAtoms, nrnb, fr, fcd, wcycle, runScheduleWork, vsite,
-                imdSession, pull_work, constr, &topologyHolder_->globalTopology(), enforcedRotation);
-        topologyHolder_->registerClient(shellFCElement.get());
-        neighborSearchSignallerBuilder->registerSignallerClient(
-                compat::make_not_null(shellFCElement.get()));
-        energySignallerBuilder->registerSignallerClient(compat::make_not_null(shellFCElement.get()));
-
-        // std::move *should* not be needed with c++-14, but clang-3.6 still requires it
-        return std::move(shellFCElement);
-    }
-    else
-    {
-        auto forceElement = std::make_unique<ForceElement>(
-                statePropagatorDataPtr, energyElementPtr, freeEnergyPerturbationElement,
-                isDynamicBox, fplog, cr, inputrec, mdAtoms, nrnb, fr, fcd, wcycle, runScheduleWork,
-                vsite, imdSession, pull_work, enforcedRotation);
-        topologyHolder_->registerClient(forceElement.get());
-        neighborSearchSignallerBuilder->registerSignallerClient(compat::make_not_null(forceElement.get()));
-        energySignallerBuilder->registerSignallerClient(compat::make_not_null(forceElement.get()));
-
-        // std::move *should* not be needed with c++-14, but clang-3.6 still requires it
-        return std::move(forceElement);
-    }
+
+    auto forceElement = std::make_unique<ForceElement>(
+            statePropagatorDataPtr, energyElementPtr, freeEnergyPerturbationElement, isVerbose,
+            isDynamicBox, fplog, cr, inputrec, mdAtoms, nrnb, fr, fcd, wcycle, runScheduleWork, vsite,
+            imdSession, pull_work, constr, &topologyHolder_->globalTopology(), enforcedRotation);
+    topologyHolder_->registerClient(forceElement.get());
+    neighborSearchSignallerBuilder->registerSignallerClient(compat::make_not_null(forceElement.get()));
+    energySignallerBuilder->registerSignallerClient(compat::make_not_null(forceElement.get()));
+
+    // std::move *should* not be needed with c++-14, but clang-3.6 still requires it
+    return std::move(forceElement);
 }
 
 std::unique_ptr<ISimulatorElement> ModularSimulator::buildIntegrator(
diff --git a/src/gromacs/modularsimulator/shellfcelement.cpp b/src/gromacs/modularsimulator/shellfcelement.cpp
deleted file mode 100644 (file)
index 5d7b0ff..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 2019,2020, 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.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-/*! \internal \file
- * \brief Defines the shell / flex constraints element for the modular simulator
- *
- * \author Pascal Merz <pascal.merz@me.com>
- * \ingroup module_modularsimulator
- */
-
-#include "gmxpre.h"
-
-#include "shellfcelement.h"
-
-#include "gromacs/domdec/mdsetup.h"
-#include "gromacs/math/vectypes.h"
-#include "gromacs/mdlib/constr.h"
-#include "gromacs/mdlib/force.h"
-#include "gromacs/mdlib/force_flags.h"
-#include "gromacs/mdlib/mdatoms.h"
-#include "gromacs/mdrun/shellfc.h"
-#include "gromacs/mdtypes/inputrec.h"
-#include "gromacs/mdtypes/mdatom.h"
-#include "gromacs/pbcutil/pbc.h"
-#include "gromacs/topology/atoms.h"
-#include "gromacs/topology/mtop_util.h"
-
-#include "energyelement.h"
-#include "freeenergyperturbationelement.h"
-#include "statepropagatordata.h"
-
-struct gmx_edsam;
-struct gmx_enfrot;
-struct gmx_multisim_t;
-class history_t;
-
-namespace gmx
-{
-bool ShellFCElement::doShellsOrFlexConstraints(const gmx_mtop_t& mtop, int nflexcon)
-{
-    if (nflexcon != 0)
-    {
-        return true;
-    }
-    std::array<int, eptNR> n = gmx_mtop_particletype_count(mtop);
-    return n[eptShell] != 0;
-}
-
-ShellFCElement::ShellFCElement(StatePropagatorData*           statePropagatorData,
-                               EnergyElement*                 energyElement,
-                               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,
-                               t_fcdata*                      fcd,
-                               gmx_wallcycle*                 wcycle,
-                               MdrunScheduleWorkload*         runScheduleWork,
-                               gmx_vsite_t*                   vsite,
-                               ImdSession*                    imdSession,
-                               pull_t*                        pull_work,
-                               Constraints*                   constr,
-                               const gmx_mtop_t*              globalTopology,
-                               gmx_enfrot*                    enforcedRotation) :
-    nextNSStep_(-1),
-    nextEnergyCalculationStep_(-1),
-    nextVirialCalculationStep_(-1),
-    nextFreeEnergyCalculationStep_(-1),
-    statePropagatorData_(statePropagatorData),
-    energyElement_(energyElement),
-    freeEnergyPerturbationElement_(freeEnergyPerturbationElement),
-    localTopology_(nullptr),
-    isDynamicBox_(isDynamicBox),
-    isVerbose_(isVerbose),
-    nSteps_(0),
-    ddBalanceRegionHandler_(cr),
-    fplog_(fplog),
-    cr_(cr),
-    inputrec_(inputrec),
-    mdAtoms_(mdAtoms),
-    nrnb_(nrnb),
-    wcycle_(wcycle),
-    fr_(fr),
-    vsite_(vsite),
-    imdSession_(imdSession),
-    pull_work_(pull_work),
-    fcd_(fcd),
-    runScheduleWork_(runScheduleWork),
-    constr_(constr),
-    enforcedRotation_(enforcedRotation)
-{
-    lambda_.fill(0);
-
-    shellfc_ = init_shell_flexcon(fplog, globalTopology, constr_ ? constr_->numFlexibleConstraints() : 0,
-                                  inputrec->nstcalcenergy, DOMAINDECOMP(cr));
-
-    GMX_ASSERT(shellfc_, "ShellFCElement built, but init_shell_flexcon returned a nullptr");
-
-    if (!DOMAINDECOMP(cr))
-    {
-        // This was done in mdAlgorithmsSetupAtomData(), but shellfc
-        // won't be available outside this element.
-        make_local_shells(cr, mdAtoms->mdatoms(), shellfc_);
-    }
-}
-
-void ShellFCElement::scheduleTask(Step step, Time time, const RegisterRunFunctionPtr& registerRunFunction)
-{
-    unsigned int flags =
-            (GMX_FORCE_STATECHANGED | GMX_FORCE_ALLFORCES | (isDynamicBox_ ? GMX_FORCE_DYNAMICBOX : 0)
-             | (nextVirialCalculationStep_ == step ? GMX_FORCE_VIRIAL : 0)
-             | (nextEnergyCalculationStep_ == step ? GMX_FORCE_ENERGY : 0)
-             | (nextFreeEnergyCalculationStep_ == step ? GMX_FORCE_DHDL : 0));
-
-    const bool isNSStep = (step == nextNSStep_);
-    (*registerRunFunction)(std::make_unique<SimulatorRunFunction>(
-            [this, step, time, flags, isNSStep]() { run(step, time, isNSStep, flags); }));
-    nSteps_++;
-}
-
-void ShellFCElement::elementSetup()
-{
-    GMX_ASSERT(localTopology_, "Setup called before local topology was set.");
-}
-
-void ShellFCElement::run(Step step, Time time, bool isNSStep, unsigned int flags)
-{
-    // Disabled functionality
-    gmx_multisim_t* ms = nullptr;
-
-    if (!DOMAINDECOMP(cr_) && isNSStep && inputrecDynamicBox(inputrec_))
-    {
-        // TODO: Correcting the box is done in DomDecHelper (if using DD) or here (non-DD simulations).
-        //       Think about unifying this responsibility, could this be done in one place?
-        auto box = statePropagatorData_->box();
-        correct_box(fplog_, step, box);
-    }
-
-    auto       x      = statePropagatorData_->positionsView();
-    auto       v      = statePropagatorData_->velocitiesView();
-    auto       forces = statePropagatorData_->forcesView();
-    auto       box    = statePropagatorData_->constBox();
-    history_t* hist   = nullptr; // disabled
-
-    tensor force_vir = { { 0 } };
-    // TODO: Make lambda const (needs some adjustments in lower force routines)
-    ArrayRef<real> lambda =
-            freeEnergyPerturbationElement_ ? freeEnergyPerturbationElement_->lambdaView() : lambda_;
-    relax_shell_flexcon(fplog_, cr_, ms, isVerbose_, enforcedRotation_, step, inputrec_, imdSession_,
-                        pull_work_, isNSStep, static_cast<int>(flags), localTopology_, constr_,
-                        energyElement_->enerdata(), fcd_, statePropagatorData_->localNumAtoms(), x,
-                        v, box, lambda, hist, forces, force_vir, mdAtoms_->mdatoms(), nrnb_,
-                        wcycle_, shellfc_, fr_, runScheduleWork_, time, energyElement_->muTot(),
-                        vsite_, ddBalanceRegionHandler_);
-    energyElement_->addToForceVirial(force_vir, step);
-}
-
-void ShellFCElement::elementTeardown()
-{
-    done_shellfc(fplog_, shellfc_, nSteps_);
-}
-
-void ShellFCElement::setTopology(const gmx_localtop_t* top)
-{
-    localTopology_ = top;
-}
-
-SignallerCallbackPtr ShellFCElement::registerNSCallback()
-{
-    return std::make_unique<SignallerCallback>(
-            [this](Step step, Time gmx_unused time) { this->nextNSStep_ = step; });
-}
-
-SignallerCallbackPtr ShellFCElement::registerEnergyCallback(EnergySignallerEvent event)
-{
-    if (event == EnergySignallerEvent::EnergyCalculationStep)
-    {
-        return std::make_unique<SignallerCallback>(
-                [this](Step step, Time /*unused*/) { nextEnergyCalculationStep_ = step; });
-    }
-    if (event == EnergySignallerEvent::VirialCalculationStep)
-    {
-        return std::make_unique<SignallerCallback>(
-                [this](Step step, Time /*unused*/) { nextVirialCalculationStep_ = step; });
-    }
-    if (event == EnergySignallerEvent::FreeEnergyCalculationStep)
-    {
-        return std::make_unique<SignallerCallback>(
-                [this](Step step, Time /*unused*/) { nextFreeEnergyCalculationStep_ = step; });
-    }
-    return nullptr;
-}
-} // namespace gmx
diff --git a/src/gromacs/modularsimulator/shellfcelement.h b/src/gromacs/modularsimulator/shellfcelement.h
deleted file mode 100644 (file)
index 548ff18..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 2019,2020, 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.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-/*! \libinternal \file
- * \brief Declares the shell / flex constraints element for the modular simulator
- *
- * \author Pascal Merz <pascal.merz@me.com>
- * \ingroup module_modularsimulator
- */
-
-#ifndef GMX_MODULARSIMULATOR_SHELLFCELEMENT_H
-#define GMX_MODULARSIMULATOR_SHELLFCELEMENT_H
-
-#include <array>
-
-#include "gromacs/domdec/dlbtiming.h"
-#include "gromacs/mdtypes/md_enums.h"
-#include "gromacs/utility/real.h"
-
-#include "modularsimulatorinterfaces.h"
-#include "topologyholder.h"
-
-struct gmx_enfrot;
-struct gmx_shellfc_t;
-struct gmx_wallcycle;
-struct pull_t;
-struct t_fcdata;
-struct t_nrnb;
-
-namespace gmx
-{
-class Awh;
-class EnergyElement;
-class FreeEnergyPerturbationElement;
-class ImdSession;
-class MDAtoms;
-class MdrunScheduleWorkload;
-class StatePropagatorData;
-
-/*! \libinternal
- * \ingroup module_modularsimulator
- * \brief Shell & flex constraints element
- *
- * The ShellFCElement manages the call to relax_shell_flexcon(...)
- */
-class ShellFCElement final :
-    public ISimulatorElement,
-    public ITopologyHolderClient,
-    public INeighborSearchSignallerClient,
-    public IEnergySignallerClient
-{
-public:
-    //! Constructor
-    ShellFCElement(StatePropagatorData*           statePropagatorData,
-                   EnergyElement*                 energyElement,
-                   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,
-                   t_fcdata*                      fcd,
-                   gmx_wallcycle*                 wcycle,
-                   MdrunScheduleWorkload*         runScheduleWork,
-                   gmx_vsite_t*                   vsite,
-                   ImdSession*                    imdSession,
-                   pull_t*                        pull_work,
-                   Constraints*                   constr,
-                   const gmx_mtop_t*              globalTopology,
-                   gmx_enfrot*                    enforcedRotation);
-
-    /*! \brief Register shell / flex constraint calculation for step / time
-     *
-     * @param step                 The step number
-     * @param time                 The time
-     * @param registerRunFunction  Function allowing to register a run function
-     */
-    void scheduleTask(Step step, Time time, const RegisterRunFunctionPtr& registerRunFunction) override;
-
-    //! Check that we got the local topology
-    void elementSetup() override;
-    //! Print some final output
-    void elementTeardown() override;
-
-    //! Whether either shells or flexible constraints are used
-    static bool doShellsOrFlexConstraints(const gmx_mtop_t& mtop, int nflexcon);
-
-private:
-    //! ITopologyHolderClient implementation
-    void setTopology(const gmx_localtop_t* top) override;
-    //! INeighborSearchSignallerClient implementation
-    SignallerCallbackPtr registerNSCallback() override;
-    //! IEnergySignallerClient implementation
-    SignallerCallbackPtr registerEnergyCallback(EnergySignallerEvent event) override;
-    //! The actual do_force call
-    void run(Step step, Time time, bool isNSStep, unsigned int flags);
-
-    //! The shell / FC helper struct
-    gmx_shellfc_t* shellfc_;
-
-    //! The next NS step
-    Step nextNSStep_;
-    //! The next energy calculation step
-    Step nextEnergyCalculationStep_;
-    //! The next energy calculation step
-    Step nextVirialCalculationStep_;
-    //! The next free energy calculation step
-    Step nextFreeEnergyCalculationStep_;
-
-    //! Pointer to the micro state
-    StatePropagatorData* statePropagatorData_;
-    //! Pointer to the energy element
-    EnergyElement* energyElement_;
-    //! The free energy perturbation element
-    FreeEnergyPerturbationElement* freeEnergyPerturbationElement_;
-
-    //! The local topology - updated by Topology via Client system
-    const gmx_localtop_t* localTopology_;
-
-    //! Whether we're having a dynamic box
-    const bool isDynamicBox_;
-    //! Whether we're being verbose
-    const bool isVerbose_;
-    //! The number of shell relaxation steps we did
-    Step nSteps_;
-
-    //! DD / DLB helper object
-    const DDBalanceRegionHandler ddBalanceRegionHandler_;
-
-    /* \brief The FEP lambda vector
-     *
-     * Used if FEP is off, since do_force
-     * requires lambda to be allocated anyway
-     */
-    std::array<real, efptNR> lambda_;
-
-    // Access to ISimulator data
-    //! Handles logging.
-    FILE* fplog_;
-    //! Handles communication.
-    const t_commrec* cr_;
-    //! Contains user input mdp options.
-    const t_inputrec* inputrec_;
-    //! Atom parameters for this domain.
-    const MDAtoms* mdAtoms_;
-    //! Manages flop accounting.
-    t_nrnb* nrnb_;
-    //! Manages wall cycle accounting.
-    gmx_wallcycle* wcycle_;
-    //! Parameters for force calculations.
-    t_forcerec* fr_;
-    //! Handles virtual sites.
-    gmx_vsite_t* vsite_;
-    //! The Interactive Molecular Dynamics session.
-    ImdSession* imdSession_;
-    //! The pull work object.
-    pull_t* pull_work_;
-    //! Helper struct for force calculations.
-    t_fcdata* fcd_;
-    //! Schedule of work for each MD step for this task.
-    MdrunScheduleWorkload* runScheduleWork_;
-    //! Handles constraints.
-    Constraints* constr_;
-    //! Handles enforced rotation.
-    gmx_enfrot* enforcedRotation_;
-};
-
-} // namespace gmx
-
-#endif // GMX_MODULARSIMULATOR_SHELLFCELEMENT_H