SYCL: Avoid using no_init read accessor in rocFFT
[alexxy/gromacs.git] / src / gromacs / mdrun / membedholder.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 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 /*! \internal
36  * \brief Encapsulates membed methods
37  *
38  * \author Joe Jordan <ejjordan@kth.se>
39  * \ingroup module_mdrun
40  */
41 #ifndef GMX_MDRUN_MEMBEDHOLDER_H
42 #define GMX_MDRUN_MEMBEDHOLDER_H
43
44 #include <cstdio>
45
46 #include "gromacs/utility/real.h"
47
48 struct gmx_membed_t;
49 struct gmx_mtop_t;
50 struct t_commrec;
51 struct t_filenm;
52 struct t_inputrec;
53 class t_state;
54
55 namespace gmx
56 {
57
58 /*! \brief Membed SimulatorBuilder parameter type.
59  *
60  * Does not (yet) encapsulate ownership semantics of resources. Simulator is
61  * not (necessarily) granted ownership of resources. Client is responsible for
62  * maintaining the validity of resources for the life time of the Simulator,
63  * then for cleaning up those resources.
64  */
65 class MembedHolder
66 {
67 public:
68     //! Build holder from input information.
69     explicit MembedHolder(int nfile, const t_filenm fnm[]);
70     //! Move is possible.
71     MembedHolder(MembedHolder&& holder) noexcept;
72     //! Move assignment is possible.
73     MembedHolder& operator=(MembedHolder&& holder) noexcept;
74     //! Copy is not allowed.
75     MembedHolder(const MembedHolder&) = delete;
76     //! Copy assignment is not allowed.
77     MembedHolder& operator=(const MembedHolder&) = delete;
78
79     ~MembedHolder();
80
81     //! Get information about membed being used.
82     [[nodiscard]] bool doMembed() const { return doMembed_; }
83
84     /*! \brief
85      * Fully initialize underlying datastructure.
86      *
87      * \param[in] fplog Handle to log file.
88      * \param[in] nfile How many input files are there.
89      * \param[in] fnm   Input file collection datastructure.
90      * \param[in,out] mtop  Handle to mtop, can be modified.
91      * \param[in,out] inputrec Handle to inputrec, can be modified.
92      * \param[in,out] state    Simulation state information, can be modified.
93      * \param[in,out] cr       Communication information.
94      * \param[out]    cpt      Some kind of checkpoint information.
95      */
96     void initializeMembed(FILE*          fplog,
97                           int            nfile,
98                           const t_filenm fnm[],
99                           gmx_mtop_t*    mtop,
100                           t_inputrec*    inputrec,
101                           t_state*       state,
102                           t_commrec*     cr,
103                           real*          cpt);
104
105     //! Get handle to membed object.
106     gmx_membed_t* membed();
107
108 private:
109     //! Pointer to membed object. TODO replace with unique_ptr or get rid of this.
110     gmx_membed_t* membed_ = nullptr;
111     //! Whether membed is being used.
112     bool doMembed_ = false;
113 };
114
115 } // namespace gmx
116
117 #endif // GMX_MDRUN_MEMBEDHOLDER_H