Generalize IForceProvider
[gromacs.git] / src / gromacs / mdrunutility / mdmodules.h
blob663d76ffe77a43a4055c8f10af37cde09aa2e281
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2016,2017, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 /*! \libinternal \file
36 * \brief
37 * Declares gmx::MDModules.
39 * \author Teemu Murtola <teemu.murtola@gmail.com>
40 * \inlibraryapi
41 * \ingroup module_mdrunutility
43 #ifndef GMX_MDRUNUTILITY_MDMODULES_H
44 #define GMX_MDRUNUTILITY_MDMODULES_H
46 #include "gromacs/utility/classhelpers.h"
48 struct ForceProviders;
50 struct t_inputrec;
52 namespace gmx
55 class IKeyValueTreeErrorHandler;
56 class IKeyValueTreeTransformRules;
57 class IMDOutputProvider;
58 class KeyValueTreeObject;
60 /*! \libinternal \brief
61 * Manages the collection of all modules used for mdrun.
63 * This class acts as a central place for constructing modules for mdrun
64 * and wiring up dependencies between them. This class should be the only
65 * place that contains the full list of modules, although in the future, some
66 * code (e.g., in tools) may benefit from the ability to only create one or a
67 * few modules and use them.
69 * The general idea is that each module takes care of its own data rather than
70 * mdrun having to know about all the details of each type of force calculation.
71 * Initially this is applied for simple things like electric field calculations
72 * but later more complex forces will be supported too.
74 * Currently, where the set of modules needs to be accessed, either a pointer
75 * to MDModules is passed around, or an instance of IMDOutputProvider or
76 * ForceProviders returned from MDModules. These objects returned from
77 * MDModules call the corresponding methods in the relevant modules.
78 * In the future, some additional logic may need to be introduced at
79 * the call sites that can also influence the signature of the methods,
80 * similar to what ForceProviders already does for force computation.
82 * The assignOptionsToModules() and adjustInputrecBasedOnModules() methods of
83 * this class also take responsibility for wiring up the options (and their
84 * defaults) for each module.
86 * \inlibraryapi
87 * \ingroup module_mdrunutility
89 class MDModules
91 public:
92 MDModules();
93 ~MDModules();
95 /*! \brief
96 * Initializes a transform from mdp values to sectioned options.
98 * \see IMdpOptionProvider::initMdpTransform()
100 * Initializes the combined transform from all modules.
102 void initMdpTransform(IKeyValueTreeTransformRules *rules);
104 /*! \brief
105 * Sets input parameters from `params` for each module.
107 * \param[in] params Contains keys and values from user
108 * input (and defaults) to configure modules that have
109 * registered options with those keys.
110 * \param[out] errorHandler Called to report errors.
112 void assignOptionsToModules(const KeyValueTreeObject &params,
113 IKeyValueTreeErrorHandler *errorHandler);
115 /*! \brief
116 * Normalizes inputrec parameters to match current code version.
118 * This orders the parameters in `ir->param` to match the current code
119 * and adds any missing defaults.
121 void adjustInputrecBasedOnModules(t_inputrec *ir);
123 /*! \brief
124 * Returns an interface for initializing and finalizing output for modules.
126 IMDOutputProvider *outputProvider();
127 /*! \brief
128 * Returns an object for computing forces from the modules.
130 ForceProviders *initForceProviders();
132 private:
133 class Impl;
135 PrivateImplPointer<Impl> impl_;
138 } // namespace gmx
140 #endif