Document and clean up do_numbering()
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / readir.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team.
6  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
7  * Copyright (c) 2018,2019,2020,2021, 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.
11  *
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.
16  *
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.
21  *
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.
26  *
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.
34  *
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.
37  */
38
39 #ifndef GMX_GMXPREPROCESS_READIR_H
40 #define GMX_GMXPREPROCESS_READIR_H
41
42 #include <string>
43
44 #include "gromacs/fileio/readinp.h"
45 #include "gromacs/math/vectypes.h"
46 #include "gromacs/mdtypes/multipletimestepping.h"
47 #include "gromacs/utility/arrayref.h"
48 #include "gromacs/utility/real.h"
49
50 namespace gmx
51 {
52 class MDModules;
53 struct MDModulesNotifiers;
54 } // namespace gmx
55
56 struct gmx_mtop_t;
57 struct gmx_output_env_t;
58 struct pull_params_t;
59 struct pull_t;
60 struct t_blocka;
61 struct t_grpopts;
62 struct t_inpfile;
63 struct t_inputrec;
64 struct t_pull_group;
65 struct t_pull_coord;
66 struct t_rot;
67 struct warninp;
68 typedef warninp* warninp_t;
69
70 enum
71 {
72     eshNONE,
73     eshHBONDS,
74     eshALLBONDS,
75     eshHANGLES,
76     eshALLANGLES,
77     eshNR
78 };
79
80 enum
81 {
82     ecouplamVDWQ,
83     ecouplamVDW,
84     ecouplamQ,
85     ecouplamNONE,
86     ecouplamNR
87 };
88
89 struct t_gromppopts
90 {
91     int                warnings  = 0;
92     int                nshake    = 0;
93     char*              include   = nullptr;
94     char*              define    = nullptr;
95     bool               bGenVel   = false;
96     bool               bGenPairs = false;
97     real               tempi     = 0;
98     int                seed      = 0;
99     gmx::GromppMtsOpts mtsOpts;
100     bool               bOrire           = false;
101     bool               bMorse           = false;
102     char*              wall_atomtype[2] = { nullptr, nullptr };
103     char*              couple_moltype   = nullptr;
104     int                couple_lam0      = 0;
105     int                couple_lam1      = 0;
106     bool               bCoupleIntra     = false;
107 };
108
109 /*! \brief Initialise object to hold strings parsed from an .mdp file */
110 void init_inputrec_strings();
111
112 /*! \brief Clean up object that holds strings parsed from an .mdp file */
113 void done_inputrec_strings();
114
115 /*! \brief Performs all validation on \p ir that can be done without index groups and topology
116  *
117  * Any errors, warnings or notes are added to \p wi
118  */
119 void check_ir(const char*                    mdparin,
120               const gmx::MDModulesNotifiers& mdModulesNotifiers,
121               t_inputrec*                    ir,
122               t_gromppopts*                  opts,
123               warninp_t                      wi);
124
125 //! Returns the index of string \p s in \p gn or exit with a verbose fatal error when not found
126 int search_string(const char* s, int ng, char* const gn[]);
127
128 void double_check(t_inputrec* ir, matrix box, bool bHasNormalConstraints, bool bHasAnyConstraints, warninp_t wi);
129 /* Do more checks */
130
131 void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_t wi);
132 /* Do even more checks */
133
134 void get_ir(const char*     mdparin,
135             const char*     mdparout,
136             gmx::MDModules* mdModules,
137             t_inputrec*     ir,
138             t_gromppopts*   opts,
139             WriteMdpHeader  writeMdpHeader,
140             warninp_t       wi);
141 /* Read the input file, and retrieve data for inputrec.
142  * More data are read, but the are only evaluated when the next
143  * function is called. Also prints the input file back to mdparout.
144  */
145
146 void do_index(const char*                    mdparin,
147               const char*                    ndx,
148               gmx_mtop_t*                    mtop,
149               bool                           bVerbose,
150               const gmx::MDModulesNotifiers& mdModulesNotifiers,
151               t_inputrec*                    ir,
152               warninp_t                      wi);
153 /* Read the index file and assign grp numbers to atoms.
154  */
155
156 /* Routines In readpull.c */
157
158 std::vector<std::string> read_pullparams(std::vector<t_inpfile>* inp, pull_params_t* pull, warninp_t wi);
159 /* Reads the pull parameters, returns a list of the pull group names */
160 void process_pull_groups(gmx::ArrayRef<t_pull_group>      pullGroups,
161                          gmx::ArrayRef<const std::string> pullGroupNames,
162                          const t_blocka*                  grps,
163                          char**                           gnames);
164 /* Process the pull group parameters after reading the index groups */
165
166 void checkPullCoords(gmx::ArrayRef<const t_pull_group> pullGroups,
167                      gmx::ArrayRef<const t_pull_coord> pullCoords);
168 /* Process the pull coordinates after reading the pull groups */
169
170 pull_t* set_pull_init(t_inputrec*                    ir,
171                       const gmx_mtop_t&              mtop,
172                       gmx::ArrayRef<const gmx::RVec> x,
173                       matrix                         box,
174                       real                           lambda,
175                       warninp_t                      wi);
176 /* Prints the initial pull group distances in x.
177  * If requested, adds the current distance to the initial reference location.
178  * Returns the pull_t pull work struct. This should be passed to finish_pull()
179  * after all modules have registered their external potentials, if present.
180  */
181
182 std::vector<std::string> read_rotparams(std::vector<t_inpfile>* inp, t_rot* rot, warninp_t wi);
183 /* Reads enforced rotation parameters, returns a list of the rot group names */
184
185 void make_rotation_groups(t_rot*                           rot,
186                           gmx::ArrayRef<const std::string> rotateGroupNames,
187                           t_blocka*                        grps,
188                           char**                           gnames);
189 /* Process the rotation parameters after reading the index groups */
190
191 void set_reference_positions(t_rot* rot, rvec* x, matrix box, const char* fn, bool bSet, warninp_t wi);
192
193 #endif