Document and clean up do_numbering()
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / readir.h
index fc1357749ce6d703b0ebb7af61661d3a2c475dea..fef3384e11903f9541b9f477713c5a736b9fa132 100644 (file)
@@ -3,7 +3,8 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 #ifndef GMX_GMXPREPROCESS_READIR_H
 #define GMX_GMXPREPROCESS_READIR_H
 
-#include "gromacs/gmxpreprocess/grompp-impl.h"
+#include <string>
+
+#include "gromacs/fileio/readinp.h"
+#include "gromacs/math/vectypes.h"
+#include "gromacs/mdtypes/multipletimestepping.h"
+#include "gromacs/utility/arrayref.h"
+#include "gromacs/utility/real.h"
 
 namespace gmx
 {
 class MDModules;
-}
+struct MDModulesNotifiers;
+} // namespace gmx
 
-struct gmx_groups_t;
 struct gmx_mtop_t;
 struct gmx_output_env_t;
 struct pull_params_t;
 struct pull_t;
+struct t_blocka;
 struct t_grpopts;
 struct t_inpfile;
 struct t_inputrec;
+struct t_pull_group;
+struct t_pull_coord;
 struct t_rot;
 struct warninp;
-typedef warninp *warninp_t;
+typedef warninpwarninp_t;
 
