2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2020, 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 Utilities for interacting with SimulationInput.
38 * \author M. Eric Irrgang <ericirrgang@gmail.com>
39 * \ingroup module_mdrun
42 #ifndef GMX_MDRUN_SIMULATIONINPUTUTILITY_H
43 #define GMX_MDRUN_SIMULATIONINPUTUTILITY_H
47 #include "gromacs/mdtypes/checkpointdata.h"
48 #include "gromacs/utility/mdmodulenotification.h"
50 #include "simulationinput.h"
52 // Forward declarations for types from other modules that are opaque to the public API.
53 // TODO: Document the sources of these symbols or import a (self-documenting) fwd header.
59 struct ObservablesHistory;
60 struct PartialDeserializedTprFile;
65 /*! \brief Get the global simulation input.
67 * Acquire global simulation data structures from the SimulationInput handle.
68 * Note that global data is returned in the calling thread. In parallel
69 * computing contexts, the client is responsible for calling only where needed.
74 * // Only the master rank has the global state
75 * globalState = globalSimulationState(simulationInput);
77 * // Read (nearly) all data required for the simulation
78 * applyGlobalInputRecord(simulationInput, inputrec);
79 * applyGlobalTopology(simulationInput, &mtop);
82 * \todo Factor the logic for global/local and master-rank-checks.
83 * The SimulationInput utilities should behave properly for the various distributed data scenarios.
84 * Consider supplying data directly to the consumers rather than exposing the
85 * implementation details of the legacy aggregate types.
89 // TODO: Remove this monolithic detail as member data can be separately cached and managed. (#3374)
90 // Note that clients still need tpxio.h for PartialDeserializedTprFile.
91 void applyGlobalSimulationState(const SimulationInput& simulationInput,
92 PartialDeserializedTprFile* partialDeserializedTpr,
95 gmx_mtop_t* globalTopology);
96 // TODO: Implement the following, pending further discussion re #3374.
97 std::unique_ptr<t_state> globalSimulationState(const SimulationInput&);
98 void applyGlobalInputRecord(const SimulationInput&, t_inputrec*);
99 void applyGlobalTopology(const SimulationInput&, gmx_mtop_t*);
102 /*! \brief Initialize local stateful simulation data.
104 * Establish an invariant for the simulator at a trajectory point.
105 * Call on all ranks (after domain decomposition and task assignments).
107 * After this call, the simulator has all of the information it will
108 * receive in order to advance a trajectory from the current step.
109 * Checkpoint information has been applied, if applicable, and stateful
110 * data has been (re)initialized.
112 * \warning Mdrunner instances do not clearly distinguish between global and local
113 * versions of t_state.
115 * \todo Factor the distributed data aspects of simulation input data into the
116 * SimulationInput implementation.
118 * \todo Consider refactoring to decouple the checkpoint facility from its consumers
119 * (state, observablesHistory, mdModulesNotifier, and parts of ir).
121 * \warning It is the caller’s responsibility to make sure that
122 * preconditions are satisfied for the parameter objects.
124 * \see globalSimulationState()
125 * \see applyGlobalInputRecord()
126 * \see applyGlobalTopology()
128 void applyLocalState(const SimulationInput& simulationInput,
134 ObservablesHistory* observablesHistory,
135 bool reproducibilityRequested,
136 const MdModulesNotifier& notifier,
137 gmx::ReadCheckpointDataHolder* modularSimulatorCheckpointData,
138 bool useModularSimulator);
140 } // end namespace gmx
142 #endif // GMX_MDRUN_SIMULATIONINPUTUTILITY_H