Fixes for clang-tidy-9
[alexxy/gromacs.git] / src / gromacs / mimic / communicator.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2018,2019,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.
8  *
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.
13  *
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.
18  *
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.
23  *
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.
31  *
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.
34  */
35
36 #ifndef GMX_MIMIC_COMMUNICATOR_H
37 #define GMX_MIMIC_COMMUNICATOR_H
38
39 #include "gromacs/gpu_utils/hostallocator.h"
40 #include "gromacs/math/paddedvector.h"
41 #include "gromacs/mdlib/constr.h"
42 #include "gromacs/topology/topology.h"
43 #include "gromacs/utility/futil.h"
44
45 namespace gmx
46 {
47 /**
48  * \inlibraryapi
49  * \internal \brief
50  * Class-wrapper around MiMiC communication library
51  * It uses GROMACS' unit conversion to switch from GROMACS' units to a.u.
52  *
53  * \author Viacheslav Bolnykh <v.bolnykh@hpc-leap.eu>
54  * \ingroup module_mimic
55  */
56 class MimicCommunicator
57 {
58
59 public:
60     /*! \brief
61      * Initializes the communicator
62      */
63     static void init();
64
65     /*! \brief
66      * Sends the data needed for MiMiC initialization
67      *
68      * That includes number of atoms, element numbers, charges, masses,
69      * maximal order of multipoles (0 for point-charge forcefields),
70      * number of molecules, number of atoms per each molecule,
71      * bond constraints data
72      *
73      * @param mtop global topology data
74      * @param coords coordinates of all atoms
75      */
76     static void sendInitData(gmx_mtop_t* mtop, PaddedHostVector<gmx::RVec> coords);
77
78     /*! \brief
79      * Gets the number of MD steps to perform from MiMiC
80      *
81      * @return nsteps the number of MD steps to perform
82      */
83     static int64_t getStepNumber();
84
85     /*! \brief
86      * Receive and array of updated atomic coordinates from MiMiC
87      *
88      * @param x array of coordinates to fill
89      * @param natoms number of atoms in the system
90      */
91     static void getCoords(PaddedHostVector<RVec>* x, int natoms);
92
93     /*! \brief
94      * Send the potential energy value to MiMiC
95      *
96      * @param energy energy value to send
97      */
98     static void sendEnergies(real energy);
99
100     /*! \brief
101      * Send classical forces acting on all atoms in the system
102      * to MiMiC.
103      *
104      * @param forces array of forces to send
105      * @param natoms number of atoms in the system
106      */
107     static void sendForces(ArrayRef<gmx::RVec> forces, int natoms);
108
109     /*! \brief
110      * Finish communications and disconnect from the server
111      */
112     static void finalize();
113 };
114
115 } // namespace gmx
116
117 #endif // GMX_MIMIC_COMMUNICATOR_H