SYCL: Avoid using no_init read accessor in rocFFT
[alexxy/gromacs.git] / src / gromacs / essentialdynamics / edsam.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team.
6  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
7  * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
8  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
9  * and including many others, as listed in the AUTHORS file in the
10  * top-level source directory and at http://www.gromacs.org.
11  *
12  * GROMACS is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 2.1
15  * of the License, or (at your option) any later version.
16  *
17  * GROMACS is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with GROMACS; if not, see
24  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
26  *
27  * If you want to redistribute modifications to GROMACS, please
28  * consider that scientific software is very special. Version
29  * control is crucial - bugs must be traceable. We will be happy to
30  * consider code for inclusion in the official distribution, but
31  * derived work must not be called official GROMACS. Details are found
32  * in the README & COPYING files - if they are missing, get the
33  * official version at http://www.gromacs.org.
34  *
35  * To help us fund GROMACS development, we humbly ask that you cite
36  * the research papers on the package. Check out http://www.gromacs.org.
37  */
38 /*! \libinternal \file
39  *
40  * \brief
41  * Declares functions to calculate both essential dynamics constraints
42  * as well as flooding potentials and forces.
43  *
44  * \authors Bert de Groot <bgroot@gwdg.de>, Oliver Lange <oliver.lange@tum.de>,
45  * Carsten Kutzner <ckutzne@gwdg.de>
46  *
47  * \inlibraryapi
48  */
49 #ifndef GMX_ESSENTIALDYNAMICS_EDSAM_H
50 #define GMX_ESSENTIALDYNAMICS_EDSAM_H
51
52 #include <memory>
53
54 #include "gromacs/math/vectypes.h"
55
56 /*! \brief Abstract type for essential dynamics
57  *
58  * The main type is defined only in edsam.cpp
59  */
60 struct gmx_edsam;
61 struct gmx_domdec_t;
62 struct gmx_mtop_t;
63 struct gmx_output_env_t;
64 struct ObservablesHistory;
65 struct t_commrec;
66 struct t_filenm;
67 struct t_inputrec;
68 class t_state;
69
70 namespace gmx
71 {
72 enum class StartingBehavior;
73 class Constraints;
74 template<typename>
75 class ArrayRef;
76
77 class EssentialDynamics
78 {
79 public:
80     EssentialDynamics();
81     ~EssentialDynamics();
82
83     /*! \brief Getter for working data
84      *
85      * This is needed while the module is still under
86      * construction. */
87     gmx_edsam* getLegacyED();
88
89 private:
90     class Impl;
91
92     std::unique_ptr<Impl> impl_;
93 };
94 class MDLogger;
95 } // namespace gmx
96
97 /*! \brief Applies essential dynamics constrains as defined in the .edi input file.
98  *
99  * \param ir                MD input parameter record.
100  * \param step              Number of the time step.
101  * \param cr                Data needed for MPI communication.
102  * \param coords            The local positions on this processor.
103  * \param velocities        The local velocities.
104  * \param box               The simulation box.
105  * \param ed                The essential dynamics data.
106  */
107 void do_edsam(const t_inputrec*        ir,
108               int64_t                  step,
109               const t_commrec*         cr,
110               gmx::ArrayRef<gmx::RVec> coords,
111               gmx::ArrayRef<gmx::RVec> velocities,
112               const matrix             box,
113               gmx_edsam*               ed);
114
115
116 /*! \brief Initializes the essential dynamics and flooding module.
117  *
118  * \param mdlog             Logger.
119  * \param ediFileName       Essential dynamics input file.
120  * \param edoFileName       Output file for essential dynamics data.
121  * \param mtop              Molecular topology.
122  * \param ir                MD input parameter record.
123  * \param cr                Data needed for MPI communication.
124  * \param constr            Data structure keeping the constraint information.
125  * \param globalState       The global state, only used on the master rank.
126  * \param oh                The observables history container.
127  * \param oenv              The output environment information.
128  * \param startingBehavior  Describes whether this is a restart appending to output files
129  *
130  * \returns                 A pointer to the ED data structure.
131  */
132 std::unique_ptr<gmx::EssentialDynamics> init_edsam(const gmx::MDLogger&    mdlog,
133                                                    const char*             ediFileName,
134                                                    const char*             edoFileName,
135                                                    const gmx_mtop_t&       mtop,
136                                                    const t_inputrec&       ir,
137                                                    const t_commrec*        cr,
138                                                    gmx::Constraints*       constr,
139                                                    const t_state*          globalState,
140                                                    ObservablesHistory*     oh,
141                                                    const gmx_output_env_t* oenv,
142                                                    gmx::StartingBehavior   startingBehavior);
143
144 /*! \brief Make a selection of the home atoms for the ED groups.
145  *
146  * Should be called at every domain decomposition.
147  *
148  * \param dd                Domain decomposition data.
149  * \param ed                Essential dynamics and flooding data.
150  */
151 void dd_make_local_ed_indices(gmx_domdec_t* dd, gmx_edsam* ed);
152
153
154 /*! \brief Evaluate the flooding potential(s) and forces as requested in the .edi input file.
155  *
156  * \param cr                Data needed for MPI communication.
157  * \param ir                MD input parameter record.
158  * \param coords            Positions on the local processor.
159  * \param force             Forcefield forces to which the flooding forces are added.
160  * \param ed                The essential dynamics data.
161  * \param box               The simulation box.
162  * \param step              Number of the time step.
163  * \param bNS               Are we in a neighbor searching step?
164  */
165 void do_flood(const t_commrec*               cr,
166               const t_inputrec&              ir,
167               gmx::ArrayRef<const gmx::RVec> coords,
168               gmx::ArrayRef<gmx::RVec>       force,
169               gmx_edsam*                     ed,
170               const matrix                   box,
171               int64_t                        step,
172               bool                           bNS);
173
174 #endif