StatePropagatorDataGpu object to manage GPU forces, positions and velocities buffers
[alexxy/gromacs.git] / src / gromacs / mdlib / update_constrain_cuda.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2019, 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 /*! \libinternal \file
36  *
37  * \brief Declaration of high-level functions of CUDA implementation of update and constrain class.
38  *
39  * \todo This should only list interfaces needed for libgromacs clients (e.g.
40  *       management of coordinates, velocities and forces should not be here).
41  * \todo Change "cuda" suffix to "gpu"
42  *
43  * \author Artem Zhmurov <zhmurov@gmail.com>
44  *
45  * \ingroup module_mdlib
46  * \inlibraryapi
47  */
48 #ifndef GMX_MDLIB_UPDATE_CONSTRAIN_CUDA_H
49 #define GMX_MDLIB_UPDATE_CONSTRAIN_CUDA_H
50
51 #include "gromacs/gpu_utils/devicebuffer_datatype.h"
52 #include "gromacs/mdtypes/group.h"
53 #include "gromacs/utility/arrayref.h"
54 #include "gromacs/utility/classhelpers.h"
55
56 struct gmx_mtop_t;
57 struct t_idef;
58 struct t_inputrec;
59 struct t_mdatoms;
60 struct t_pbc;
61
62 namespace gmx
63 {
64
65 class UpdateConstrainCuda
66 {
67
68     public:
69         /*! \brief Create Update-Constrain object.
70          *
71          * \param[in] ir             Input record data: LINCS takes number of iterations and order of
72          *                           projection from it.
73          * \param[in] mtop           Topology of the system: SETTLE gets the masses for O and H atoms
74          *                           and target O-H and H-H distances from this object.
75          * \param[in] commandStream  GPU stream to use. Can be nullptr.
76          */
77         UpdateConstrainCuda(const t_inputrec  &ir,
78                             const gmx_mtop_t  &mtop,
79                             const void        *commandStream);
80
81         ~UpdateConstrainCuda();
82
83         /*! \brief Integrate
84          *
85          * This will extract temperature scaling factors from tcstat, transform them into the plain
86          * array and call the normal integrate method.
87          *
88          * \param[in]  dt                     Timestep.
89          * \param[in]  updateVelocities       If the velocities should be constrained.
90          * \param[in]  computeVirial          If virial should be updated.
91          * \param[out] virial                 Place to save virial tensor.
92          * \param[in]  doTempCouple           If the temperature coupling should be performed.
93          * \param[in]  tcstat                 Temperature coupling data.
94          * \param[in]  doPressureCouple       If the temperature coupling should be applied.
95          * \param[in]  dtPressureCouple       Period between pressure coupling steps
96          * \param[in]  velocityScalingMatrix  Parrinello-Rahman velocity scaling matrix
97          */
98         void integrate(real                              dt,
99                        bool                              updateVelocities,
100                        bool                              computeVirial,
101                        tensor                            virial,
102                        bool                              doTempCouple,
103                        gmx::ArrayRef<const t_grp_tcstat> tcstat,
104                        bool                              doPressureCouple,
105                        float                             dtPressureCouple,
106                        const matrix                      velocityScalingMatrix);
107
108         /*! \brief Set the pointers and update data-structures (e.g. after NB search step).
109          *
110          * \param[in,out]  d_x                 Device buffer with coordinates.
111          * \param[in,out]  d_v                 Device buffer with velocities.
112          * \param[in]      d_f                 Device buffer with forces.
113          * \param[in]      idef                System topology
114          * \param[in]      md                  Atoms data.
115          * \param[in]      numTempScaleValues  Number of temperature scaling groups. Zero for no temperature scaling.
116          */
117         void set(DeviceBuffer<float>  d_x,
118                  DeviceBuffer<float>  d_v,
119                  DeviceBuffer<float>  d_f,
120                  const t_idef        &idef,
121                  const t_mdatoms     &md,
122                  int                  numTempScaleValues);
123
124         /*! \brief
125          * Update PBC data.
126          *
127          * Converts PBC data from t_pbc into the PbcAiuc format and stores the latter.
128          *
129          * \param[in] pbc The PBC data in t_pbc format.
130          */
131         void setPbc(const t_pbc *pbc);
132
133
134     private:
135         class Impl;
136         gmx::PrivateImplPointer<Impl> impl_;
137
138 };
139
140 } //namespace gmx
141
142 #endif