-enum {
-    eshNONE, eshHBONDS, eshALLBONDS, eshHANGLES, eshALLANGLES, eshNR
+enum
+{
+    eshNONE,
+    eshHBONDS,
+    eshALLBONDS,
+    eshHANGLES,
+    eshALLANGLES,
+    eshNR
 };
 
-enum {
-    ecouplamVDWQ, ecouplamVDW, ecouplamQ, ecouplamNONE, ecouplamNR
+enum
+{
+    ecouplamVDWQ,
+    ecouplamVDW,
+    ecouplamQ,
+    ecouplamNONE,
+    ecouplamNR
 };
 
 struct t_gromppopts
 {
-    int      warnings;
-    int      nshake;
-    char    *include;
-    char    *define;
-    gmx_bool bGenVel;
-    gmx_bool bGenPairs;
-    real     tempi;
-    int      seed;
-    gmx_bool bOrire;
-    gmx_bool bMorse;
-    char    *wall_atomtype[2];
-    char    *couple_moltype;
-    int      couple_lam0;
-    int      couple_lam1;
-    gmx_bool bCoupleIntra;
+    int                warnings  = 0;
+    int                nshake    = 0;
+    char*              include   = nullptr;
+    char*              define    = nullptr;
+    bool               bGenVel   = false;
+    bool               bGenPairs = false;
+    real               tempi     = 0;
+    int                seed      = 0;
+    gmx::GromppMtsOpts mtsOpts;
+    bool               bOrire           = false;
+    bool               bMorse           = false;
+    char*              wall_atomtype[2] = { nullptr, nullptr };
+    char*              couple_moltype   = nullptr;
+    int                couple_lam0      = 0;
+    int                couple_lam1      = 0;
+    bool               bCoupleIntra     = false;
 };
 
 /*! \brief Initialise object to hold strings parsed from an .mdp file */
@@ -90,81 +112,82 @@ void init_inputrec_strings();
 /*! \brief Clean up object that holds strings parsed from an .mdp file */
 void done_inputrec_strings();
 
-void check_ir(const char *mdparin, t_inputrec *ir, t_gromppopts *opts,
-              warninp_t wi);
-/* Validate inputrec data.
- * Fatal errors will be added to nerror.
+/*! \brief Performs all validation on \p ir that can be done without index groups and topology
+ *
+ * Any errors, warnings or notes are added to \p wi
  */
-int search_string(const char *s, int ng, char *gn[]);
-/* Returns the index of string s in the index groups */
+void check_ir(const char*                    mdparin,
+              const gmx::MDModulesNotifiers& mdModulesNotifiers,
+              t_inputrec*                    ir,
+              t_gromppopts*                  opts,
+              warninp_t                      wi);
 
-void double_check(t_inputrec *ir, matrix box,
-                  gmx_bool bHasNormalConstraints,
-                  gmx_bool bHasAnyConstraints,
-                  warninp_t wi);
+//! Returns the index of string \p s in \p gn or exit with a verbose fatal error when not found
+int search_string(const char* s, int ng, char* const gn[]);
+
+void double_check(t_inputrec* ir, matrix box, bool bHasNormalConstraints, bool bHasAnyConstraints, warninp_t wi);
 /* Do more checks */
 
-void triple_check(const char *mdparin, t_inputrec *ir, gmx_mtop_t *sys,
-                  warninp_t wi);
+void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_t wi);
 /* Do even more checks */
 
-void check_chargegroup_radii(const gmx_mtop_t *mtop, const t_inputrec *ir,
-                             rvec *x,
-                             warninp_t wi);
-/* Even more checks, charge group radii vs. cut-off's only. */
-
-void get_ir(const char *mdparin, const char *mdparout,
-            gmx::MDModules *mdModules, t_inputrec *ir, t_gromppopts *opts,
-            warninp_t wi);
+void get_ir(const char*     mdparin,
+            const char*     mdparout,
+            gmx::MDModules* mdModules,
+            t_inputrec*     ir,
+            t_gromppopts*   opts,
+            WriteMdpHeader  writeMdpHeader,
+            warninp_t       wi);
 /* Read the input file, and retrieve data for inputrec.
  * More data are read, but the are only evaluated when the next
  * function is called. Also prints the input file back to mdparout.
  */
 
-void do_index(const char* mdparin,
-              const char *ndx,
-              gmx_mtop_t *mtop,
-              gmx_bool    bVerbose,
-              t_inputrec *ir,
-              warninp_t   wi);
+void do_index(const char*                    mdparin,
+              const char*                    ndx,
+              gmx_mtop_t*                    mtop,
+              bool                           bVerbose,
+              const gmx::MDModulesNotifiers& mdModulesNotifiers,
+              t_inputrec*                    ir,
+              warninp_t                      wi);
 /* Read the index file and assign grp numbers to atoms.
  */
 
 /* Routines In readpull.c */
 
-char **read_pullparams(int *ninp_p, t_inpfile **inp,
-                       pull_params_t *pull,
-                       warninp_t wi);
+std::vector<std::string> read_pullparams(std::vector<t_inpfile>* inp, pull_params_t* pull, warninp_t wi);
 /* Reads the pull parameters, returns a list of the pull group names */
-
-void make_pull_groups(pull_params_t *pull,
-                      char **pgnames,
-                      const t_blocka *grps, char **gnames);
+void process_pull_groups(gmx::ArrayRef<t_pull_group>      pullGroups,
+                         gmx::ArrayRef<const std::string> pullGroupNames,
+                         const t_blocka*                  grps,
+                         char**                           gnames);
 /* Process the pull group parameters after reading the index groups */
 
-void make_pull_coords(pull_params_t *pull);
+void checkPullCoords(gmx::ArrayRef<const t_pull_group> pullGroups,
+                     gmx::ArrayRef<const t_pull_coord> pullCoords);
 /* Process the pull coordinates after reading the pull groups */
 
-pull_t *set_pull_init(t_inputrec *ir, const gmx_mtop_t *mtop,
-                      rvec *x, matrix box, real lambda,
-                      const gmx_output_env_t *oenv);
+pull_t* set_pull_init(t_inputrec*                    ir,
+                      const gmx_mtop_t&              mtop,
+                      gmx::ArrayRef<const gmx::RVec> x,
+                      matrix                         box,
+                      real                           lambda,
+                      warninp_t                      wi);
 /* Prints the initial pull group distances in x.
  * If requested, adds the current distance to the initial reference location.
  * Returns the pull_t pull work struct. This should be passed to finish_pull()
  * after all modules have registered their external potentials, if present.
  */
 
-int str_nelem(const char *str, int maxptr, char *ptr[]);
-/* helper function from readir.c to convert strings */
-
-char **read_rotparams(int *ninp_p, t_inpfile **inp, t_rot *rot, warninp_t wi);
+std::vector<std::string> read_rotparams(std::vector<t_inpfile>* inp, t_rot* rot, warninp_t wi);
 /* Reads enforced rotation parameters, returns a list of the rot group names */
 
-void make_rotation_groups(t_rot *rot, char **rotgnames,
-                          t_blocka *grps, char **gnames);
+void make_rotation_groups(t_rot*                           rot,
+                          gmx::ArrayRef<const std::string> rotateGroupNames,
+                          t_blocka*                        grps,
+                          char**                           gnames);
 /* Process the rotation parameters after reading the index groups */
 
-void set_reference_positions(t_rot *rot, rvec *x, matrix box,
-                             const char *fn, gmx_bool bSet, warninp_t wi);
+void set_reference_positions(t_rot* rot, rvec* x, matrix box, const char* fn, bool bSet, warninp_t wi);
 
 #endif