Start making IMD and swap model IMDModule
authorMark Abraham <mark.j.abraham@gmail.com>
Sun, 31 Mar 2019 16:42:04 +0000 (18:42 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 10 Apr 2019 15:52:37 +0000 (17:52 +0200)
Moved MDModules to mdrun code module (to relieve cyclic dependency
that would otherwise result), because it is a very high level thing
that is intended to be aware of very many components.

Refs #2877

Change-Id: Ia7d1422bab887f768f8abed01edcbc4fb290dfeb

15 files changed:
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/gmxpreprocess/tests/readir.cpp
src/gromacs/imd/imd.cpp
src/gromacs/imd/imd.h
src/gromacs/mdrun/CMakeLists.txt
src/gromacs/mdrun/mdmodules.cpp [moved from src/gromacs/mdrunutility/mdmodules.cpp with 94% similarity]
src/gromacs/mdrun/mdmodules.h [moved from src/gromacs/mdrunutility/mdmodules.h with 97% similarity]
src/gromacs/mdrun/runner.cpp
src/gromacs/mdrun/runner.h
src/gromacs/mdrunutility/CMakeLists.txt
src/gromacs/swap/swapcoords.cpp
src/gromacs/swap/swapcoords.h
src/gromacs/tools/check.cpp
src/gromacs/tools/dump.cpp

index 9da76a8db29d4ac8b5c6b76a1d11bde0c4c8020e..5852c03a6a4563b5afbd1865fbf5c2f8324634e0 100644 (file)
@@ -81,7 +81,7 @@
 #include "gromacs/mdlib/perf_est.h"
 #include "gromacs/mdlib/qmmm.h"
 #include "gromacs/mdlib/vsite.h"
-#include "gromacs/mdrunutility/mdmodules.h"
+#include "gromacs/mdrun/mdmodules.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
 #include "gromacs/mdtypes/nblist.h"
index 75edec92243523d6e15321bc8005701146961788..c4ef18259bfade2768fa6d75b0b02b40986af817 100644 (file)
@@ -57,7 +57,7 @@
 #include "gromacs/math/units.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/mdlib/calc_verletbuf.h"
-#include "gromacs/mdrunutility/mdmodules.h"
+#include "gromacs/mdrun/mdmodules.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
 #include "gromacs/mdtypes/pull_params.h"
index 5bff568412ed685664777c3ebce2fb1e2b952a5a..634a08291ca47f4bc63b452d0f9d4070b1dadfa3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019, 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.
@@ -52,7 +52,7 @@
 #include <gtest/gtest.h>
 
 #include "gromacs/fileio/warninp.h"
-#include "gromacs/mdrunutility/mdmodules.h"
+#include "gromacs/mdrun/mdmodules.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/stringutil.h"
index a53e2c8e76ed49a18f0490aae5317b15dcdba035..5f0f8193363244899feea33cdaeb06bb85f89f8d 100644 (file)
@@ -69,6 +69,7 @@
 #include "gromacs/mdlib/sighandler.h"
 #include "gromacs/mdlib/stat.h"
 #include "gromacs/mdtypes/enerdata.h"
+#include "gromacs/mdtypes/imdmodule.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
 #include "gromacs/mdtypes/mdrunoptions.h"
@@ -97,7 +98,6 @@ constexpr int c_headerSize = 8;
 /*! \brief IMD Protocol Version. */
 constexpr int c_protocolVersion = 2;
 
-
 /*! \internal
  * \brief
  * IMD (interactive molecular dynamics) energy record.
@@ -315,6 +315,27 @@ class ImdSession::Impl
         gmx_enerdata_t  *enerd = nullptr;
 };
 
+/*! \internal
+ * \brief Implement interactive molecular dynamics.
+ *
+ * \todo Some aspects of this module provides forces (when the user
+ * pulls on things in VMD), so in future it should have a class that
+ * models IForceProvider and is contributed to the collection of such
+ * things.
+ */
+class InteractiveMolecularDynamics final : public IMDModule
+{
+    // From IMDModule
+    IMdpOptionProvider *mdpOptionProvider() override { return nullptr; }
+    IMDOutputProvider *outputProvider() override { return nullptr; }
+    void initForceProviders(ForceProviders * /* forceProviders */) override {}
+};
+
+std::unique_ptr<IMDModule> createInteractiveMolecularDynamicsModule()
+{
+    return std::make_unique<InteractiveMolecularDynamics>();
+}
+
 /*! \brief Enum for types of IMD messages.
  *
  * We use the same records as the NAMD/VMD IMD implementation.
index bd91747f4f284363b57db20cb6c35504a01a56eb..0336d77aea3d413f9e8206cbeea2a0306fa5cb86 100644 (file)
@@ -83,11 +83,18 @@ class t_state;
 
 namespace gmx
 {
+class IMDModule;
 class ImdSession;
+class InteractiveMolecularDynamics;
 class MDLogger;
 struct MdrunOptions;
 
-static const char IMDstr[] = "IMD:";  /**< Tag output from the IMD module with this string. */
+/*! \brief
+ * Creates a module for interactive molecular dynamics.
+ */
+std::unique_ptr<IMDModule> createInteractiveMolecularDynamicsModule();
+
+static const char IMDstr[] = "IMD:"; /**< Tag output from the IMD module with this string. */
 
 /*! \brief Writes out the group of atoms selected for interactive manipulation.
  *
index eea49236594d943aa6c087d27bd7703b132ca76b..e9073906d6439f9619507d39c1fb268fba692778 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2018, by the GROMACS development team, led by
+# Copyright (c) 2018,2019, 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.
@@ -37,6 +37,7 @@ gmx_add_libgromacs_sources(
     legacymdrunoptions.cpp
     logging.cpp
     md.cpp
+    mdmodules.cpp
     minimize.cpp
     multisim.cpp
     replicaexchange.cpp
similarity index 94%
rename from src/gromacs/mdrunutility/mdmodules.cpp
rename to src/gromacs/mdrun/mdmodules.cpp
index f0eab395c7372a0900c7acfb203589588dd9f920..ad2efe339afc9511f7cc3bac9e39925b0430c1eb 100644 (file)
@@ -39,6 +39,7 @@
 #include <memory>
 
 #include "gromacs/applied_forces/electricfield.h"
+#include "gromacs/imd/imd.h"
 #include "gromacs/mdtypes/iforceprovider.h"
 #include "gromacs/mdtypes/imdmodule.h"
 #include "gromacs/mdtypes/imdoutputprovider.h"
@@ -47,6 +48,7 @@
 #include "gromacs/options/options.h"
 #include "gromacs/options/optionsection.h"
 #include "gromacs/options/treesupport.h"
+#include "gromacs/swap/swapcoords.h"
 #include "gromacs/utility/keyvaluetree.h"
 #include "gromacs/utility/keyvaluetreebuilder.h"
 #include "gromacs/utility/keyvaluetreetransform.h"
@@ -60,7 +62,9 @@ class MDModules::Impl : public IMDOutputProvider
     public:
 
         Impl()
-            : field_(createElectricFieldModule())
+            : field_(createElectricFieldModule()),
+              imd_(createInteractiveMolecularDynamicsModule()),
+              swapCoordinates_(createSwapCoordinatesModule())
         {
         }
 
@@ -85,6 +89,8 @@ class MDModules::Impl : public IMDOutputProvider
 
         std::unique_ptr<IMDModule>      field_;
         std::unique_ptr<ForceProviders> forceProviders_;
+        std::unique_ptr<IMDModule>      imd_;
+        std::unique_ptr<IMDModule>      swapCoordinates_;
 
         /*! \brief List of registered MDModules
          *
similarity index 97%
rename from src/gromacs/mdrunutility/mdmodules.h
rename to src/gromacs/mdrun/mdmodules.h
index 2230a555c40820886649c3ff46d585914f5425c2..c069bbb4fa56cda37a46854a654fd32afd960099 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019, 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.
  *
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \inlibraryapi
- * \ingroup module_mdrunutility
+ * \ingroup module_mdrun
  */
-#ifndef GMX_MDRUNUTILITY_MDMODULES_H
-#define GMX_MDRUNUTILITY_MDMODULES_H
+#ifndef GMX_MDRUN_MDMODULES_H
+#define GMX_MDRUN_MDMODULES_H
 
 #include "gromacs/utility/classhelpers.h"
 
index de8ecc19ab1b69af5987d5b367fae30527967c80..0f8f8abb26629b11b1808e9cd4f0b756002985d8 100644 (file)
@@ -97,9 +97,9 @@
 #include "gromacs/mdlib/sighandler.h"
 #include "gromacs/mdlib/stophandler.h"
 #include "gromacs/mdrun/logging.h"
+#include "gromacs/mdrun/mdmodules.h"
 #include "gromacs/mdrun/multisim.h"
 #include "gromacs/mdrun/simulationcontext.h"
-#include "gromacs/mdrunutility/mdmodules.h"
 #include "gromacs/mdrunutility/printtime.h"
 #include "gromacs/mdrunutility/threadaffinity.h"
 #include "gromacs/mdtypes/commrec.h"
index f9f255012612c684d03f71f3843de45ccd1f5ebb..b2b309e77d90f01227ce23c88cfb725582d49ef6 100644 (file)
@@ -52,7 +52,7 @@
 #include "gromacs/domdec/options.h"
 #include "gromacs/hardware/hw_info.h"
 #include "gromacs/math/vec.h"
-#include "gromacs/mdrunutility/mdmodules.h"
+#include "gromacs/mdrun/mdmodules.h"
 #include "gromacs/mdtypes/mdrunoptions.h"
 #include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/real.h"
index 99252d32269db8adf7a6d40909ea9b4aa143e940..14dc4b0de9514268c68e6477362cb813fce96d8d 100644 (file)
@@ -34,7 +34,6 @@
 
 gmx_add_libgromacs_sources(
     handlerestart.cpp
-    mdmodules.cpp
     printtime.cpp
     threadaffinity.cpp
     )
index 68302f8b8f7db31c4d2b6e1678d110fbd3ebba59..a6f9f14f2e5976774d09d53c12b0210514cf67a8 100644 (file)
@@ -61,6 +61,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/mdlib/groupcoord.h"
 #include "gromacs/mdtypes/commrec.h"
+#include "gromacs/mdtypes/imdmodule.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
 #include "gromacs/mdtypes/mdrunoptions.h"
@@ -99,7 +100,27 @@ enum eDomain {
 };
 static const char* DomainString[eDomainNr] = { "not_assigned", "Domain_A", "Domain_B" }; /**< Name for the domains */
 
+namespace gmx
+{
+
+/*! \internal
+ * \brief Implement Computational Electrophysiology swapping.
+ */
+class SwapCoordinates final : public IMDModule
+{
+    // From IMDModule
+    IMdpOptionProvider *mdpOptionProvider() override { return nullptr; }
+    IMDOutputProvider *outputProvider() override { return nullptr; }
+    void initForceProviders(ForceProviders * /* forceProviders */) override {}
+};
+
+std::unique_ptr<IMDModule> createSwapCoordinatesModule()
+{
+    return std::make_unique<SwapCoordinates>();
+}
+
 
+} // namespace gmx
 
 /*! \internal \brief
  * Structure containing compartment-specific data.
index df3a9c614552c0baa8b2dc3210e2a1b707eece14..5b789284701e56d5aafca2994de3bb69850e4cd6 100644 (file)
@@ -54,6 +54,8 @@
 
 #include <cstdio>
 
+#include <memory>
+
 #include "gromacs/math/vectypes.h"
 #include "gromacs/utility/basedefinitions.h"
 
@@ -70,9 +72,16 @@ struct ObservablesHistory;
 
 namespace gmx
 {
+class IMDModule;
 class LocalAtomSetManager;
 struct MdrunOptions;
-}
+
+/*! \brief
+ * Creates a module for Computational Electrophysiology swapping.
+ */
+std::unique_ptr<IMDModule> createSwapCoordinatesModule();
+
+} // namespace gmx
 
 /*! \brief Initialize ion / water position swapping ("Computational Electrophysiology").
  *
index b4a410854b828d102897a73cd20b4f369e52c08c..33c39a4cfff2dce9880de518da1698afcf3745d2 100644 (file)
@@ -52,7 +52,7 @@
 #include "gromacs/math/functions.h"
 #include "gromacs/math/units.h"
 #include "gromacs/math/vec.h"
-#include "gromacs/mdrunutility/mdmodules.h"
+#include "gromacs/mdrun/mdmodules.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
 #include "gromacs/mdtypes/state.h"
index 4b648826cafb0c0950a57785ebe6b43f90b9871f..f999c4f125f30874dc960b11f29e107a6d7cb753 100644 (file)
@@ -62,7 +62,7 @@
 #include "gromacs/fileio/xtcio.h"
 #include "gromacs/gmxpreprocess/gmxcpp.h"
 #include "gromacs/math/vecdump.h"
-#include "gromacs/mdrunutility/mdmodules.h"
+#include "gromacs/mdrun/mdmodules.h"
 #include "gromacs/mdtypes/forcerec.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"