Clean up grompp memory leaks in rotation and pull structures.
[gromacs.git] / src / gromacs / gmxpreprocess / readir.h
blob939b1cd3fc92832189a70b4236e3d8f3e3d18de3
1 /*
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) 2013,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.
39 #ifndef GMX_GMXPREPROCESS_READIR_H
40 #define GMX_GMXPREPROCESS_READIR_H
42 #include "gromacs/fileio/readinp.h"
43 #include "gromacs/math/vectypes.h"
44 #include "gromacs/utility/real.h"
46 namespace gmx
48 class MDModules;
49 struct MdModulesNotifier;
50 } // namespace gmx
52 struct gmx_mtop_t;
53 struct gmx_output_env_t;
54 struct pull_params_t;
55 struct pull_t;
56 struct t_blocka;
57 struct t_grpopts;
58 struct t_inpfile;
59 struct t_inputrec;
60 struct t_rot;
61 struct warninp;
62 typedef warninp* warninp_t;
64 enum
66 eshNONE,
67 eshHBONDS,
68 eshALLBONDS,
69 eshHANGLES,
70 eshALLANGLES,
71 eshNR
74 enum
76 ecouplamVDWQ,
77 ecouplamVDW,
78 ecouplamQ,
79 ecouplamNONE,
80 ecouplamNR
83 struct t_gromppopts
85 int warnings;
86 int nshake;
87 char* include;
88 char* define;
89 bool bGenVel;
90 bool bGenPairs;
91 real tempi;
92 int seed;
93 bool bOrire;
94 bool bMorse;
95 char* wall_atomtype[2];
96 char* couple_moltype;
97 int couple_lam0;
98 int couple_lam1;
99 bool bCoupleIntra;
102 /*! \brief Initialise object to hold strings parsed from an .mdp file */
103 void init_inputrec_strings();
105 /*! \brief Clean up object that holds strings parsed from an .mdp file */
106 void done_inputrec_strings();
108 void check_ir(const char* mdparin,
109 const gmx::MdModulesNotifier& mdModulesNotifier,
110 t_inputrec* ir,
111 t_gromppopts* opts,
112 warninp_t wi);
113 /* Validate inputrec data.
114 * Fatal errors will be added to nerror.
116 int search_string(const char* s, int ng, char* gn[]);
117 /* Returns the index of string s in the index groups */
119 void double_check(t_inputrec* ir, matrix box, bool bHasNormalConstraints, bool bHasAnyConstraints, warninp_t wi);
120 /* Do more checks */
122 void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_t wi);
123 /* Do even more checks */
125 void get_ir(const char* mdparin,
126 const char* mdparout,
127 gmx::MDModules* mdModules,
128 t_inputrec* ir,
129 t_gromppopts* opts,
130 WriteMdpHeader writeMdpHeader,
131 warninp_t wi);
132 /* Read the input file, and retrieve data for inputrec.
133 * More data are read, but the are only evaluated when the next
134 * function is called. Also prints the input file back to mdparout.
137 void do_index(const char* mdparin,
138 const char* ndx,
139 gmx_mtop_t* mtop,
140 bool bVerbose,
141 const gmx::MdModulesNotifier& notifier,
142 t_inputrec* ir,
143 warninp_t wi);
144 /* Read the index file and assign grp numbers to atoms.
147 /* Routines In readpull.c */
149 std::vector<std::string> read_pullparams(std::vector<t_inpfile>* inp, pull_params_t* pull, warninp_t wi);
150 /* Reads the pull parameters, returns a list of the pull group names */
152 void make_pull_groups(pull_params_t* pull,
153 gmx::ArrayRef<const std::string> pullGroupNames,
154 const t_blocka* grps,
155 char** gnames);
156 /* Process the pull group parameters after reading the index groups */
158 void make_pull_coords(pull_params_t* pull);
159 /* Process the pull coordinates after reading the pull groups */
161 pull_t* set_pull_init(t_inputrec* ir, const gmx_mtop_t* mtop, rvec* x, matrix box, real lambda, warninp_t wi);
162 /* Prints the initial pull group distances in x.
163 * If requested, adds the current distance to the initial reference location.
164 * Returns the pull_t pull work struct. This should be passed to finish_pull()
165 * after all modules have registered their external potentials, if present.
168 std::vector<std::string> read_rotparams(std::vector<t_inpfile>* inp, t_rot* rot, warninp_t wi);
169 /* Reads enforced rotation parameters, returns a list of the rot group names */
171 void make_rotation_groups(t_rot* rot,
172 gmx::ArrayRef<const std::string> rotateGroupNames,
173 t_blocka* grps,
174 char** gnames);
175 /* Process the rotation parameters after reading the index groups */
177 void set_reference_positions(t_rot* rot, rvec* x, matrix box, const char* fn, bool bSet, warninp_t wi);
179 #endif