Introduce frequency for CompositeSimulatorElement
authorPascal Merz <pascal.merz@me.com>
Mon, 7 Sep 2020 16:28:37 +0000 (10:28 -0600)
committerArtem Zhmurov <zhmurov@gmail.com>
Fri, 21 May 2021 10:49:25 +0000 (10:49 +0000)
This adds functionality to run a composite simulator element at a
prescribed frequency. This prepares the introduction of Andersen
thermostatting.

src/gromacs/modularsimulator/compositesimulatorelement.cpp
src/gromacs/modularsimulator/compositesimulatorelement.h

index 369c1bde3ae4b05562ce6f9a3583ed7947a09399..37a8359f3b5026b7102ed2645cc515b762309303 100644 (file)
 
 #include "gmxpre.h"
 
+#include "gromacs/mdlib/stat.h"
+
 #include "compositesimulatorelement.h"
 
 namespace gmx
 {
 CompositeSimulatorElement::CompositeSimulatorElement(
         std::vector<compat::not_null<ISimulatorElement*>>    elementCallList,
-        std::vector<std::unique_ptr<gmx::ISimulatorElement>> elements) :
-    elementCallList_(std::move(elementCallList)), elementOwnershipList_(std::move(elements))
+        std::vector<std::unique_ptr<gmx::ISimulatorElement>> elements,
+        int                                                  frequency) :
+    elementCallList_(std::move(elementCallList)),
+    elementOwnershipList_(std::move(elements)),
+    frequency_(frequency)
 {
 }
 
 void CompositeSimulatorElement::scheduleTask(Step step, Time time, const RegisterRunFunction& registerRunFunction)
 {
-    for (auto& element : elementCallList_)
+    if (do_per_step(step, frequency_))
     {
-        element->scheduleTask(step, time, registerRunFunction);
+        for (auto& element : elementCallList_)
+        {
+            element->scheduleTask(step, time, registerRunFunction);
+        }
     }
 }
 
index cf730626ccb56d155b2f149a31c6b40733d7fa14..c238974da194069537509af299052af1a195ed1a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -75,7 +75,8 @@ class CompositeSimulatorElement final : public ISimulatorElement
 public:
     //! Constructor
     explicit CompositeSimulatorElement(std::vector<compat::not_null<ISimulatorElement*>> elementCallList,
-                                       std::vector<std::unique_ptr<ISimulatorElement>> elements);
+                                       std::vector<std::unique_ptr<ISimulatorElement>> elements,
+                                       int                                             frequency);
 
     /*! \brief Register run function for step / time
      *
@@ -105,6 +106,8 @@ private:
     std::vector<compat::not_null<ISimulatorElement*>> elementCallList_;
     //! List of elements owned by composite element
     std::vector<std::unique_ptr<ISimulatorElement>> elementOwnershipList_;
+    //! The frequency at which the composite element is running
+    const int frequency_;
 };
 
 } // namespace gmx