Gromacs
2022.2
|
#include <gromacs/mdrun/mdmodules.h>
Manages the collection of all modules used for mdrun.
This class acts as a central place for constructing modules for mdrun and wiring up dependencies between them. This class should be the only place that contains the full list of modules, although in the future, some code (e.g., in tools) may benefit from the ability to only create one or a few modules and use them.
The general idea is that each module takes care of its own data rather than mdrun having to know about all the details of each type of force calculation. Initially this is applied for simple things like electric field calculations but later more complex forces will be supported too.
Currently, where the set of modules needs to be accessed, either a pointer to MDModules is passed around, or an instance of IMDOutputProvider or ForceProviders returned from MDModules. These objects returned from MDModules call the corresponding methods in the relevant modules. In the future, some additional logic may need to be introduced at the call sites that can also influence the signature of the methods, similar to what ForceProviders already does for force computation.
The assignOptionsToModules() and adjustInputrecBasedOnModules() methods of this class also take responsibility for wiring up the options (and their defaults) for each module.
Public Member Functions | |
void | initMdpTransform (IKeyValueTreeTransformRules *rules) |
Initializes a transform from mdp values to sectioned options. More... | |
void | buildMdpOutput (KeyValueTreeObjectBuilder *builder) |
Initializes a builder of flat mdp-style key-value pairs suitable for output. More... | |
void | assignOptionsToModules (const KeyValueTreeObject ¶ms, IKeyValueTreeErrorHandler *errorHandler) |
Sets input parameters from params for each module. More... | |
void | adjustInputrecBasedOnModules (t_inputrec *ir) |
Normalizes inputrec parameters to match current code version. More... | |
IMDOutputProvider * | outputProvider () |
Returns an interface for initializing and finalizing output for modules. | |
ForceProviders * | initForceProviders () |
Returns an object for computing forces from the modules. | |
void | subscribeToSimulationSetupNotifications () |
Subscribe MDModules to simulation setup notifications. More... | |
void | subscribeToPreProcessingNotifications () |
Subscribe MDModules to notifications during pre-processing. More... | |
void | add (std::shared_ptr< IMDModule > module) |
Add a module to the container. More... | |
const MDModulesNotifiers & | notifiers () |
Return a handle to the notifiers used for callbacks between modules. | |
void gmx::MDModules::add | ( | std::shared_ptr< IMDModule > | module | ) |
Add a module to the container.
An object may be added by a client to the bound MD Modules at run time. Both the client and the MDModules object may need to extend the life of the provided object. However, the MDModules container guarantees to extend the life of a provided object for as long as its consumers may attempt to use its the interfaces accessible through IMDModule methods.
module | implements some sort of modular functionality for MD. |
Adding a module at an arbitrary point in the MDModules life breaks some assumptions in the protocol of the other member functions. If MDModules should not change after some point, we should move this to a builder class.
void gmx::MDModules::adjustInputrecBasedOnModules | ( | t_inputrec * | ir | ) |
Normalizes inputrec parameters to match current code version.
This orders the parameters in ir->param
to match the current code and adds any missing defaults. It also throws an error if the inputrec contains parameters that are not recognized by any module.
void gmx::MDModules::assignOptionsToModules | ( | const KeyValueTreeObject & | params, |
IKeyValueTreeErrorHandler * | errorHandler | ||
) |
Sets input parameters from params
for each module.
[in] | params | Contains keys and values from user input (and defaults) to configure modules that have registered options with those keys. |
[out] | errorHandler | Called to report errors. |
void gmx::MDModules::buildMdpOutput | ( | KeyValueTreeObjectBuilder * | builder | ) |
Initializes a builder of flat mdp-style key-value pairs suitable for output.
If used as input to initMdpTransform(), the key-value pairs resulting from this function would leave the module settings unchanged.
Once the transition from mdp to key-value input is complete, this method will probably not exist.
void gmx::MDModules::initMdpTransform | ( | IKeyValueTreeTransformRules * | rules | ) |
Initializes a transform from mdp values to sectioned options.
Initializes the combined transform from all modules.
void gmx::MDModules::subscribeToPreProcessingNotifications | ( | ) |
void gmx::MDModules::subscribeToSimulationSetupNotifications | ( | ) |