Improve tests of index block construction
[gromacs.git] / src / gromacs / mdlib / lincs_cuda.h
blob76014939bb88b3a7f31c37bf59666e4dd12353a9
1 /*
2 * This file is part of the GROMACS molecular simulation package.
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.
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
37 * \brief Declaration of high-level functions of CUDA implementation of LINCS.
39 * \todo This should only list interfaces needed for libgromacs clients.
41 * \author Artem Zhmurov <zhmurov@gmail.com>
43 * \ingroup module_mdlib
44 * \inlibraryapi
46 #ifndef GMX_MDLIB_LINCS_CUDA_H
47 #define GMX_MDLIB_LINCS_CUDA_H
50 #include "gromacs/mdlib/constr.h"
51 #include "gromacs/mdtypes/mdatom.h"
52 #include "gromacs/topology/idef.h"
53 #include "gromacs/utility/classhelpers.h"
55 namespace gmx
58 class LincsCuda
61 public:
62 /*! \brief Constructor.
64 * \param[in] numIterations Number of iteration for the correction of the projection.
65 * \param[in] expansionOrder Order of the matrix inversion algorithm.
67 LincsCuda(int numIterations,
68 int expansionOrder);
69 ~LincsCuda();
71 /*! \brief Apply LINCS to the coordinates/velocities stored in CPU memory.
73 * This method should not be used in any code-path, where performance is of any value.
74 * Only suitable for test and will be removed in future patch sets.
75 * Allocates GPU memory, copies data from CPU, applies LINCS to coordinates and,
76 * if requested, to velocities, copies the results back, frees GPU memory.
77 * Method uses this class data structures which should be filled with set() and setPbc()
78 * methods.
80 * \todo Remove this method
82 * \param[in] numAtoms Number of atoms
83 * \param[in] h_x Coordinates before timestep (in CPU memory)
84 * \param[in,out] h_xp Coordinates after timestep (in CPU memory). The
85 * resulting constrained coordinates will be saved here.
86 * \param[in] updateVelocities If the velocities should be updated.
87 * \param[in,out] h_v Velocities to update (in CPU memory, can be nullptr
88 * if not updated)
89 * \param[in] invdt Reciprocal timestep (to scale Lagrange
90 * multipliers when velocities are updated)
91 * \param[in] computeVirial If virial should be updated.
92 * \param[in,out] virialScaled Scaled virial tensor to be updated.
94 void copyApplyCopy(int numAtoms,
95 const rvec *h_x,
96 rvec *h_xp,
97 bool updateVelocities,
98 rvec *h_v,
99 real invdt,
100 bool computeVirial,
101 tensor virialScaled);
103 /*! \brief
104 * Update data-structures (e.g. after NB search step).
106 * Updates the constraints data. Should be called if the particles were sorted,
107 * redistributed between domains, etc.
109 * Information about constraints should be taken from:
110 * idef.il[F_CONSTR].iatoms --- type (T) of constraint and two atom indexes (i1, i2)
111 * idef.iparams[T].constr.dA --- target length for constraint of type T
112 * From t_mdatom, the code should take:
113 * md.invmass --- array of inverse square root of masses for each atom in the system.
115 * \param[in] idef Local topology data to get information on constraints from.
116 * \param[in] md Atoms data to get atom masses from.
118 void set(const t_idef &idef,
119 const t_mdatoms &md);
121 /*! \brief
122 * Update PBC data.
124 * \param[in] pbc The PBC data in t_pbc format.
126 void setPbc(const t_pbc *pbc);
128 /*! \brief Class with hardware-specific interfaces and implementations.*/
129 class Impl;
131 private:
132 gmx::PrivateImplPointer<Impl> impl_;
136 } // namespace gmx
138 #endif