2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2010,2014,2015,2016,2017 by the GROMACS development team.
7 * Copyright (c) 2018,2019,2020, 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.
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.
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.
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.
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.
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.
38 #ifndef GMX_MDLIB_MDATOMS_H
39 #define GMX_MDLIB_MDATOMS_H
46 #include "gromacs/gpu_utils/hostallocator.h"
47 #include "gromacs/utility/basedefinitions.h"
48 #include "gromacs/utility/real.h"
49 #include "gromacs/utility/unique_cptr.h"
59 * \brief Contains a C-style t_mdatoms while managing some of its
60 * memory with C++ vectors with allocators.
62 * \todo The group-scheme kernels needed a plain C-style t_mdatoms, so
63 * this type combines that with the memory management needed for
64 * efficient PME on GPU transfers. The mdatoms_ member should be
68 //! C-style mdatoms struct.
69 unique_cptr
<t_mdatoms
> mdatoms_
;
70 //! Memory for chargeA that can be set up for efficient GPU transfer.
71 gmx::PaddedHostVector
<real
> chargeA_
;
72 //! Memory for chargeB that can be set up for efficient GPU transfer.
73 gmx::PaddedHostVector
<real
> chargeB_
;
76 // TODO make this private
80 t_mdatoms
* mdatoms() { return mdatoms_
.get(); }
82 const t_mdatoms
* mdatoms() const { return mdatoms_
.get(); }
83 /*! \brief Resizes memory for charges of FEP state A.
85 * \throws std::bad_alloc If out of memory.
87 void resizeChargeA(int newSize
);
88 /*! \brief Resizes memory for charges of FEP state B.
90 * \throws std::bad_alloc If out of memory.
92 void resizeChargeB(int newSize
);
93 /*! \brief Reserves memory for charges of FEP state A.
95 * \throws std::bad_alloc If out of memory.
97 void reserveChargeA(int newCapacity
);
98 /*! \brief Reserves memory for charges of FEP state B.
100 * \throws std::bad_alloc If out of memory.
102 void reserveChargeB(int newCapacity
);
103 //! Builder function.
104 friend std::unique_ptr
<MDAtoms
>
105 makeMDAtoms(FILE* fp
, const gmx_mtop_t
& mtop
, const t_inputrec
& ir
, bool rankHasPmeGpuTask
);
108 //! Builder function for MdAtomsWrapper.
109 std::unique_ptr
<MDAtoms
> makeMDAtoms(FILE* fp
, const gmx_mtop_t
& mtop
, const t_inputrec
& ir
, bool useGpuForPme
);
113 void atoms2md(const gmx_mtop_t
* mtop
,
114 const t_inputrec
* ir
,
116 gmx::ArrayRef
<int> index
,
118 gmx::MDAtoms
* mdAtoms
);
119 /* This routine copies the atoms->atom struct into md.
120 * If index!=NULL only the indexed atoms are copied.
121 * For the masses the A-state (lambda=0) mass is used.
122 * Sets md->lambda = 0.
123 * In free-energy runs, update_mdatoms() should be called after atoms2md()
124 * to set the masses corresponding to the value of lambda at each step.
127 void update_mdatoms(t_mdatoms
* md
, real lambda
);
128 /* When necessary, sets all the mass parameters to values corresponding
129 * to the free-energy parameter lambda.
130 * Sets md->lambda = lambda.