From 728ff0327a4e4c63ec7a9e9f002b678a08365b69 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Sun, 31 Mar 2019 18:42:04 +0200 Subject: [PATCH] Start making IMD and swap model IMDModule 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 --- src/gromacs/gmxpreprocess/grompp.cpp | 2 +- src/gromacs/gmxpreprocess/readir.cpp | 2 +- src/gromacs/gmxpreprocess/tests/readir.cpp | 4 ++-- src/gromacs/imd/imd.cpp | 23 ++++++++++++++++++- src/gromacs/imd/imd.h | 9 +++++++- src/gromacs/mdrun/CMakeLists.txt | 3 ++- .../{mdrunutility => mdrun}/mdmodules.cpp | 8 ++++++- .../{mdrunutility => mdrun}/mdmodules.h | 8 +++---- src/gromacs/mdrun/runner.cpp | 2 +- src/gromacs/mdrun/runner.h | 2 +- src/gromacs/mdrunutility/CMakeLists.txt | 1 - src/gromacs/swap/swapcoords.cpp | 21 +++++++++++++++++ src/gromacs/swap/swapcoords.h | 11 ++++++++- src/gromacs/tools/check.cpp | 2 +- src/gromacs/tools/dump.cpp | 2 +- 15 files changed, 82 insertions(+), 18 deletions(-) rename src/gromacs/{mdrunutility => mdrun}/mdmodules.cpp (94%) rename src/gromacs/{mdrunutility => mdrun}/mdmodules.h (97%) diff --git a/src/gromacs/gmxpreprocess/grompp.cpp b/src/gromacs/gmxpreprocess/grompp.cpp index 9da76a8db2..5852c03a6a 100644 --- a/src/gromacs/gmxpreprocess/grompp.cpp +++ b/src/gromacs/gmxpreprocess/grompp.cpp @@ -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" diff --git a/src/gromacs/gmxpreprocess/readir.cpp b/src/gromacs/gmxpreprocess/readir.cpp index 75edec9224..c4ef18259b 100644 --- a/src/gromacs/gmxpreprocess/readir.cpp +++ b/src/gromacs/gmxpreprocess/readir.cpp @@ -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" diff --git a/src/gromacs/gmxpreprocess/tests/readir.cpp b/src/gromacs/gmxpreprocess/tests/readir.cpp index 5bff568412..634a08291c 100644 --- a/src/gromacs/gmxpreprocess/tests/readir.cpp +++ b/src/gromacs/gmxpreprocess/tests/readir.cpp @@ -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 #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" diff --git a/src/gromacs/imd/imd.cpp b/src/gromacs/imd/imd.cpp index a53e2c8e76..5f0f819336 100644 --- a/src/gromacs/imd/imd.cpp +++ b/src/gromacs/imd/imd.cpp @@ -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 createInteractiveMolecularDynamicsModule() +{ + return std::make_unique(); +} + /*! \brief Enum for types of IMD messages. * * We use the same records as the NAMD/VMD IMD implementation. diff --git a/src/gromacs/imd/imd.h b/src/gromacs/imd/imd.h index bd91747f4f..0336d77aea 100644 --- a/src/gromacs/imd/imd.h +++ b/src/gromacs/imd/imd.h @@ -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 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. * diff --git a/src/gromacs/mdrun/CMakeLists.txt b/src/gromacs/mdrun/CMakeLists.txt index eea4923659..e9073906d6 100644 --- a/src/gromacs/mdrun/CMakeLists.txt +++ b/src/gromacs/mdrun/CMakeLists.txt @@ -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 diff --git a/src/gromacs/mdrunutility/mdmodules.cpp b/src/gromacs/mdrun/mdmodules.cpp similarity index 94% rename from src/gromacs/mdrunutility/mdmodules.cpp rename to src/gromacs/mdrun/mdmodules.cpp index f0eab395c7..ad2efe339a 100644 --- a/src/gromacs/mdrunutility/mdmodules.cpp +++ b/src/gromacs/mdrun/mdmodules.cpp @@ -39,6 +39,7 @@ #include #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 field_; std::unique_ptr forceProviders_; + std::unique_ptr imd_; + std::unique_ptr swapCoordinates_; /*! \brief List of registered MDModules * diff --git a/src/gromacs/mdrunutility/mdmodules.h b/src/gromacs/mdrun/mdmodules.h similarity index 97% rename from src/gromacs/mdrunutility/mdmodules.h rename to src/gromacs/mdrun/mdmodules.h index 2230a555c4..c069bbb4fa 100644 --- a/src/gromacs/mdrunutility/mdmodules.h +++ b/src/gromacs/mdrun/mdmodules.h @@ -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. @@ -38,10 +38,10 @@ * * \author Teemu Murtola * \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" diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index de8ecc19ab..0f8f8abb26 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -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" diff --git a/src/gromacs/mdrun/runner.h b/src/gromacs/mdrun/runner.h index f9f2550126..b2b309e77d 100644 --- a/src/gromacs/mdrun/runner.h +++ b/src/gromacs/mdrun/runner.h @@ -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" diff --git a/src/gromacs/mdrunutility/CMakeLists.txt b/src/gromacs/mdrunutility/CMakeLists.txt index 99252d3226..14dc4b0de9 100644 --- a/src/gromacs/mdrunutility/CMakeLists.txt +++ b/src/gromacs/mdrunutility/CMakeLists.txt @@ -34,7 +34,6 @@ gmx_add_libgromacs_sources( handlerestart.cpp - mdmodules.cpp printtime.cpp threadaffinity.cpp ) diff --git a/src/gromacs/swap/swapcoords.cpp b/src/gromacs/swap/swapcoords.cpp index 68302f8b8f..a6f9f14f2e 100644 --- a/src/gromacs/swap/swapcoords.cpp +++ b/src/gromacs/swap/swapcoords.cpp @@ -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 createSwapCoordinatesModule() +{ + return std::make_unique(); +} + +} // namespace gmx /*! \internal \brief * Structure containing compartment-specific data. diff --git a/src/gromacs/swap/swapcoords.h b/src/gromacs/swap/swapcoords.h index df3a9c6145..5b78928470 100644 --- a/src/gromacs/swap/swapcoords.h +++ b/src/gromacs/swap/swapcoords.h @@ -54,6 +54,8 @@ #include +#include + #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 createSwapCoordinatesModule(); + +} // namespace gmx /*! \brief Initialize ion / water position swapping ("Computational Electrophysiology"). * diff --git a/src/gromacs/tools/check.cpp b/src/gromacs/tools/check.cpp index b4a410854b..33c39a4cff 100644 --- a/src/gromacs/tools/check.cpp +++ b/src/gromacs/tools/check.cpp @@ -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" diff --git a/src/gromacs/tools/dump.cpp b/src/gromacs/tools/dump.cpp index 4b648826ca..f999c4f125 100644 --- a/src/gromacs/tools/dump.cpp +++ b/src/gromacs/tools/dump.cpp @@ -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" -- 2.22.0