Clean up constraints code
authorMark Abraham <mark.j.abraham@gmail.com>
Wed, 28 Feb 2018 18:08:14 +0000 (19:08 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 13 Apr 2018 09:58:32 +0000 (11:58 +0200)
Moved constraint code into gmx namespace.

Used more forward declarations in both the old and new headers.

Removed typedef from type declarations.

Removed gmx_ prefix from some names, since it is no longer required
and we may as well avoid verbiage.

Renamed some types more consistently with newer coding styles, and
called them class now where they will be one shortly.

Added some const correctness.

Apparently this inspires uncrustify to change positions of some
comments. Go figure.

Replaced all gmx_bool in constraints code with bool.

Maths functions from vec.h (which are not in the top-level namespace)
now need namespace qualifications.

Added and fixed various Doxygen, which is primitive in some cases
where the code was particularly cryptic.

Noted policy on multiple authors within Doxygen comments.

Refs #2423

Change-Id: I41bf3a4b9a4fbbcb3a3a7a27dc922d563abedbcb

34 files changed:
docs/dev-manual/doxygen.rst
src/gromacs/domdec/domdec.cpp
src/gromacs/domdec/domdec.h
src/gromacs/domdec/domdec_constraints.cpp
src/gromacs/domdec/domdec_constraints.h
src/gromacs/essentialdynamics/edsam.cpp
src/gromacs/essentialdynamics/edsam.h
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/mdlib/constr.cpp
src/gromacs/mdlib/constr.h
src/gromacs/mdlib/constraintrange.cpp
src/gromacs/mdlib/constraintrange.h
src/gromacs/mdlib/lincs.cpp
src/gromacs/mdlib/lincs.h
src/gromacs/mdlib/md_support.cpp
src/gromacs/mdlib/md_support.h
src/gromacs/mdlib/mdebin.cpp
src/gromacs/mdlib/mdebin.h
src/gromacs/mdlib/settle.cpp
src/gromacs/mdlib/settle.h
src/gromacs/mdlib/shake.cpp
src/gromacs/mdlib/shake.h
src/gromacs/mdlib/shellfc.cpp
src/gromacs/mdlib/shellfc.h
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdlib/sim_util.h
src/gromacs/mdlib/stat.cpp
src/gromacs/mdlib/tests/settle.cpp
src/gromacs/mdlib/tests/shake.cpp
src/gromacs/mdlib/update.cpp
src/gromacs/mdlib/update.h
src/gromacs/mdrun/integrator.h
src/gromacs/mdrun/minimize.cpp
src/gromacs/mdrun/runner.cpp

index 15dd37f56221fdb6e3ad6d240914fc0468940b06..ae86c3c45158506ee9cef3466c842e1bcd4711f0 100644 (file)
@@ -316,7 +316,8 @@ documentation.
 
 One or more contact persons who know about the contents of the module should be
 listed using ``\author`` commands.  This provides a point of contact if one
-has questions.
+has questions. Authors should be listed in chronological order of contributions,
+where possible.
 
 Classes/structs
 ^^^^^^^^^^^^^^^
index a3c82375df8dfe5874df0c4e9a1573187d34bc2c..ec8a20d5883a41eedd590097c751fd4ba5dbc985 100644 (file)
@@ -9204,7 +9204,7 @@ void dd_partition_system(FILE                *fplog,
                          gmx_localtop_t      *top_local,
                          t_forcerec          *fr,
                          gmx_vsite_t         *vsite,
-                         gmx_constr_t         constr,
+                         gmx::Constraints    *constr,
                          t_nrnb              *nrnb,
                          gmx_wallcycle       *wcycle,
                          gmx_bool             bVerbose)
index 462953bd6c5e75c6b9d8c5a1f7ae13fc479cbe10..23f347251a09fb02ff09354d2e9356db08d7a951 100644 (file)
@@ -86,6 +86,7 @@ class t_state;
 
 namespace gmx
 {
+class Constraints;
 class MDAtoms;
 } // namespace
 
@@ -324,7 +325,7 @@ void dd_partition_system(FILE                *fplog,
                          gmx_localtop_t      *top_local,
                          t_forcerec          *fr,
                          gmx_vsite_t         *vsite,
-                         struct gmx_constr   *constr,
+                         gmx::Constraints    *constr,
                          t_nrnb              *nrnb,
                          gmx_wallcycle       *wcycle,
                          gmx_bool             bVerbose);
index 1b2d141b09abc294a336d7fac3ea157e00f4a0d2..e9bd0a7da0e3b5bd8b923f22179481ebe4cb4c91 100644 (file)
@@ -440,7 +440,7 @@ static void atoms_to_constraints(gmx_domdec_t *dd,
 int dd_make_local_constraints(gmx_domdec_t *dd, int at_start,
                               const struct gmx_mtop_t *mtop,
                               const int *cginfo,
-                              gmx_constr_t constr, int nrec,
+                              gmx::Constraints *constr, int nrec,
                               t_ilist *il_local)
 {
     gmx_domdec_constraints_t   *dc;
index 8e94f91c9cdd72a2c12ce686ec25b5cd71880dc0..d8d829403740cad4e405848db3265a843658d6ba 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2005,2006,2007,2008,2009,2010,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2005,2006,2007,2008,2009,2010,2012,2013,2014,2015,2018, 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_DOMDEC_DOMDEC_CONSTRAINTS_H
 #define GMX_DOMDEC_DOMDEC_CONSTRAINTS_H
 
-#include "gromacs/mdlib/constr.h"
+namespace gmx
+{
+class Constraints;
+}
 
 struct gmx_domdec_t;
 struct gmx_mtop_t;
@@ -57,7 +60,7 @@ void dd_clear_local_constraint_indices(gmx_domdec_t *dd);
 int dd_make_local_constraints(struct gmx_domdec_t *dd, int at_start,
                               const struct gmx_mtop_t *mtop,
                               const int *cginfo,
-                              gmx_constr_t constr, int nrec,
+                              gmx::Constraints *constr, int nrec,
                               struct t_ilist *il_local);
 
 /*! \brief Initializes the data structures for constraint communication */
index 66755e45ac463d8d99547c64a1641820a92ba841..b1990e575bc239960b9281797979e582e88b8861 100644 (file)
@@ -2577,7 +2577,7 @@ gmx_edsam_t init_edsam(
         const gmx_mtop_t       *mtop,
         const t_inputrec       *ir,
         const t_commrec        *cr,
-        gmx_constr             *constr,
+        gmx::Constraints       *constr,
         const t_state          *globalState,
         ObservablesHistory     *oh,
         const gmx_output_env_t *oenv,
index 7cb0ae5a294b6a4cb7c6fdcaf2791e39878c4fbd..43466797b739125482bb59dba39cbebe1328b2f6 100644 (file)
@@ -67,6 +67,11 @@ struct t_filenm;
 struct t_inputrec;
 class t_state;
 
+namespace gmx
+{
+class Constraints;
+}
+
 /*! \brief Applies essential dynamics constrains as defined in the .edi input file.
  *
  * \param ir                MD input parameter record.
@@ -102,7 +107,7 @@ gmx_edsam_t init_edsam(
         const gmx_mtop_t       *mtop,
         const t_inputrec       *ir,
         const t_commrec        *cr,
-        struct gmx_constr      *constr,
+        gmx::Constraints       *constr,
         const t_state          *globalState,
         ObservablesHistory     *oh,
         const gmx_output_env_t *oenv,
index 2cabe5da7e96e0ce1d22af06843231d9f1912016..d124df0596ec239f2cd7ae0078b02d449e72f2cd 100644 (file)
@@ -1389,10 +1389,9 @@ static bool haveDecoupledModeInMol(const gmx_moltype_t *molt,
     const t_atom * atom = molt->atoms.atom;
 
     int            numFlexibleConstraints;
-    t_blocka       atomToConstraints = make_at2con(0, molt->atoms.nr,
-                                                   molt->ilist, iparams,
-                                                   FALSE,
-                                                   &numFlexibleConstraints);
+    t_blocka       atomToConstraints = gmx::make_at2con(0, molt->atoms.nr,
+                                                        molt->ilist, iparams,
+                                                        FALSE, &numFlexibleConstraints);
 
     bool           haveDecoupledMode = false;
     for (int ftype = 0; ftype < F_NRE; ftype++)
index 819310c7c195320ffd7583d2f3754558c4b98e02..7b006bac1a810c67446a6e3f11dc8a7aaa76884a 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \internal \file
+ * \brief Defines the high-level constraint code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ */
 #include "gmxpre.h"
 
 #include "constr.h"
 #include "gromacs/utility/smalloc.h"
 #include "gromacs/utility/txtdump.h"
 
-typedef struct gmx_constr {
-    int                ncon_tot;       /* The total number of constraints    */
-    int                nflexcon;       /* The number of flexible constraints */
-    int                n_at2con_mt;    /* The size of at2con = #moltypes     */
-    t_blocka          *at2con_mt;      /* A list of atoms to constraints     */
-    int                n_at2settle_mt; /* The size of at2settle = #moltypes  */
-    int              **at2settle_mt;   /* A list of atoms to settles         */
-    gmx_bool           bInterCGsettles;
-    gmx_lincsdata_t    lincsd;         /* LINCS data                         */
-    gmx_shakedata_t    shaked;         /* SHAKE data                         */
-    gmx_settledata_t   settled;        /* SETTLE data                        */
-    int                maxwarn;        /* The maximum number of warnings     */
-    int                warncount_lincs;
-    int                warncount_settle;
-    gmx_edsam_t        ed;             /* The essential dynamics data        */
-
-    /* Thread local working data */
-    tensor            *vir_r_m_dr_th;           /* Thread virial contribution */
-    bool              *bSettleErrorHasOccurred; /* Did a settle error occur?  */
-
-    /* Only used for printing warnings */
-    const gmx_mtop_t  *warn_mtop;     /* Pointer to the global topology     */
-} t_gmx_constr;
-
-int n_flexible_constraints(struct gmx_constr *constr)
+namespace gmx
+{
+
+class Constraints
+{
+    public:
+        int                ncon_tot;       /* The total number of constraints    */
+        int                nflexcon;       /* The number of flexible constraints */
+        int                n_at2con_mt;    /* The size of at2con = #moltypes     */
+        t_blocka          *at2con_mt;      /* A list of atoms to constraints     */
+        int                n_at2settle_mt; /* The size of at2settle = #moltypes  */
+        int              **at2settle_mt;   /* A list of atoms to settles         */
+        bool               bInterCGsettles;
+        Lincs             *lincsd;         /* LINCS data                         */
+        shakedata         *shaked;         /* SHAKE data                         */
+        settledata        *settled;        /* SETTLE data                        */
+        int                maxwarn;        /* The maximum number of warnings     */
+        int                warncount_lincs;
+        int                warncount_settle;
+        gmx_edsam_t        ed;         /* The essential dynamics data        */
+
+        /* Thread local working data */
+        tensor            *vir_r_m_dr_th;           /* Thread virial contribution */
+        bool              *bSettleErrorHasOccurred; /* Did a settle error occur?  */
+
+        /* Only used for printing warnings */
+        const gmx_mtop_t  *warn_mtop; /* Pointer to the global topology     */
+};
+
+int n_flexible_constraints(const Constraints *constr)
 {
     int nflexcon;
 
@@ -116,6 +128,7 @@ int n_flexible_constraints(struct gmx_constr *constr)
     return nflexcon;
 }
 
+//! Clears constraint quantities for atoms in nonlocal region.
 static void clear_constraint_quantity_nonlocal(gmx_domdec_t *dd, rvec *q)
 {
     int nonlocal_at_start, nonlocal_at_end, at;
@@ -140,6 +153,7 @@ void too_many_constraint_warnings(int eConstrAlg, int warncount)
               "adjust the lincs warning threshold in your mdp file\nor " : "\n");
 }
 
+//! Writes out coordinates.
 static void write_constr_pdb(const char *fn, const char *title,
                              const gmx_mtop_t *mtop,
                              int start, int homenr, const t_commrec *cr,
@@ -197,6 +211,7 @@ static void write_constr_pdb(const char *fn, const char *title,
     gmx_fio_fclose(out);
 }
 
+//! Writes out domain contents to help diagnose crashes.
 static void dump_confs(FILE *fplog, gmx_int64_t step, const gmx_mtop_t *mtop,
                        int start, int homenr, const t_commrec *cr,
                        rvec x[], rvec xprime[], matrix box)
@@ -222,21 +237,21 @@ static void dump_confs(FILE *fplog, gmx_int64_t step, const gmx_mtop_t *mtop,
     fprintf(stderr, "Wrote pdb files with previous and current coordinates\n");
 }
 
-gmx_bool constrain(FILE *fplog, gmx_bool bLog, gmx_bool bEner,
-                   struct gmx_constr *constr,
-                   t_idef *idef, const t_inputrec *ir,
-                   const t_commrec *cr,
-                   const gmx_multisim_t *ms,
-                   gmx_int64_t step, int delta_step,
-                   real step_scaling,
-                   t_mdatoms *md,
-                   rvec *x, rvec *xprime, rvec *min_proj,
-                   gmx_bool bMolPBC, matrix box,
-                   real lambda, real *dvdlambda,
-                   rvec *v, tensor *vir,
-                   t_nrnb *nrnb, int econq)
+bool constrain(FILE *fplog, bool bLog, bool bEner,
+               Constraints *constr,
+               t_idef *idef, const t_inputrec *ir,
+               const t_commrec *cr,
+               const gmx_multisim_t *ms,
+               gmx_int64_t step, int delta_step,
+               real step_scaling,
+               t_mdatoms *md,
+               rvec *x, rvec *xprime, rvec *min_proj,
+               bool bMolPBC, matrix box,
+               real lambda, real *dvdlambda,
+               rvec *v, tensor *vir,
+               t_nrnb *nrnb, int econq)
 {
-    gmx_bool    bOK, bDump;
+    bool        bOK, bDump;
     int         start, homenr;
     tensor      vir_r_m_dr;
     real        scaled_delta_t;
@@ -571,7 +586,7 @@ gmx_bool constrain(FILE *fplog, gmx_bool bLog, gmx_bool bEner,
     return bOK;
 }
 
-real *constr_rmsd_data(struct gmx_constr *constr)
+real *constr_rmsd_data(Constraints *constr)
 {
     if (constr->lincsd)
     {
@@ -583,7 +598,7 @@ real *constr_rmsd_data(struct gmx_constr *constr)
     }
 }
 
-real constr_rmsd(struct gmx_constr *constr)
+real constr_rmsd(const Constraints *constr)
 {
     if (constr->lincsd)
     {
@@ -597,12 +612,12 @@ real constr_rmsd(struct gmx_constr *constr)
 
 t_blocka make_at2con(int start, int natoms,
                      const t_ilist *ilist, const t_iparams *iparams,
-                     gmx_bool bDynamics, int *nflexiblecons)
+                     bool bDynamics, int *nflexiblecons)
 {
     int      *count, ncon, con, con_tot, nflexcon, ftype, i, a;
     t_iatom  *ia;
     t_blocka  at2con;
-    gmx_bool  bFlexCon;
+    bool      bFlexCon;
 
     snew(count, natoms);
     nflexcon = 0;
@@ -674,6 +689,7 @@ t_blocka make_at2con(int start, int natoms,
     return at2con;
 }
 
+//! Returns the index of the settle to which each atom belongs.
 static int *make_at2settle(int natoms, const t_ilist *ilist)
 {
     int *at2s;
@@ -698,7 +714,7 @@ static int *make_at2settle(int natoms, const t_ilist *ilist)
     return at2s;
 }
 
-void set_constraints(struct gmx_constr *constr,
+void set_constraints(Constraints *constr,
                      gmx_localtop_t *top, const t_inputrec *ir,
                      const t_mdatoms *md, const t_commrec *cr)
 {
@@ -741,7 +757,7 @@ void set_constraints(struct gmx_constr *constr,
     }
 }
 
-gmx_constr_t init_constraints(FILE *fplog,
+Constraints *init_constraints(FILE *fplog,
                               const gmx_mtop_t *mtop, const t_inputrec *ir,
                               bool doEssentialDynamics,
                               const t_commrec *cr)
@@ -761,7 +777,7 @@ gmx_constr_t init_constraints(FILE *fplog,
         return nullptr;
     }
 
-    struct gmx_constr *constr;
+    Constraints *constr;
 
     snew(constr, 1);
 
@@ -900,30 +916,29 @@ gmx_constr_t init_constraints(FILE *fplog,
     return constr;
 }
 
-/* Put a pointer to the essential dynamics constraints into the constr struct */
-void saveEdsamPointer(gmx_constr_t constr, gmx_edsam_t ed)
+void saveEdsamPointer(Constraints *constr, gmx_edsam *ed)
 {
     constr->ed = ed;
 }
 
-const t_blocka *atom2constraints_moltype(gmx_constr_t constr)
+const t_blocka *atom2constraints_moltype(const Constraints *constr)
 {
     return constr->at2con_mt;
 }
 
-const int **atom2settle_moltype(gmx_constr_t constr)
+const int **atom2settle_moltype(const Constraints *constr)
 {
     return (const int **)constr->at2settle_mt;
 }
 
 
-gmx_bool inter_charge_group_constraints(const gmx_mtop_t *mtop)
+bool inter_charge_group_constraints(const gmx_mtop_t *mtop)
 {
     const gmx_moltype_t *molt;
     const t_block       *cgs;
     const t_ilist       *il;
     int                 *at2cg, cg, a, ftype, i;
-    gmx_bool             bInterCG;
+    bool                 bInterCG;
 
     bInterCG = FALSE;
     for (size_t mb = 0; mb < mtop->molblock.size() && !bInterCG; mb++)
@@ -963,13 +978,13 @@ gmx_bool inter_charge_group_constraints(const gmx_mtop_t *mtop)
     return bInterCG;
 }
 
-gmx_bool inter_charge_group_settles(const gmx_mtop_t *mtop)
+bool inter_charge_group_settles(const gmx_mtop_t *mtop)
 {
     const gmx_moltype_t *molt;
     const t_block       *cgs;
     const t_ilist       *il;
     int                 *at2cg, cg, a, ftype, i;
-    gmx_bool             bInterCG;
+    bool                 bInterCG;
 
     bInterCG = FALSE;
     for (size_t mb = 0; mb < mtop->molblock.size() && !bInterCG; mb++)
@@ -1007,3 +1022,5 @@ gmx_bool inter_charge_group_settles(const gmx_mtop_t *mtop)
 
     return bInterCG;
 }
+
+} // namespace
index 15eec40bcf580b132272769a63a72eab6111ed70..a0d86431360e77e61cff2231a44cf0611567a06e 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \libinternal \file
+ * \brief Declares interface to constraint code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ * \inlibraryapi
+ */
 
-#ifndef GMX_MBLIB_CONSTR_H
-#define GMX_MBLIB_CONSTR_H
+#ifndef GMX_MDLIB_CONSTR_H
+#define GMX_MDLIB_CONSTR_H
 
 #include <cstdio>
 
@@ -59,8 +67,10 @@ struct t_pbc;
 union t_iparams;
 class t_state;
 
-/* Abstract type for constraints */
-typedef struct gmx_constr *gmx_constr_t;
+namespace gmx
+{
+
+class Constraints;
 
 enum
 {
@@ -74,28 +84,14 @@ enum
     econqForceDispl     /* Constrain forces (mass-weighted 1/0 for freeze) */
 };
 
-int n_flexible_constraints(gmx_constr *constr);
-/* Returns the total number of flexible constraints in the system */
+/*! \brief Returns the total number of flexible constraints in the system. */
+int n_flexible_constraints(const Constraints *constr);
 
+/*! \brief Generate a fatal error because of too many LINCS/SETTLE warnings. */
 void too_many_constraint_warnings(int eConstrAlg, int warncount);
-/* Generate a fatal error because of too many LINCS/SETTLE warnings */
-
-
-gmx_bool constrain(FILE *log, gmx_bool bLog, gmx_bool bEner,
-                   gmx_constr_t constr,
-                   t_idef *idef,
-                   const t_inputrec *ir,
-                   const t_commrec *cr,
-                   const gmx_multisim_t *ms,
-                   gmx_int64_t step, int delta_step,
-                   real step_scaling,
-                   t_mdatoms *md,
-                   rvec *x, rvec *xprime, rvec *min_proj,
-                   gmx_bool bMolPBC, matrix box,
-                   real lambda, real *dvdlambda,
-                   rvec *v, tensor *vir,
-                   t_nrnb *nrnb, int econq);
-/*
+
+/*! \brief Applies constraints to coordinates.
+ *
  * When econq=econqCoord constrains coordinates xprime using th
  * directions in x, min_proj is not used.
  *
@@ -125,23 +121,37 @@ gmx_bool constrain(FILE *log, gmx_bool bLog, gmx_bool bEner,
  * Return TRUE if OK, FALSE in case of shake error
  *
  */
-
-gmx_constr_t init_constraints(FILE *log,
+bool constrain(FILE *log, bool bLog, bool bEner,
+               Constraints *constr,
+               t_idef *idef,
+               const t_inputrec *ir,
+               const t_commrec *cr,
+               const gmx_multisim_t *ms,
+               gmx_int64_t step, int delta_step,
+               real step_scaling,
+               t_mdatoms *md,
+               rvec *x, rvec *xprime, rvec *min_proj,
+               bool bMolPBC, matrix box,
+               real lambda, real *dvdlambda,
+               rvec *v, tensor *vir,
+               t_nrnb *nrnb, int econq);
+
+/*! \brief Initialize constraints stuff */
+Constraints *init_constraints(FILE *log,
                               const gmx_mtop_t *mtop, const t_inputrec *ir,
                               bool doEssentialDynamics,
                               const t_commrec *cr);
-/* Initialize constraints stuff */
 
-void saveEdsamPointer(gmx_constr_t      constr,
+/*! \brief Put a pointer to the essential dynamics constraints into the constr struct. */
+void saveEdsamPointer(Constraints      *constr,
                       gmx_edsam        *ed);
-/* Put a pointer to the essential dynamics constraints into the constr struct */
 
-void set_constraints(gmx_constr_t             constr,
+/*! \brief Set up all the local constraints for this rank. */
+void set_constraints(Constraints             *constr,
                      gmx_localtop_t          *top,
                      const t_inputrec        *ir,
                      const t_mdatoms         *md,
                      const t_commrec         *cr);
-/* Set up all the local constraints for the node */
 
 /* The at2con t_blocka struct returned by the routines below
  * contains a list of constraints per atom.
@@ -149,35 +159,35 @@ void set_constraints(gmx_constr_t             constr,
  * after the F_CONSTR constraints.
  */
 
+/*! \brief Returns a block struct to go from atoms to constraints */
 t_blocka make_at2con(int start, int natoms,
                      const t_ilist *ilist, const t_iparams *iparams,
-                     gmx_bool bDynamics, int *nflexiblecons);
-/* Returns a block struct to go from atoms to constraints */
+                     bool bDynamics, int *nflexiblecons);
 
-const t_blocka *atom2constraints_moltype(gmx_constr_t constr);
-/* Returns the an array of atom to constraints lists for the moltypes */
+/*! \brief Returns an array of atom to constraints lists for the moltypes */
+const t_blocka *atom2constraints_moltype(const Constraints *constr);
 
-const int **atom2settle_moltype(gmx_constr_t constr);
-/* Returns the an array of atom to settle for the moltypes */
+/*! \brief Returns an array of atom to settles lists for the moltypes */
+const int **atom2settle_moltype(const Constraints *constr);
 
-#define constr_iatomptr(nconstr, iatom_constr, iatom_constrnc, con) ((con) < (nconstr) ? (iatom_constr)+(con)*3 : (iatom_constrnc)+(con-nconstr)*3)
-/* Macro for getting the constraint iatoms for a constraint number con
+/*! \brief Macro for getting the constraint iatoms for a constraint number con
  * which comes from a list where F_CONSTR and F_CONSTRNC constraints
- * are concatenated.
- */
+ * are concatenated. */
+#define constr_iatomptr(nconstr, iatom_constr, iatom_constrnc, con) ((con) < (nconstr) ? (iatom_constr)+(con)*3 : (iatom_constrnc)+(con-nconstr)*3)
 
-gmx_bool inter_charge_group_constraints(const gmx_mtop_t *mtop);
-/* Returns if there are inter charge group constraints */
+/*! \brief Returns whether there are inter charge group constraints */
+bool inter_charge_group_constraints(const gmx_mtop_t *mtop);
 
-gmx_bool inter_charge_group_settles(const gmx_mtop_t *mtop);
-/* Returns if there are inter charge group settles */
+/*! \brief Returns whether there are inter charge group settles */
+bool inter_charge_group_settles(const gmx_mtop_t *mtop);
 
-real *constr_rmsd_data(gmx_constr_t constr);
-/* Return the data for determining constraint RMS relative deviations.
- * Returns NULL when LINCS is not used.
- */
+/*! \brief Return the data for determining constraint RMS relative deviations.
+ * Returns NULL when LINCS is not used. */
+real *constr_rmsd_data(Constraints *constr);
+
+/*! \brief Return the RMSD of the constraint */
+real constr_rmsd(const Constraints *constr);
 
-real constr_rmsd(gmx_constr_t constr);
-/* Return the RMSD of the constraint */
+} // namespace
 
 #endif
index abe685a04d34d6f52df220864c5b1c574d4bc192..2e573bbe02a21ea7eebb90e07f32ef197ca77df6 100644 (file)
 #include "gromacs/utility/real.h"
 #include "gromacs/utility/smalloc.h"
 
+namespace gmx
+{
+
+//! Recursing function to help find all adjacent constraints.
 static void constr_recur(const t_blocka *at2con,
                          const t_ilist *ilist, const t_iparams *iparams,
                          gmx_bool bTopB,
@@ -148,6 +152,7 @@ static void constr_recur(const t_blocka *at2con,
     }
 }
 
+//! Find the interaction radius needed for constraints for this molecule type.
 static real constr_r_max_moltype(const gmx_moltype_t *molt,
                                  const t_iparams     *iparams,
                                  const t_inputrec    *ir)
@@ -234,3 +239,5 @@ real constr_r_max(FILE *fplog, const gmx_mtop_t *mtop, const t_inputrec *ir)
 
     return rmax;
 }
+
+} // namespace
index 11c4a7de8d5869be858e9eb48494d331f510381f..7a56a06f36b3b7257233a8a299fcfd3657b9aa46 100644 (file)
 struct gmx_mtop_t;
 struct t_inputrec;
 
+namespace gmx
+{
+
 /*! \brief Returns an estimate of the maximum distance between atoms
  * required for LINCS. */
 real constr_r_max(FILE *fplog, const gmx_mtop_t *mtop, const t_inputrec *ir);
 
+} // namespace
+
 #endif
index c9ec014f3c99cd8a54598e7beab19ce60f458392..3b440e7f31373c6937760a109cbbc3b1a9cad302 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
-/* This file is completely threadsafe - keep it that way! */
+/*! \internal \file
+ * \brief Defines LINCS code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ */
 #include "gmxpre.h"
 
 #include "lincs.h"
 
 using namespace gmx; // TODO: Remove when this file is moved into gmx namespace
 
-typedef struct {
-    int    b0;         /* first constraint for this task */
-    int    b1;         /* b1-1 is the last constraint for this task */
-    int    ntriangle;  /* the number of constraints in triangles */
-    int   *triangle;   /* the list of triangle constraints */
-    int   *tri_bits;   /* the bits tell if the matrix element should be used */
-    int    tri_alloc;  /* allocation size of triangle and tri_bits */
-    int    nind;       /* number of indices */
-    int   *ind;        /* constraint index for updating atom data */
-    int    nind_r;     /* number of indices */
-    int   *ind_r;      /* constraint index for updating atom data */
-    int    ind_nalloc; /* allocation size of ind and ind_r */
-    tensor vir_r_m_dr; /* temporary variable for virial calculation */
-    real   dhdlambda;  /* temporary variable for lambda derivative */
-} lincs_task_t;
-
-typedef struct gmx_lincsdata {
-    int             ncg;          /* the global number of constraints */
-    int             ncg_flex;     /* the global number of flexible constraints */
-    int             ncg_triangle; /* the global number of constraints in triangles */
-    int             nIter;        /* the number of iterations */
-    int             nOrder;       /* the order of the matrix expansion */
-    int             max_connect;  /* the maximum number of constrains connected to a single atom */
-
-    int             nc_real;      /* the number of real constraints */
-    int             nc;           /* the number of constraints including padding for SIMD */
-    int             nc_alloc;     /* the number we allocated memory for */
-    int             ncc;          /* the number of constraint connections */
-    int             ncc_alloc;    /* the number we allocated memory for */
-    real            matlam;       /* the FE lambda value used for filling blc and blmf */
-    int            *con_index;    /* mapping from topology to LINCS constraints */
-    real           *bllen0;       /* the reference distance in topology A */
-    real           *ddist;        /* the reference distance in top B - the r.d. in top A */
-    int            *bla;          /* the atom pairs involved in the constraints */
-    real           *blc;          /* 1/sqrt(invmass1 + invmass2) */
-    real           *blc1;         /* as blc, but with all masses 1 */
-    int            *blnr;         /* index into blbnb and blmf */
-    int            *blbnb;        /* list of constraint connections */
-    int             ntriangle;    /* the local number of constraints in triangles */
-    int             ncc_triangle; /* the number of constraint connections in triangles */
-    gmx_bool        bCommIter;    /* communicate before each LINCS interation */
-    real           *blmf;         /* matrix of mass factors for constraint connections */
-    real           *blmf1;        /* as blmf, but with all masses 1 */
-    real           *bllen;        /* the reference bond length */
-    int            *nlocat;       /* the local atom count per constraint, can be NULL */
-
-    int             ntask;        /* The number of tasks = #threads for LINCS */
-    lincs_task_t   *task;         /* LINCS thread division */
-    gmx_bitmask_t  *atf;          /* atom flags for thread parallelization */
-    int             atf_nalloc;   /* allocation size of atf */
-    gmx_bool        bTaskDep;     /* are the LINCS tasks interdependent? */
-    gmx_bool        bTaskDepTri;  /* are there triangle constraints that cross task borders? */
-    /* arrays for temporary storage in the LINCS algorithm */
-    rvec           *tmpv;
-    real           *tmpncc;
-    real           *tmp1;
-    real           *tmp2;
-    real           *tmp3;
-    real           *tmp4;
-    real           *mlambda; /* the Lagrange multipliers * -1 */
-    /* storage for the constraint RMS relative deviation output */
-    real            rmsd_data[3];
-} t_gmx_lincsdata;
-
-/* Define simd_width for memory allocation used for SIMD code */
+namespace gmx
+{
+
+//! Unit of work within LINCS.
+struct Task
+{
+    //! First constraint for this task.
+    int    b0;
+    //! b1-1 is the last constraint for this task.
+    int    b1;
+    //! The number of constraints in triangles.
+    int    ntriangle;
+    //! The list of triangle constraints.
+    int   *triangle;
+    //! The bits tell if the matrix element should be used.
+    int   *tri_bits;
+    //! Allocation size of triangle and tri_bits.
+    int    tri_alloc;
+    //! Number of indices.
+    int    nind;
+    //! Constraint index for updating atom data.
+    int   *ind;
+    //! Number of indices.
+    int    nind_r;
+    //! Constraint index for updating atom data.
+    int   *ind_r;
+    //! Allocation size of ind and ind_r.
+    int    ind_nalloc;
+    //! Temporary variable for virial calculation.
+    tensor vir_r_m_dr;
+    //! Temporary variable for lambda derivative.
+    real   dhdlambda;
+};
+
+/*! \brief Data for LINCS algorithm.
+ */
+class Lincs
+{
+    public:
+        //! The global number of constraints.
+        int             ncg;
+        //! The global number of flexible constraints.
+        int             ncg_flex;
+        //! The global number of constraints in triangles.
+        int             ncg_triangle;
+        //! The number of iterations.
+        int             nIter;
+        //! The order of the matrix expansion.
+        int             nOrder;
+        //! The maximum number of constraints connected to a single atom.
+        int             max_connect;
+
+        //! The number of real constraints.
+        int             nc_real;
+        //! The number of constraints including padding for SIMD.
+        int             nc;
+        //! The number we allocated memory for.
+        int             nc_alloc;
+        //! The number of constraint connections.
+        int             ncc;
+        //! The number we allocated memory for.
+        int             ncc_alloc;
+        //! The FE lambda value used for filling blc and blmf.
+        real            matlam;
+        //! mapping from topology to LINCS constraints.
+        int            *con_index;
+        //! The reference distance in topology A.
+        real           *bllen0;
+        //! The reference distance in top B - the r.d. in top A.
+        real           *ddist;
+        //! The atom pairs involved in the constraints.
+        int            *bla;
+        //! 1/sqrt(invmass1  invmass2).
+        real           *blc;
+        //! As blc, but with all masses 1.
+        real           *blc1;
+        //! Index into blbnb and blmf.
+        int            *blnr;
+        //! List of constraint connections.
+        int            *blbnb;
+        //! The local number of constraints in triangles.
+        int             ntriangle;
+        //! The number of constraint connections in triangles.
+        int             ncc_triangle;
+        //! Communicate before each LINCS interation.
+        bool            bCommIter;
+        //! Matrix of mass factors for constraint connections.
+        real           *blmf;
+        //! As blmf, but with all masses 1.
+        real           *blmf1;
+        //! The reference bond length.
+        real           *bllen;
+        //! The local atom count per constraint, can be NULL.
+        int            *nlocat;
+
+        /*! \brief The number of tasks used for LINCS work.
+         *
+         * \todo This is mostly used to loop over \c task, which would
+         * be nicer to do with range-based for loops, but the thread
+         * index is used for constructing bit masks and organizing the
+         * virial output buffer, so other things need to change,
+         * first. */
+        int             ntask;
+        /*! \brief LINCS thread division */
+        Task           *task;
+        //! Atom flags for thread parallelization.
+        gmx_bitmask_t  *atf;
+        //! Allocation size of atf
+        int             atf_nalloc;
+        //! Are the LINCS tasks interdependent?
+        bool            bTaskDep;
+        //! Are there triangle constraints that cross task borders?
+        bool            bTaskDepTri;
+        //! Arrays for temporary storage in the LINCS algorithm.
+        /*! @{ */
+        rvec           *tmpv;
+        real           *tmpncc;
+        real           *tmp1;
+        real           *tmp2;
+        real           *tmp3;
+        real           *tmp4;
+        /*! @} */
+        //! The Lagrange multipliers times -1.
+        real           *mlambda;
+        //! Storage for the constraint RMS relative deviation output.
+        real            rmsd_data[3];
+};
+
+/*! \brief Define simd_width for memory allocation used for SIMD code */
 #if GMX_SIMD_HAVE_REAL
 static const int simd_width = GMX_SIMD_REAL_WIDTH;
 #else
 static const int simd_width = 1;
 #endif
 
-/* Align to 128 bytes, consistent with the current implementation of
+/*! \brief Align to 128 bytes, consistent with the current implementation of
    AlignedAllocator, which currently forces 128 byte alignment. */
 static const int align_bytes = 128;
 
-real *lincs_rmsd_data(struct gmx_lincsdata *lincsd)
+real *lincs_rmsd_data(Lincs *lincsd)
 {
     return lincsd->rmsd_data;
 }
 
-real lincs_rmsd(struct gmx_lincsdata *lincsd)
+real lincs_rmsd(const Lincs *lincsd)
 {
     if (lincsd->rmsd_data[0] > 0)
     {
@@ -171,12 +241,13 @@ real lincs_rmsd(struct gmx_lincsdata *lincsd)
     }
 }
 
-/* Do a set of nrec LINCS matrix multiplications.
+/*! \brief Do a set of nrec LINCS matrix multiplications.
+ *
  * This function will return with up to date thread-local
  * constraint data, without an OpenMP barrier.
  */
-static void lincs_matrix_expand(const gmx_lincsdata *lincsd,
-                                const lincs_task_t *li_task,
+static void lincs_matrix_expand(const Lincs *lincsd,
+                                const Task *li_task,
                                 const real *blcc,
                                 real *rhs1, real *rhs2, real *sol)
 {
@@ -215,7 +286,7 @@ static void lincs_matrix_expand(const gmx_lincsdata *lincsd,
         swap = rhs1;
         rhs1 = rhs2;
         rhs2 = swap;
-    } /* nrec*(ncons+2*nrtot) flops */
+    }   /* nrec*(ncons+2*nrtot) flops */
 
     if (lincsd->ntriangle > 0)
     {
@@ -274,7 +345,7 @@ static void lincs_matrix_expand(const gmx_lincsdata *lincsd,
             swap = rhs1;
             rhs1 = rhs2;
             rhs2 = swap;
-        } /* nrec*(ntriangle + ncc_triangle*2) flops */
+        }   /* nrec*(ntriangle + ncc_triangle*2) flops */
 
         if (lincsd->bTaskDepTri)
         {
@@ -287,6 +358,7 @@ static void lincs_matrix_expand(const gmx_lincsdata *lincsd,
     }
 }
 
+//! Update atomic coordinates when an index is not required.
 static void lincs_update_atoms_noind(int ncons, const int *bla,
                                      real prefac,
                                      const real *fac, rvec *r,
@@ -314,7 +386,7 @@ static void lincs_update_atoms_noind(int ncons, const int *bla,
             x[j][0] += tmp0*im2;
             x[j][1] += tmp1*im2;
             x[j][2] += tmp2*im2;
-        } /* 16 ncons flops */
+        }   /* 16 ncons flops */
     }
     else
     {
@@ -336,6 +408,7 @@ static void lincs_update_atoms_noind(int ncons, const int *bla,
     }
 }
 
+//! Update atomic coordinates when an index is required.
 static void lincs_update_atoms_ind(int ncons, const int *ind, const int *bla,
                                    real prefac,
                                    const real *fac, rvec *r,
@@ -364,7 +437,7 @@ static void lincs_update_atoms_ind(int ncons, const int *ind, const int *bla,
             x[j][0] += tmp0*im2;
             x[j][1] += tmp1*im2;
             x[j][2] += tmp2*im2;
-        } /* 16 ncons flops */
+        }   /* 16 ncons flops */
     }
     else
     {
@@ -383,11 +456,12 @@ static void lincs_update_atoms_ind(int ncons, const int *ind, const int *bla,
             x[j][0] += tmp0;
             x[j][1] += tmp1;
             x[j][2] += tmp2;
-        } /* 16 ncons flops */
+        }   /* 16 ncons flops */
     }
 }
 
-static void lincs_update_atoms(gmx_lincsdata *li, int th,
+//! Update coordinates for atoms.
+static void lincs_update_atoms(Lincs *li, int th,
                                real prefac,
                                const real *fac, rvec *r,
                                const real *invmass,
@@ -425,11 +499,11 @@ static void lincs_update_atoms(gmx_lincsdata *li, int th,
 }
 
 #if GMX_SIMD_HAVE_REAL
-/* Calculate the constraint distance vectors r to project on from x.
+/*! \brief Calculate the constraint distance vectors r to project on from x.
+ *
  * Determine the right-hand side of the matrix equation using quantity f.
  * This function only differs from calc_dr_x_xp_simd below in that
- * no constraint length is subtracted and no PBC is used for f.
- */
+ * no constraint length is subtracted and no PBC is used for f. */
 static void gmx_simdcall
 calc_dr_x_f_simd(int                       b0,
                  int                       b1,
@@ -499,12 +573,12 @@ calc_dr_x_f_simd(int                       b0,
 }
 #endif // GMX_SIMD_HAVE_REAL
 
-/* LINCS projection, works on derivatives of the coordinates */
+/*! \brief LINCS projection, works on derivatives of the coordinates. */
 static void do_lincsp(rvec *x, rvec *f, rvec *fp, t_pbc *pbc,
-                      gmx_lincsdata *lincsd, int th,
+                      Lincs *lincsd, int th,
                       real *invmass,
-                      int econq, gmx_bool bCalcDHDL,
-                      gmx_bool bCalcVir, tensor rmdf)
+                      int econq, bool bCalcDHDL,
+                      bool bCalcVir, tensor rmdf)
 {
     int      b0, b1, b;
     int     *bla, *blnr, *blbnb;
@@ -552,7 +626,7 @@ static void do_lincsp(rvec *x, rvec *f, rvec *fp, t_pbc *pbc,
                      pbc_simd,
                      r, rhs1, sol);
 
-#else // GMX_SIMD_HAVE_REAL
+#else   // GMX_SIMD_HAVE_REAL
 
     /* Compute normalized i-j vectors */
     if (pbc)
@@ -573,7 +647,7 @@ static void do_lincsp(rvec *x, rvec *f, rvec *fp, t_pbc *pbc,
 
             rvec_sub(x[bla[2*b]], x[bla[2*b+1]], dx);
             unitv(dx, r[b]);
-        } /* 16 ncons flops */
+        }   /* 16 ncons flops */
     }
 
     for (b = b0; b < b1; b++)
@@ -591,7 +665,7 @@ static void do_lincsp(rvec *x, rvec *f, rvec *fp, t_pbc *pbc,
         /* 7 flops */
     }
 
-#endif // GMX_SIMD_HAVE_REAL
+#endif  // GMX_SIMD_HAVE_REAL
 
     if (lincsd->bTaskDep)
     {
@@ -608,8 +682,8 @@ static void do_lincsp(rvec *x, rvec *f, rvec *fp, t_pbc *pbc,
 
         for (n = blnr[b]; n < blnr[b+1]; n++)
         {
-            blcc[n] = blmf[n]*iprod(r[b], r[blbnb[n]]);
-        } /* 6 nr flops */
+            blcc[n] = blmf[n]*::iprod(r[b], r[blbnb[n]]);
+        }   /* 6 nr flops */
     }
     /* Together: 23*ncons + 6*nrtot flops */
 
@@ -676,14 +750,14 @@ static void do_lincsp(rvec *x, rvec *f, rvec *fp, t_pbc *pbc,
                     rmdf[i][j] += tmp1*r[b][j];
                 }
             }
-        } /* 23 ncons flops */
+        }   /* 23 ncons flops */
     }
 }
 
 #if GMX_SIMD_HAVE_REAL
-/* Calculate the constraint distance vectors r to project on from x.
- * Determine the right-hand side of the matrix equation using coordinates xp.
- */
+/*! \brief Calculate the constraint distance vectors r to project on from x.
+ *
+ * Determine the right-hand side of the matrix equation using coordinates xp. */
 static void gmx_simdcall
 calc_dr_x_xp_simd(int                       b0,
                   int                       b1,
@@ -755,7 +829,7 @@ calc_dr_x_xp_simd(int                       b0,
 }
 #endif // GMX_SIMD_HAVE_REAL
 
-/* Determine the distances and right-hand side for the next iteration */
+/*! \brief Determine the distances and right-hand side for the next iteration. */
 gmx_unused static void calc_dist_iter(
         int                       b0,
         int                       b1,
@@ -767,7 +841,7 @@ gmx_unused static void calc_dist_iter(
         real                      wfac,
         real * gmx_restrict       rhs,
         real * gmx_restrict       sol,
-        gmx_bool *                bWarn)
+        bool *                    bWarn)
 {
     int b;
 
@@ -786,7 +860,7 @@ gmx_unused static void calc_dist_iter(
             rvec_sub(xp[bla[2*b]], xp[bla[2*b+1]], dx);
         }
         len2  = len*len;
-        dlen2 = 2*len2 - norm2(dx);
+        dlen2 = 2*len2 - ::norm2(dx);
         if (dlen2 < wfac*len2)
         {
             /* not race free - see detailed comment in caller */
@@ -802,11 +876,11 @@ gmx_unused static void calc_dist_iter(
         }
         rhs[b]  = mvb;
         sol[b]  = mvb;
-    } /* 20*ncons flops */
+    }   /* 20*ncons flops */
 }
 
 #if GMX_SIMD_HAVE_REAL
-/* As the function above, but using SIMD intrinsics */
+/*! \brief As calc_dist_iter(), but using SIMD intrinsics. */
 static void gmx_simdcall
 calc_dist_iter_simd(int                       b0,
                     int                       b1,
@@ -818,7 +892,7 @@ calc_dist_iter_simd(int                       b0,
                     real                      wfac,
                     real * gmx_restrict       rhs,
                     real * gmx_restrict       sol,
-                    gmx_bool *                bWarn)
+                    bool *                    bWarn)
 {
     SimdReal        min_S(GMX_REAL_MIN);
     SimdReal        two_S(2.0);
@@ -887,14 +961,15 @@ calc_dist_iter_simd(int                       b0,
 }
 #endif // GMX_SIMD_HAVE_REAL
 
+//! Implements LINCS constraining.
 static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
-                     gmx_lincsdata *lincsd, int th,
+                     Lincs *lincsd, int th,
                      const real *invmass,
                      const t_commrec *cr,
-                     gmx_bool bCalcDHDL,
-                     real wangle, gmx_bool *bWarn,
+                     bool bCalcDHDL,
+                     real wangle, bool *bWarn,
                      real invdt, rvec * gmx_restrict v,
-                     gmx_bool bCalcVir, tensor vir_r_m_dr)
+                     bool bCalcVir, tensor vir_r_m_dr)
 {
     int      b0, b1, b, i, j, n, iter;
     int     *bla, *blnr, *blbnb;
@@ -938,7 +1013,7 @@ static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
                       pbc_simd,
                       r, rhs1, sol);
 
-#else // GMX_SIMD_HAVE_REAL
+#else   // GMX_SIMD_HAVE_REAL
 
     if (pbc)
     {
@@ -952,7 +1027,7 @@ static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
             unitv(dx, r[b]);
 
             pbc_dx_aiuc(pbc, xp[bla[2*b]], xp[bla[2*b+1]], dx);
-            mvb     = blc[b]*(iprod(r[b], dx) - bllen[b]);
+            mvb     = blc[b]*(::iprod(r[b], dx) - bllen[b]);
             rhs1[b] = mvb;
             sol[b]  = mvb;
         }
@@ -987,7 +1062,7 @@ static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
         /* Together: 26*ncons + 6*nrtot flops */
     }
 
-#endif // GMX_SIMD_HAVE_REAL
+#endif  // GMX_SIMD_HAVE_REAL
 
     if (lincsd->bTaskDep)
     {
@@ -1002,7 +1077,7 @@ static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
     {
         for (n = blnr[b]; n < blnr[b+1]; n++)
         {
-            blcc[n] = blmf[n]*iprod(r[b], r[blbnb[n]]);
+            blcc[n] = blmf[n]*::iprod(r[b], r[blbnb[n]]);
         }
     }
     /* Together: 26*ncons + 6*nrtot flops */
@@ -1022,7 +1097,7 @@ static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
     {
         mlambda[b] = blc[b]*sol[b];
     }
-#endif // GMX_SIMD_HAVE_REAL
+#endif  // GMX_SIMD_HAVE_REAL
 
     /* Update the coordinates */
     lincs_update_atoms(lincsd, th, 1.0, mlambda, r, invmass, xp);
@@ -1063,7 +1138,7 @@ static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
         calc_dist_iter(b0, b1, bla, xp, bllen, blc, pbc, wfac,
                        rhs1, sol, bWarn);
         /* 20*ncons flops */
-#endif  // GMX_SIMD_HAVE_REAL
+#endif      // GMX_SIMD_HAVE_REAL
 
         lincs_matrix_expand(lincsd, &lincsd->task[th], blcc, rhs1, rhs2, sol);
         /* nrec*(ncons+2*nrtot) flops */
@@ -1086,7 +1161,7 @@ static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
             blc_sol[b]  = mvb;
             mlambda[b] += mvb;
         }
-#endif  // GMX_SIMD_HAVE_REAL
+#endif      // GMX_SIMD_HAVE_REAL
 
         /* Update the coordinates */
         lincs_update_atoms(lincsd, th, 1.0, blc_sol, r, invmass, xp);
@@ -1146,7 +1221,7 @@ static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
                     vir_r_m_dr[i][j] -= tmp1*r[b][j];
                 }
             }
-        } /* 22 ncons flops */
+        }   /* 22 ncons flops */
     }
 
     /* Total:
@@ -1160,9 +1235,9 @@ static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
      */
 }
 
-/* Sets the elements in the LINCS matrix for task li_task */
-static void set_lincs_matrix_task(gmx_lincsdata        *li,
-                                  lincs_task_t         *li_task,
+/*! \brief Sets the elements in the LINCS matrix for task task. */
+static void set_lincs_matrix_task(Lincs                *li,
+                                  Task                 *li_task,
                                   const real           *invmass,
                                   int                  *ncc_triangle,
                                   int                  *nCrossTaskTriangles)
@@ -1256,8 +1331,8 @@ static void set_lincs_matrix_task(gmx_lincsdata        *li,
     }
 }
 
-/* Sets the elements in the LINCS matrix */
-static void set_lincs_matrix(gmx_lincsdata *li, real *invmass, real lambda)
+/*! \brief Sets the elements in the LINCS matrix. */
+static void set_lincs_matrix(Lincs *li, real *invmass, real lambda)
 {
     int        i;
     const real invsqrt2 = 0.7071067811865475244;
@@ -1308,13 +1383,14 @@ static void set_lincs_matrix(gmx_lincsdata *li, real *invmass, real lambda)
     li->matlam = lambda;
 }
 
+//! Finds all triangles of atoms that share constraints to a central atom.
 static int count_triangle_constraints(const t_ilist  *ilist,
                                       const t_blocka *at2con)
 {
     int      ncon1, ncon_tot;
     int      c0, a00, a01, n1, c1, a10, a11, ac1, n2, c2, a20, a21;
     int      ncon_triangle;
-    gmx_bool bTriangle;
+    bool     bTriangle;
     t_iatom *ia1, *ia2, *iap;
 
     ncon1    = ilist[F_CONSTR].nr/3;
@@ -1371,13 +1447,14 @@ static int count_triangle_constraints(const t_ilist  *ilist,
     return ncon_triangle;
 }
 
-static gmx_bool more_than_two_sequential_constraints(const t_ilist  *ilist,
-                                                     const t_blocka *at2con)
+//! Finds sequences of sequential constraints.
+static bool more_than_two_sequential_constraints(const t_ilist  *ilist,
+                                                 const t_blocka *at2con)
 {
     t_iatom  *ia1, *ia2, *iap;
     int       ncon1, ncon_tot, c;
     int       a1, a2;
-    gmx_bool  bMoreThanTwoSequentialConstraints;
+    bool      bMoreThanTwoSequentialConstraints;
 
     ncon1    = ilist[F_CONSTR].nr/3;
     ncon_tot = ncon1 + ilist[F_CONSTRNC].nr/3;
@@ -1402,17 +1479,18 @@ static gmx_bool more_than_two_sequential_constraints(const t_ilist  *ilist,
     return bMoreThanTwoSequentialConstraints;
 }
 
+//! Sorting helper function to compare two integers.
 static int int_comp(const void *a, const void *b)
 {
     return (*(int *)a) - (*(int *)b);
 }
 
-gmx_lincsdata_t init_lincs(FILE *fplog, const gmx_mtop_t *mtop,
-                           int nflexcon_global, const t_blocka *at2con,
-                           gmx_bool bPLINCS, int nIter, int nProjOrder)
+Lincs *init_lincs(FILE *fplog, const gmx_mtop_t *mtop,
+                  int nflexcon_global, const t_blocka *at2con,
+                  bool bPLINCS, int nIter, int nProjOrder)
 {
-    gmx_lincsdata        *li;
-    gmx_bool              bMoreThanTwoSeq;
+    Lincs                *li;
+    bool                  bMoreThanTwoSeq;
 
     if (fplog)
     {
@@ -1525,10 +1603,10 @@ gmx_lincsdata_t init_lincs(FILE *fplog, const gmx_mtop_t *mtop,
     return li;
 }
 
-/* Sets up the work division over the threads */
-static void lincs_thread_setup(gmx_lincsdata *li, int natoms)
+/*! \brief Sets up the work division over the threads. */
+static void lincs_thread_setup(Lincs *li, int natoms)
 {
-    lincs_task_t   *li_m;
+    Task           *li_m;
     int             th;
     gmx_bitmask_t  *atf;
     int             a;
@@ -1553,7 +1631,7 @@ static void lincs_thread_setup(gmx_lincsdata *li, int natoms)
 
     for (th = 0; th < li->ntask; th++)
     {
-        lincs_task_t *li_task;
+        Task         *li_task;
         int           b;
 
         li_task = &li->task[th];
@@ -1571,7 +1649,7 @@ static void lincs_thread_setup(gmx_lincsdata *li, int natoms)
     {
         try
         {
-            lincs_task_t  *li_task;
+            Task          *li_task;
             gmx_bitmask_t  mask;
             int            b;
 
@@ -1617,7 +1695,7 @@ static void lincs_thread_setup(gmx_lincsdata *li, int natoms)
     li_m->nind = 0;
     for (th = 0; th < li->ntask; th++)
     {
-        lincs_task_t *li_task;
+        Task         *li_task;
         int           b;
 
         li_task   = &li->task[th];
@@ -1647,7 +1725,7 @@ static void lincs_thread_setup(gmx_lincsdata *li, int natoms)
     }
 }
 
-/* There is no realloc with alignment, so here we make one for reals.
+/*! \brief There is no realloc with alignment, so here we make one for reals.
  * Note that this function does not preserve the contents of the memory.
  */
 static void resize_real_aligned(real **ptr, int nelem)
@@ -1656,7 +1734,8 @@ static void resize_real_aligned(real **ptr, int nelem)
     snew_aligned(*ptr, nelem, align_bytes);
 }
 
-static void assign_constraint(gmx_lincsdata *li,
+//! Assign a constraint.
+static void assign_constraint(Lincs *li,
                               int constraint_index,
                               int a1, int a2,
                               real lenA, real lenB,
@@ -1689,10 +1768,9 @@ static void assign_constraint(gmx_lincsdata *li,
     li->nc++;
 }
 
-/* Check if constraint with topology index constraint_index is connected
- * to other constraints, and if so add those connected constraints to our task.
- */
-static void check_assign_connected(gmx_lincsdata *li,
+/*! \brief Check if constraint with topology index constraint_index is connected
+ * to other constraints, and if so add those connected constraints to our task. */
+static void check_assign_connected(Lincs *li,
                                    const t_iatom *iatom,
                                    const t_idef *idef,
                                    int bDynamics,
@@ -1738,11 +1816,10 @@ static void check_assign_connected(gmx_lincsdata *li,
     }
 }
 
-/* Check if constraint with topology index constraint_index is involved
+/*! \brief Check if constraint with topology index constraint_index is involved
  * in a constraint triangle, and if so add the other two constraints
- * in the triangle to our task.
- */
-static void check_assign_triangle(gmx_lincsdata *li,
+ * in the triangle to our task. */
+static void check_assign_triangle(Lincs *li,
                                   const t_iatom *iatom,
                                   const t_idef *idef,
                                   int bDynamics,
@@ -1842,10 +1919,11 @@ static void check_assign_triangle(gmx_lincsdata *li,
     }
 }
 
-static void set_matrix_indices(gmx_lincsdata        *li,
-                               const lincs_task_t   *li_task,
+//! Sets matrix indices.
+static void set_matrix_indices(Lincs                *li,
+                               const Task           *li_task,
                                const t_blocka       *at2con,
-                               gmx_bool              bSortMatrix)
+                               bool                  bSortMatrix)
 {
     int b;
 
@@ -1889,9 +1967,9 @@ static void set_matrix_indices(gmx_lincsdata        *li,
 
 void set_lincs(const t_idef         *idef,
                const t_mdatoms      *md,
-               gmx_bool              bDynamics,
+               bool                  bDynamics,
                const t_commrec      *cr,
-               gmx_lincsdata        *li)
+               Lincs                *li)
 {
     int          natoms, nflexcon;
     t_blocka     at2con;
@@ -2012,7 +2090,7 @@ void set_lincs(const t_idef         *idef,
     con = 0;
     for (th = 0; th < li->ntask; th++)
     {
-        lincs_task_t *li_task;
+        Task *li_task;
 
         li_task = &li->task[th];
 
@@ -2032,7 +2110,7 @@ void set_lincs(const t_idef         *idef,
              */
             ncon_target = ((ncon_assign*(th + 1))/li->ntask - li->nc_real + GMX_SIMD_REAL_WIDTH - 1) & ~(GMX_SIMD_REAL_WIDTH - 1);
         }
-#endif  // GMX_SIMD==2 && GMX_SIMD_HAVE_REAL
+#endif      // GMX_SIMD==2 && GMX_SIMD_HAVE_REAL
 
         /* Continue filling the arrays where we left off with the previous task,
          * including padding for SIMD.
@@ -2113,7 +2191,7 @@ void set_lincs(const t_idef         *idef,
 
     assert(li->nc_real == ncon_assign);
 
-    gmx_bool bSortMatrix;
+    bool bSortMatrix;
 
     /* Without DD we order the blbnb matrix to optimize memory access.
      * With DD the overhead of sorting is more than the gain during access.
@@ -2131,7 +2209,7 @@ void set_lincs(const t_idef         *idef,
     {
         try
         {
-            lincs_task_t *li_task;
+            Task *li_task;
 
             li_task = &li->task[th];
 
@@ -2196,6 +2274,7 @@ void set_lincs(const t_idef         *idef,
     set_lincs_matrix(li, md->invmass, md->lambda);
 }
 
+//! Issues a warning when LINCS constraints cannot be satisfied.
 static void lincs_warning(FILE *fplog,
                           gmx_domdec_t *dd, rvec *x, rvec *xprime, t_pbc *pbc,
                           int ncons, int *bla, real *bllen, real wangle,
@@ -2233,7 +2312,7 @@ static void lincs_warning(FILE *fplog,
         }
         d0     = norm(v0);
         d1     = norm(v1);
-        cosine = iprod(v0, v1)/(d0*d1);
+        cosine = ::iprod(v0, v1)/(d0*d1);
         if (cosine < wfac)
         {
             sprintf(buf, " %6d %6d  %5.1f  %8.4f %8.4f    %8.4f\n",
@@ -2258,7 +2337,8 @@ static void lincs_warning(FILE *fplog,
     }
 }
 
-static void cconerr(const gmx_lincsdata *lincsd,
+//! Determine how well the constraints have been satisfied.
+static void cconerr(const Lincs *lincsd,
                     rvec *x, t_pbc *pbc,
                     real *ncons_loc, real *ssd, real *max, int *imax)
 {
@@ -2292,7 +2372,7 @@ static void cconerr(const gmx_lincsdata *lincsd,
             {
                 rvec_sub(x[bla[2*b]], x[bla[2*b+1]], dx);
             }
-            r2  = norm2(dx);
+            r2  = ::norm2(dx);
             len = r2*gmx::invsqrt(r2);
             d   = std::abs(len/bllen[b]-1);
             if (d > ma && (nlocat == nullptr || nlocat[b]))
@@ -2319,27 +2399,27 @@ static void cconerr(const gmx_lincsdata *lincsd,
     *imax      = im;
 }
 
-gmx_bool constrain_lincs(FILE *fplog, gmx_bool bLog, gmx_bool bEner,
-                         const t_inputrec *ir,
-                         gmx_int64_t step,
-                         gmx_lincsdata *lincsd, t_mdatoms *md,
-                         const t_commrec *cr,
-                         const gmx_multisim_t *ms,
-                         rvec *x, rvec *xprime, rvec *min_proj,
-                         matrix box, t_pbc *pbc,
-                         real lambda, real *dvdlambda,
-                         real invdt, rvec *v,
-                         gmx_bool bCalcVir, tensor vir_r_m_dr,
-                         int econq,
-                         t_nrnb *nrnb,
-                         int maxwarn, int *warncount)
+bool constrain_lincs(FILE *fplog, bool bLog, bool bEner,
+                     const t_inputrec *ir,
+                     gmx_int64_t step,
+                     Lincs *lincsd, t_mdatoms *md,
+                     const t_commrec *cr,
+                     const gmx_multisim_t *ms,
+                     rvec *x, rvec *xprime, rvec *min_proj,
+                     matrix box, t_pbc *pbc,
+                     real lambda, real *dvdlambda,
+                     real invdt, rvec *v,
+                     bool bCalcVir, tensor vir_r_m_dr,
+                     int econq,
+                     t_nrnb *nrnb,
+                     int maxwarn, int *warncount)
 {
     gmx_bool  bCalcDHDL;
     char      buf[STRLEN], buf2[22], buf3[STRLEN];
     int       i, p_imax;
     real      ncons_loc, p_ssd, p_max = 0;
     rvec      dx;
-    gmx_bool  bOK, bWarn;
+    bool      bOK, bWarn;
 
     bOK = TRUE;
 
@@ -2575,3 +2655,5 @@ gmx_bool constrain_lincs(FILE *fplog, gmx_bool bLog, gmx_bool bEner,
 
     return bOK;
 }
+
+} // namespace
index c51d3b6a630b24a7a5f8be6ce6deabc4cb7c734e..7e61f763454c6187e0cb3813e00ef9ea55161eae 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \libinternal \file
+ * \brief Declares interface to LINCS code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ * \inlibraryapi
+ */
 
 #ifndef GMX_MDLIB_LINCS_H
 #define GMX_MDLIB_LINCS_H
@@ -52,40 +60,47 @@ struct t_mdatoms;
 struct t_nrnb;
 struct t_pbc;
 
+namespace gmx
+{
+
 /* Abstract type for LINCS that is defined only in the file that uses it */
-typedef struct gmx_lincsdata *gmx_lincsdata_t;
+class Lincs;
 
-real *lincs_rmsd_data(gmx_lincsdata_t lincsd);
-/* Return the data for determining constraint RMS relative deviations */
+/*! \brief Return the data for determining constraint RMS relative deviations. */
+real *lincs_rmsd_data(Lincs *lincsd);
 
-real lincs_rmsd(gmx_lincsdata_t lincsd);
-/* Return the RMSD of the constraint */
+/*! \brief Return the RMSD of the constraint. */
+real lincs_rmsd(const Lincs *lincsd);
 
-gmx_lincsdata_t init_lincs(FILE *fplog, const gmx_mtop_t *mtop,
-                           int nflexcon_global, const t_blocka *at2con,
-                           gmx_bool bPLINCS, int nIter, int nProjOrder);
-/* Initializes and returns the lincs data struct */
+/*! \brief Initializes and returns the lincs data struct. */
+Lincs *init_lincs(FILE *fplog, const gmx_mtop_t *mtop,
+                  int nflexcon_global, const t_blocka *at2con,
+                  bool bPLINCS, int nIter, int nProjOrder);
 
+/*! \brief Initialize lincs stuff */
 void set_lincs(const t_idef *idef, const t_mdatoms *md,
-               gmx_bool bDynamics, const t_commrec *cr,
-               gmx_lincsdata_t li);
-/* Initialize lincs stuff */
+               bool bDynamics, const t_commrec *cr,
+               Lincs *li);
 
-gmx_bool
-constrain_lincs(FILE *log, gmx_bool bLog, gmx_bool bEner,
+/*! \brief Applies LINCS constraints.
+ *
+ * \returns true if the constraining succeeded. */
+bool
+constrain_lincs(FILE *log, bool bLog, bool bEner,
                 const t_inputrec *ir,
                 gmx_int64_t step,
-                gmx_lincsdata_t lincsd, t_mdatoms *md,
+                Lincs *lincsd, t_mdatoms *md,
                 const t_commrec *cr,
                 const gmx_multisim_t *ms,
                 rvec *x, rvec *xprime, rvec *min_proj,
                 matrix box, t_pbc *pbc,
                 real lambda, real *dvdlambda,
                 real invdt, rvec *v,
-                gmx_bool bCalcVir, tensor vir_r_m_dr,
+                bool bCalcVir, tensor vir_r_m_dr,
                 int econ,
                 t_nrnb *nrnb,
                 int maxwarn, int *warncount);
-/* Returns if the constraining succeeded */
+
+} // namespace
 
 #endif
index 5fff597b696c60d5a8db0ebbd0dea52b61205beb..7cf67001e15819c242430ab3697fc1a518dc2fcc 100644 (file)
@@ -153,7 +153,7 @@ void compute_globals(FILE *fplog, gmx_global_stat *gstat, t_commrec *cr, t_input
                      t_state *state, t_mdatoms *mdatoms,
                      t_nrnb *nrnb, t_vcm *vcm, gmx_wallcycle_t wcycle,
                      gmx_enerdata_t *enerd, tensor force_vir, tensor shake_vir, tensor total_vir,
-                     tensor pres, rvec mu_tot, struct gmx_constr *constr,
+                     tensor pres, rvec mu_tot, gmx::Constraints *constr,
                      gmx::SimulationSignaller *signalCoordinator,
                      matrix box, int *totalNumberOfBondedInteractions,
                      gmx_bool *bSumEkinhOld, int flags)
index e6b092da974e4384e2f71d782f4bbc5174fba0d3..828933e0d2b004aaeea2ecdc33ac9f3ea63ae8af 100644 (file)
@@ -40,7 +40,6 @@
 #include "gromacs/mdlib/vcm.h"
 #include "gromacs/timing/wallcycle.h"
 
-struct gmx_constr;
 struct gmx_ekindata_t;
 struct gmx_enerdata_t;
 struct gmx_global_stat;
@@ -56,6 +55,7 @@ struct t_trxframe;
 
 namespace gmx
 {
+class Constraints;
 class MDLogger;
 class SimulationSignaller;
 }
@@ -123,7 +123,7 @@ void compute_globals(FILE *fplog, gmx_global_stat *gstat, t_commrec *cr, t_input
                      t_state *state, t_mdatoms *mdatoms,
                      t_nrnb *nrnb, t_vcm *vcm, gmx_wallcycle_t wcycle,
                      gmx_enerdata_t *enerd, tensor force_vir, tensor shake_vir, tensor total_vir,
-                     tensor pres, rvec mu_tot, gmx_constr *constr,
+                     tensor pres, rvec mu_tot, gmx::Constraints *constr,
                      gmx::SimulationSignaller *signalCoordinator,
                      matrix box, int *totalNumberOfBondedInteractions,
                      gmx_bool *bSumEkinhOld, int flags);
index 199f1705daee78aeeb5aae7e33365aec26eb358b..a65791cf289d54823b3d9ef9fbce66a2c875dedc 100644 (file)
@@ -899,23 +899,23 @@ static void copy_energy(t_mdebin *md, real e[], real ecpy[])
     }
 }
 
-void upd_mdebin(t_mdebin       *md,
-                gmx_bool        bDoDHDL,
-                gmx_bool        bSum,
-                double          time,
-                real            tmass,
-                gmx_enerdata_t *enerd,
-                t_state        *state,
-                t_lambda       *fep,
-                t_expanded     *expand,
-                matrix          box,
-                tensor          svir,
-                tensor          fvir,
-                tensor          vir,
-                tensor          pres,
-                gmx_ekindata_t *ekind,
-                rvec            mu_tot,
-                gmx_constr_t    constr)
+void upd_mdebin(t_mdebin               *md,
+                gmx_bool                bDoDHDL,
+                gmx_bool                bSum,
+                double                  time,
+                real                    tmass,
+                gmx_enerdata_t         *enerd,
+                t_state                *state,
+                t_lambda               *fep,
+                t_expanded             *expand,
+                matrix                  box,
+                tensor                  svir,
+                tensor                  fvir,
+                tensor                  vir,
+                tensor                  pres,
+                gmx_ekindata_t         *ekind,
+                rvec                    mu_tot,
+                const gmx::Constraints *constr)
 {
     int    i, j, k, kk, n, gid;
     real   crmsd[2], tmp6[6];
@@ -934,7 +934,7 @@ void upd_mdebin(t_mdebin       *md,
     add_ebin(md->ebin, md->ie, md->f_nre, ecopy, bSum);
     if (md->nCrmsd)
     {
-        crmsd[0] = constr_rmsd(constr);
+        crmsd[0] = gmx::constr_rmsd(constr);
         add_ebin(md->ebin, md->iconrmsd, md->nCrmsd, crmsd, FALSE);
     }
     if (md->bDynBox)
index 6c062a01204933304c4532debefb65466d7633e4..2257451305faf4c9d917256f94b53011af51b424 100644 (file)
@@ -44,7 +44,6 @@
 #include "gromacs/mdtypes/forcerec.h"
 
 class energyhistory_t;
-struct gmx_constr;
 struct gmx_ekindata_t;
 struct gmx_mtop_t;
 struct gmx_output_env_t;
@@ -57,6 +56,7 @@ class t_state;
 namespace gmx
 {
 class Awh;
+class Constraints;
 }
 
 /* The functions & data structures here determine the content for outputting
@@ -149,7 +149,7 @@ void upd_mdebin(t_mdebin                 *md,
                 tensor                    pres,
                 gmx_ekindata_t           *ekind,
                 rvec                      mu_tot,
-                gmx_constr               *constr);
+                const gmx::Constraints   *constr);
 
 void upd_mdebin_step(t_mdebin *md);
 /* Updates only the step count in md */
index a70e7e2e46fa94c50f42822d5c36b0460f3478bb..04d27ec0414b8faf39d676f5f9c823441ce24a08 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \internal \file
+ * \brief Defines SETTLE code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ */
 #include "gmxpre.h"
 
 #include "settle.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/smalloc.h"
 
-using namespace gmx; // TODO: Remove when this file is moved into gmx namespace
+namespace gmx
+{
 
-typedef struct
+struct settleparam_t
 {
     real   mO;
     real   mH;
@@ -81,9 +89,9 @@ typedef struct
     real   invdOH;
     real   invdHH;
     matrix invmat;
-} settleparam_t;
+};
 
-typedef struct gmx_settledata
+struct settledata
 {
     settleparam_t massw;    /* Parameters for SETTLE for coordinates */
     settleparam_t mass1;    /* Parameters with all masses 1, for forces */
@@ -96,9 +104,10 @@ typedef struct gmx_settledata
     int           nalloc;   /* Allocation size of ow1, hw2, hw3, virfac */
 
     bool          bUseSimd; /* Use SIMD intrinsics code, if possible */
-} t_gmx_settledata;
+};
 
 
+//! Initializes a projection matrix.
 static void init_proj_matrix(real invmO, real invmH, real dOH, real dHH,
                              matrix inverseCouplingMatrix)
 {
@@ -127,6 +136,7 @@ static void init_proj_matrix(real invmO, real invmH, real dOH, real dHH,
     msmul(inverseCouplingMatrix, 1/invmO, inverseCouplingMatrix);
 }
 
+//! Initializes settle parameters.
 static void settleparam_init(settleparam_t *p,
                              real mO, real mH, real invmO, real invmH,
                              real dOH, real dHH)
@@ -169,7 +179,7 @@ static void settleparam_init(settleparam_t *p,
     }
 }
 
-gmx_settledata_t settle_init(const gmx_mtop_t *mtop)
+settledata *settle_init(const gmx_mtop_t *mtop)
 {
     /* Check that we have only one settle type */
     int                   settle_type = -1;
@@ -199,7 +209,7 @@ gmx_settledata_t settle_init(const gmx_mtop_t *mtop)
     }
     GMX_RELEASE_ASSERT(settle_type >= 0, "settle_init called without settles");
 
-    gmx_settledata_t settled;
+    settledata *settled;
 
     snew(settled, 1);
 
@@ -225,7 +235,7 @@ gmx_settledata_t settle_init(const gmx_mtop_t *mtop)
     return settled;
 }
 
-void settle_free(gmx_settledata_t settled)
+void settle_free(settledata *settled)
 {
     sfree_aligned(settled->ow1);
     sfree_aligned(settled->hw2);
@@ -234,7 +244,7 @@ void settle_free(gmx_settledata_t settled)
     sfree(settled);
 }
 
-void settle_set_constraints(gmx_settledata_t  settled,
+void settle_set_constraints(settledata       *settled,
                             const t_ilist    *il_settle,
                             const t_mdatoms  *mdatoms)
 {
@@ -305,7 +315,7 @@ void settle_set_constraints(gmx_settledata_t  settled,
     }
 }
 
-void settle_proj(gmx_settledata_t settled, int econq,
+void settle_proj(settledata *settled, int econq,
                  int nsettle, t_iatom iatoms[],
                  const t_pbc *pbc,
                  rvec x[],
@@ -411,12 +421,12 @@ void settle_proj(gmx_settledata_t settled, int econq,
 }
 
 
-/* The actual settle code, templated for real/SimdReal and for optimization */
+/*! \brief The actual settle code, templated for real/SimdReal and for optimization */
 template<typename T, typename TypeBool, int packSize,
          typename TypePbc,
          bool bCorrectVelocity,
          bool bCalcVirial>
-static void settleTemplate(const gmx_settledata_t settled,
+static void settleTemplate(const settledata *settled,
                            int settleStart, int settleEnd,
                            const TypePbc pbc,
                            const real *x, real *xprime,
@@ -442,20 +452,20 @@ static void settleTemplate(const gmx_settledata_t settled,
     assert(settleStart % packSize == 0);
     assert(settleEnd   % packSize == 0);
 
-    TypeBool       bError = TypeBool(false);
+    TypeBool             bError = TypeBool(false);
 
-    settleparam_t *p    = &settled->massw;
-    T              wh   = T(p->wh);
-    T              rc   = T(p->rc);
-    T              ra   = T(p->ra);
-    T              rb   = T(p->rb);
-    T              irc2 = T(p->irc2);
-    T              mO   = T(p->mO);
-    T              mH   = T(p->mH);
+    const settleparam_t *p    = &settled->massw;
+    T                    wh   = T(p->wh);
+    T                    rc   = T(p->rc);
+    T                    ra   = T(p->ra);
+    T                    rb   = T(p->rb);
+    T                    irc2 = T(p->irc2);
+    T                    mO   = T(p->mO);
+    T                    mH   = T(p->mH);
 
-    T              almost_zero = T(1e-12);
+    T                    almost_zero = T(1e-12);
 
-    T              sum_r_m_dr[DIM][DIM];
+    T                    sum_r_m_dr[DIM][DIM];
 
     if (bCalcVirial)
     {
@@ -760,11 +770,11 @@ static void settleTemplate(const gmx_settledata_t settled,
     *bErrorHasOccurred = anyTrue(bError);
 }
 
-/* Wrapper template function that divides the settles over threads
+/*! \brief Wrapper template function that divides the settles over threads
  * and instantiates the core template with instantiated booleans.
  */
 template<typename T, typename TypeBool, int packSize, typename TypePbc>
-static void settleTemplateWrapper(gmx_settledata_t settled,
+static void settleTemplateWrapper(settledata *settled,
                                   int nthread, int thread,
                                   TypePbc pbc,
                                   const real x[], real xprime[],
@@ -838,7 +848,7 @@ static void settleTemplateWrapper(gmx_settledata_t settled,
     }
 }
 
-void csettle(gmx_settledata_t settled,
+void csettle(settledata *settled,
              int nthread, int thread,
              const t_pbc *pbc,
              const real x[], real xprime[],
@@ -891,3 +901,5 @@ void csettle(gmx_settledata_t settled,
                                              bErrorHasOccurred);
     }
 }
+
+} // namespace
index f4ee93e930918b069a565227cd5d49ec9ad48972..c44771de87cd1fd513b7562c9ea05a587e8a947a 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \libinternal \file
+ * \brief Declares interface to SETTLE code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ * \inlibraryapi
+ */
 
 #ifndef GMX_MDLIB_SETTLE_H
 #define GMX_MDLIB_SETTLE_H
@@ -44,20 +52,27 @@ struct t_inputrec;
 struct t_mdatoms;
 struct t_pbc;
 
+namespace gmx
+{
+
 /* Abstract type for SETTLE that is defined only in the file that uses it */
-typedef struct gmx_settledata *gmx_settledata_t;
+struct settledata;
 
-gmx_settledata_t settle_init(const gmx_mtop_t *mtop);
-/* Initializes and returns a structure with SETTLE parameters */
+/*! \brief Initializes and returns a structure with SETTLE parameters */
+settledata *settle_init(const gmx_mtop_t *mtop);
 
-void settle_free(gmx_settledata_t settled);
+//! Cleans up.
+void settle_free(settledata *settled);
 
-void settle_set_constraints(gmx_settledata_t  settled,
+/*! \brief Set up the indices for the settle constraints */
+void settle_set_constraints(settledata       *settled,
                             const t_ilist    *il_settle,
                             const t_mdatoms  *mdatoms);
-/* Set up the indices for the settle constraints */
 
-void csettle(gmx_settledata_t    settled,          /* The SETTLE structure */
+/*! \brief Constrain coordinates using SETTLE.
+ * Can be called on any number of threads.
+ */
+void csettle(settledata         *settled,          /* The SETTLE structure */
              int                 nthread,          /* The number of threads used */
              int                 thread,           /* Our thread index */
              const t_pbc        *pbc,              /* PBC data pointer, can be NULL */
@@ -69,18 +84,17 @@ void csettle(gmx_settledata_t    settled,          /* The SETTLE structure */
              tensor              vir_r_m_dr,       /* sum r x m delta_r */
              bool               *bErrorHasOccurred /* True if a settle error occurred */
              );
-/* Constrain coordinates using SETTLE.
- * Can be called on any number of threads.
- */
 
-void settle_proj(gmx_settledata_t settled, int econq,
+/*! \brief Analytical algorithm to subtract the components of derivatives
+ * of coordinates working on settle type constraint.
+ */
+void settle_proj(settledata *settled, int econq,
                  int nsettle, t_iatom iatoms[],
                  const t_pbc *pbc,   /* PBC data pointer, can be NULL  */
                  rvec x[],
                  rvec *der, rvec *derp,
                  int CalcVirAtomEnd, tensor vir_r_m_dder);
-/* Analytical algorithm to subtract the components of derivatives
- * of coordinates working on settle type constraint.
- */
+
+} // namespace
 
 #endif
index 43d8f20457327c506eb2099311a28641ede1d48f..688cb0f9fbeb4192fce1a5b3b8ec6832dd466a94 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \internal \file
+ * \brief Defines SHAKE code.
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ */
 #include "gmxpre.h"
 
 #include "shake.h"
@@ -46,6 +54,7 @@
 #include "gromacs/gmxlib/nrnb.h"
 #include "gromacs/math/functions.h"
 #include "gromacs/math/vec.h"
+#include "gromacs/mdlib/constr.h"
 #include "gromacs/mdlib/splitter.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
 
-typedef struct gmx_shakedata
+namespace gmx
+{
+
+struct shakedata
 {
     rvec *rij;
     real *half_of_reduced_mass;
@@ -74,11 +86,11 @@ typedef struct gmx_shakedata
      * constraint distance. */
     real *scaled_lagrange_multiplier;
     int   lagr_nalloc;    /* The allocation size of scaled_lagrange_multiplier */
-} t_gmx_shakedata;
+};
 
-gmx_shakedata_t shake_init()
+shakedata *shake_init()
 {
-    gmx_shakedata_t d;
+    shakedata *d;
 
     snew(d, 1);
 
@@ -101,6 +113,7 @@ typedef struct {
     int blocknr;
 } t_sortblock;
 
+//! Compares sort blocks.
 static int pcomp(const void *p1, const void *p2)
 {
     int          db;
@@ -130,6 +143,7 @@ static int pcomp(const void *p1, const void *p2)
     }
 }
 
+//! Prints sortblocks
 static void pr_sortblock(FILE *fp, const char *title, int nsb, t_sortblock sb[])
 {
     int i;
@@ -143,7 +157,8 @@ static void pr_sortblock(FILE *fp, const char *title, int nsb, t_sortblock sb[])
     }
 }
 
-static void resizeLagrangianData(gmx_shakedata *shaked, int ncons)
+//! Reallocates a vector.
+static void resizeLagrangianData(shakedata *shaked, int ncons)
 {
     if (ncons > shaked->lagr_nalloc)
     {
@@ -153,7 +168,7 @@ static void resizeLagrangianData(gmx_shakedata *shaked, int ncons)
 }
 
 void
-make_shake_sblock_serial(gmx_shakedata *shaked,
+make_shake_sblock_serial(shakedata *shaked,
                          const t_idef *idef, const t_mdatoms *md)
 {
     int          i, j, m, ncons;
@@ -262,7 +277,7 @@ make_shake_sblock_serial(gmx_shakedata *shaked,
 }
 
 void
-make_shake_sblock_dd(gmx_shakedata *shaked,
+make_shake_sblock_dd(shakedata *shaked,
                      const t_ilist *ilcon, const t_block *cgs,
                      const gmx_domdec_t *dd)
 {
@@ -418,6 +433,7 @@ void cshake(const int iatom[], int ncon, int *nnit, int maxnit,
     *nerror = error;
 }
 
+//! Implements RATTLE (ie. SHAKE for velocity verlet integrators)
 static void
 crattle(int iatom[], int ncon, int *nnit, int maxnit,
         real constraint_distance_squared[], real vp[], real rij[], real m2[], real omega,
@@ -500,13 +516,14 @@ crattle(int iatom[], int ncon, int *nnit, int maxnit,
     *nerror = error;
 }
 
-static int vec_shakef(FILE *fplog, gmx_shakedata_t shaked,
+//! Applies SHAKE
+static int vec_shakef(FILE *fplog, shakedata *shaked,
                       const real invmass[], int ncon,
                       t_iparams ip[], t_iatom *iatom,
                       real tol, rvec x[], rvec prime[], real omega,
-                      gmx_bool bFEP, real lambda, real scaled_lagrange_multiplier[],
+                      bool bFEP, real lambda, real scaled_lagrange_multiplier[],
                       real invdt, rvec *v,
-                      gmx_bool bCalcVir, tensor vir_r_m_dr, int econq)
+                      bool bCalcVir, tensor vir_r_m_dr, int econq)
 {
     rvec    *rij;
     real    *half_of_reduced_mass, *distance_squared_tolerance, *constraint_distance_squared;
@@ -646,6 +663,7 @@ static int vec_shakef(FILE *fplog, gmx_shakedata_t shaked,
     return nit;
 }
 
+//! Check that constraints are satisfied.
 static void check_cons(FILE *log, int nc, rvec x[], rvec prime[], rvec v[],
                        t_iparams ip[], t_iatom *iatom,
                        const real invmass[], int econq)
@@ -688,13 +706,14 @@ static void check_cons(FILE *log, int nc, rvec x[], rvec prime[], rvec v[],
     }
 }
 
-static gmx_bool
-bshakef(FILE *log, gmx_shakedata_t shaked,
+//! Applies SHAKE.
+static bool
+bshakef(FILE *log, shakedata *shaked,
         const real invmass[],
         const t_idef *idef, const t_inputrec *ir, rvec x_s[], rvec prime[],
         t_nrnb *nrnb, real lambda, real *dvdlambda,
-        real invdt, rvec *v, gmx_bool bCalcVir, tensor vir_r_m_dr,
-        gmx_bool bDumpOnError, int econq)
+        real invdt, rvec *v, bool bCalcVir, tensor vir_r_m_dr,
+        bool bDumpOnError, int econq)
 {
     t_iatom *iatoms;
     real    *lam, dt_2, dvdl;
@@ -787,7 +806,7 @@ bshakef(FILE *log, gmx_shakedata_t shaked,
 
 bool
 constrain_shake(FILE             *log,
-                gmx_shakedata_t   shaked,
+                shakedata        *shaked,
                 const real        invmass[],
                 const t_idef     *idef,
                 const t_inputrec *ir,
@@ -799,9 +818,9 @@ constrain_shake(FILE             *log,
                 real             *dvdlambda,
                 real              invdt,
                 rvec             *v,
-                gmx_bool          bCalcVir,
+                bool              bCalcVir,
                 tensor            vir_r_m_dr,
-                gmx_bool          bDumpOnError,
+                bool              bDumpOnError,
                 int               econq)
 {
     if (shaked->nblocks == 0)
@@ -833,3 +852,5 @@ constrain_shake(FILE             *log,
     }
     return bOK;
 }
+
+} // namespace
index afa6b5e5c3cc321c0ae124bfbf818b55a5fdb451..6088bdac11e7c16a7d582cda66d332a75911607a 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \libinternal \file
+ * \brief Declares interface to SHAKE code.
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ * \inlibraryapi
+ */
 
 #ifndef GMX_MDLIB_SHAKE_H
 #define GMX_MDLIB_SHAKE_H
 
-#include "gromacs/mdlib/constr.h"
 #include "gromacs/topology/block.h"
 #include "gromacs/topology/idef.h"
 
 struct gmx_domdec_t;
 struct t_inputrec;
+struct t_mdatoms;
+struct t_nrnb;
+
+namespace gmx
+{
 
 /* Abstract type for SHAKE that is defined only in the file that uses it */
-typedef struct gmx_shakedata *gmx_shakedata_t;
+struct shakedata;
 
-gmx_shakedata_t shake_init();
-/* Initializes and return the SHAKE data structure */
+/*! \brief Initializes and return the SHAKE data structure */
+shakedata *shake_init();
 
+//! Make SHAKE blocks when not using DD.
 void
-make_shake_sblock_serial(gmx_shakedata *shaked,
+make_shake_sblock_serial(shakedata *shaked,
                          const t_idef *idef, const t_mdatoms *md);
 
+//! Make SHAKE blocks when using DD.
 void
-make_shake_sblock_dd(gmx_shakedata *shaked,
+make_shake_sblock_dd(shakedata *shaked,
                      const t_ilist *ilcon, const t_block *cgs,
                      const gmx_domdec_t *dd);
 
+/*! \brief Shake all the atoms blockwise. It is assumed that all the constraints
+ * in the idef->shakes field are sorted, to ascending block nr. The
+ * sblock array points into the idef->shakes.iatoms field, with block 0
+ * starting
+ * at sblock[0] and running to ( < ) sblock[1], block n running from
+ * sblock[n] to sblock[n+1]. Array sblock should be large enough.
+ * Return TRUE when OK, FALSE when shake-error
+ */
 bool
 constrain_shake(FILE             *log,          /* Log file                    */
-                gmx_shakedata_t   shaked,       /* Total number of atoms       */
+                shakedata        *shaked,       /* Total number of atoms       */
                 const real        invmass[],    /* Atomic masses               */
                 const t_idef     *idef,         /* The interaction def         */
                 const t_inputrec *ir,           /* Input record                        */
@@ -72,22 +95,16 @@ constrain_shake(FILE             *log,          /* Log file                 */
                 real             *dvdlambda,    /* FEP force                    */
                 real              invdt,        /* 1/delta_t                    */
                 rvec             *v,            /* Also constrain v if v!=NULL  */
-                gmx_bool          bCalcVir,     /* Calculate r x m delta_r      */
+                bool              bCalcVir,     /* Calculate r x m delta_r      */
                 tensor            vir_r_m_dr,   /* sum r x m delta_r            */
-                gmx_bool          bDumpOnError, /* Dump debugging stuff on error*/
+                bool              bDumpOnError, /* Dump debugging stuff on error*/
                 int               econq);       /* which type of constraint is occurring */
-/* Shake all the atoms blockwise. It is assumed that all the constraints
- * in the idef->shakes field are sorted, to ascending block nr. The
- * sblock array points into the idef->shakes.iatoms field, with block 0
- * starting
- * at sblock[0] and running to ( < ) sblock[1], block n running from
- * sblock[n] to sblock[n+1]. Array sblock should be large enough.
- * Return TRUE when OK, FALSE when shake-error
- */
 
+/*! \brief Regular iterative shake */
 void cshake(const int iatom[], int ncon, int *nnit, int maxnit,
             const real dist2[], real xp[], const real rij[], const real m2[], real omega,
             const real invmass[], const real tt[], real lagr[], int *nerror);
-/* Regular iterative shake */
+
+} // namespace
 
 #endif
index b57c3eed983d7f378a7fdd8f1caf237d0c6fcc68..4556ab99e2e2d867d27ad6fd7c773ea2172139ba 100644 (file)
@@ -890,7 +890,7 @@ static void dump_shells(FILE *fp, gmx::ArrayRef<gmx::RVec> x, gmx::ArrayRef<gmx:
 }
 
 static void init_adir(FILE *log, gmx_shellfc_t *shfc,
-                      gmx_constr_t constr, t_idef *idef, t_inputrec *ir,
+                      gmx::Constraints *constr, t_idef *idef, t_inputrec *ir,
                       const t_commrec *cr,
                       const gmx_multisim_t *ms,
                       int dd_ac1,
@@ -949,11 +949,11 @@ static void init_adir(FILE *log, gmx_shellfc_t *shfc,
     constrain(log, FALSE, FALSE, constr, idef, ir, cr, ms, step, 0, 1.0, md,
               x, xnold, nullptr, bMolPBC, box,
               lambda[efptBONDED], &(dvdlambda[efptBONDED]),
-              nullptr, nullptr, nrnb, econqCoord);
+              nullptr, nullptr, nrnb, gmx::econqCoord);
     constrain(log, FALSE, FALSE, constr, idef, ir, cr, ms, step, 0, 1.0, md,
               x, xnew, nullptr, bMolPBC, box,
               lambda[efptBONDED], &(dvdlambda[efptBONDED]),
-              nullptr, nullptr, nrnb, econqCoord);
+              nullptr, nullptr, nrnb, gmx::econqCoord);
 
     for (n = 0; n < end; n++)
     {
@@ -970,7 +970,7 @@ static void init_adir(FILE *log, gmx_shellfc_t *shfc,
     constrain(log, FALSE, FALSE, constr, idef, ir, cr, ms, step, 0, 1.0, md,
               x_old, xnew, acc_dir, bMolPBC, box,
               lambda[efptBONDED], &(dvdlambda[efptBONDED]),
-              nullptr, nullptr, nrnb, econqDeriv_FlexCon);
+              nullptr, nullptr, nrnb, gmx::econqDeriv_FlexCon);
 }
 
 void relax_shell_flexcon(FILE *fplog, const t_commrec *cr,
@@ -979,7 +979,7 @@ void relax_shell_flexcon(FILE *fplog, const t_commrec *cr,
                          gmx_int64_t mdstep, t_inputrec *inputrec,
                          gmx_bool bDoNS, int force_flags,
                          gmx_localtop_t *top,
-                         gmx_constr_t constr,
+                         gmx::Constraints *constr,
                          gmx_enerdata_t *enerd, t_fcdata *fcd,
                          t_state *state, PaddedRVecVector *f,
                          tensor force_vir,
index b15c3e17a861e31fd520c5b6005dc51e1770a8b3..95569432c3476fafc52fd353d2225889fb0d9855 100644 (file)
@@ -44,7 +44,6 @@
 #include "gromacs/mdlib/vsite.h"
 #include "gromacs/timing/wallcycle.h"
 
-struct gmx_constr;
 struct gmx_enerdata_t;
 struct gmx_groups_t;
 struct gmx_multisim_t;
@@ -56,6 +55,11 @@ struct t_graph;
 struct t_inputrec;
 class t_state;
 
+namespace gmx
+{
+class Constraints;
+}
+
 /* Initialization function, also predicts the initial shell postions.
  */
 gmx_shellfc_t *init_shell_flexcon(FILE *fplog,
@@ -74,7 +78,7 @@ void relax_shell_flexcon(FILE *log, const t_commrec *cr,
                          gmx_int64_t mdstep, t_inputrec *inputrec,
                          gmx_bool bDoNS, int force_flags,
                          gmx_localtop_t *top,
-                         gmx_constr *constr,
+                         gmx::Constraints *constr,
                          gmx_enerdata_t *enerd, t_fcdata *fcd,
                          t_state *state, PaddedRVecVector *f,
                          tensor force_vir,
index 5a82af6181bc807bc4c0ae0f5b56e793c77ea708..9d602459b0e283f8bc5d7e1a34dde256e5eaf49b 100644 (file)
@@ -2122,7 +2122,7 @@ void do_force(FILE *fplog, const t_commrec *cr,
 }
 
 
-void do_constrain_first(FILE *fplog, gmx_constr_t constr,
+void do_constrain_first(FILE *fplog, Constraints *constr,
                         t_inputrec *ir, t_mdatoms *md,
                         t_state *state, const t_commrec *cr,
                         const gmx_multisim_t *ms,
index d1b1c89102ecc9b68ec1c7c93a7685aec00175a1..88efbedf2065f81b942daa26f9b2278a151deabb 100644 (file)
@@ -45,7 +45,6 @@
 #include "gromacs/timing/walltime_accounting.h"
 #include "gromacs/utility/arrayref.h"
 
-struct gmx_constr;
 struct gmx_localtop_t;
 struct gmx_multisim_t;
 struct gmx_output_env_t;
@@ -57,6 +56,7 @@ struct t_nrnb;
 
 namespace gmx
 {
+class Constraints;
 class IMDOutputProvider;
 class MDLogger;
 }
@@ -92,7 +92,7 @@ void global_stat(gmx_global_stat_t gs,
                  tensor fvir, tensor svir, rvec mu_tot,
                  t_inputrec *inputrec,
                  gmx_ekindata_t *ekind,
-                 gmx_constr *constr, t_vcm *vcm,
+                 gmx::Constraints *constr, t_vcm *vcm,
                  int nsig, real *sig,
                  int *totalNumberOfBondedInteractions,
                  gmx_bool bSumEkinhOld, int flags);
@@ -137,7 +137,7 @@ void calc_dispcorr(t_inputrec *ir, t_forcerec *fr,
 
 void initialize_lambdas(FILE *fplog, t_inputrec *ir, int *fep_state, gmx::ArrayRef<real> lambda, double *lam0);
 
-void do_constrain_first(FILE *log, gmx_constr *constr,
+void do_constrain_first(FILE *log, gmx::Constraints *constr,
                         t_inputrec *inputrec, t_mdatoms *md,
                         t_state *state, const t_commrec *cr,
                         const gmx_multisim_t *ms,
index 1ac39954e4ca8c6bfefcf1f23da96cd74274c2c8..f1e7bd7f2028ffe649fe2c5e1510d7425360c11c 100644 (file)
@@ -140,7 +140,7 @@ void global_stat(gmx_global_stat_t gs,
                  const t_commrec *cr, gmx_enerdata_t *enerd,
                  tensor fvir, tensor svir, rvec mu_tot,
                  t_inputrec *inputrec,
-                 gmx_ekindata_t *ekind, gmx_constr_t constr,
+                 gmx_ekindata_t *ekind, gmx::Constraints *constr,
                  t_vcm *vcm,
                  int nsig, real *sig,
                  int *totalNumberOfBondedInteractions,
@@ -234,7 +234,7 @@ void global_stat(gmx_global_stat_t gs,
         ie  = add_binr(rb, nener, copyenerd);
         if (constr)
         {
-            rmsd_data = constr_rmsd_data(constr);
+            rmsd_data = gmx::constr_rmsd_data(constr);
             if (rmsd_data)
             {
                 irmsd = add_binr(rb, 2, rmsd_data);
index c10479a12a2af9fce145f00fb5c3c09d3b6d3d5a..42aeeb3b2abc5807f1c272eec1a81d69f454382b 100644 (file)
@@ -240,7 +240,7 @@ TEST_P(SettleTest, SatisfiesConstraints)
     mdatoms.homenr  = numSettles * atomsPerSettle;
 
     // Finally make the settle data structures
-    gmx_settledata_t settled = settle_init(&mtop);
+    settledata *settled = settle_init(&mtop);
     settle_set_constraints(settled, &mtop.moltype[0].ilist[F_SETTLE], &mdatoms);
 
     // Copy the original positions from the array of doubles to a vector of reals
index 4cc77911fd56f859557f72cfa1f4f6eed94da78d..f1fb6c2c999e910c8d0b0252424eaa704e7b76bd 100644 (file)
@@ -48,6 +48,8 @@
 #include "testutils/refdata.h"
 #include "testutils/testasserts.h"
 
+namespace gmx
+{
 namespace
 {
 
@@ -227,8 +229,8 @@ class ShakeTest : public ::testing::Test
             {
                 // We need to allow for the requested tolerance plus rounding
                 // errors due to the absolute size of the coordinate values
-                gmx::test::FloatingPointTolerance constraintTolerance =
-                    gmx::test::absoluteTolerance(std::sqrt(constrainedDistancesSquared[i])*ShakeTest::tolerance_ + coordMax*GMX_REAL_EPS);
+                test::FloatingPointTolerance constraintTolerance =
+                    test::absoluteTolerance(std::sqrt(constrainedDistancesSquared[i])*ShakeTest::tolerance_ + coordMax*GMX_REAL_EPS);
                 // Assert that the constrained distances are within the required tolerance
                 EXPECT_FLOAT_EQ_TOL(std::sqrt(constrainedDistancesSquared[i]),
                                     std::sqrt(finalDistancesSquared[i]),
@@ -357,3 +359,4 @@ TEST_F(ShakeTest, ConstrainsThreeBondsWithCommonAtoms)
 }
 
 } // namespace
+} // namespace
index bd6ca55cae356bd8600d075364545fe713aa2bdd..09428a4a3289de4e1899713c334d129dc4288d40 100644 (file)
@@ -1543,7 +1543,7 @@ void update_constraints(gmx_int64_t                    step,
                         t_nrnb                        *nrnb,
                         gmx_wallcycle_t                wcycle,
                         gmx_update_t                  *upd,
-                        gmx_constr_t                   constr,
+                        gmx::Constraints              *constr,
                         gmx_bool                       bFirstHalf,
                         gmx_bool                       bCalcVir)
 {
@@ -1860,7 +1860,7 @@ void update_coords(gmx_int64_t                    step,
                    gmx_update_t                  *upd,
                    int                            UpdatePart,
                    const t_commrec               *cr, /* these shouldn't be here -- need to think about it */
-                   gmx_constr_t                   constr)
+                   gmx::Constraints              *constr)
 {
     gmx_bool bDoConstr = (nullptr != constr);
 
@@ -1981,7 +1981,7 @@ void update_coords(gmx_int64_t                    step,
 }
 
 extern gmx_bool update_randomize_velocities(t_inputrec *ir, gmx_int64_t step, const t_commrec *cr,
-                                            t_mdatoms *md, t_state *state, gmx_update_t *upd, gmx_constr_t constr)
+                                            t_mdatoms *md, t_state *state, gmx_update_t *upd, gmx::Constraints *constr)
 {
 
     real rate = (ir->delta_t)/ir->opts.tau_t[0];
index 0d6c5a33d4331249f2fb1bbc1fef5628a34fa726..6d4787474624941ea257d10f84e247be1f26de10 100644 (file)
@@ -45,7 +45,6 @@
 #include "gromacs/utility/real.h"
 
 class ekinstate_t;
-struct gmx_constr;
 struct gmx_ekindata_t;
 struct gmx_enerdata_t;
 struct gmx_multisim_t;
@@ -62,6 +61,11 @@ class t_state;
 /* Abstract type for update */
 struct gmx_update_t;
 
+namespace gmx
+{
+class Constraints;
+}
+
 /* Initialize the stochastic dynamics struct */
 gmx_update_t *init_update(const t_inputrec *ir);
 
@@ -126,11 +130,11 @@ void update_coords(gmx_int64_t                    step,
                    gmx_update_t                  *upd,
                    int                            bUpdatePart,
                    const t_commrec               *cr, /* these shouldn't be here -- need to think about it */
-                   gmx_constr                    *constr);
+                   gmx::Constraints              *constr);
 
 /* Return TRUE if OK, FALSE in case of Shake Error */
 
-extern gmx_bool update_randomize_velocities(t_inputrec *ir, gmx_int64_t step, const t_commrec *cr, t_mdatoms *md, t_state *state, gmx_update_t *upd, gmx_constr *constr);
+extern gmx_bool update_randomize_velocities(t_inputrec *ir, gmx_int64_t step, const t_commrec *cr, t_mdatoms *md, t_state *state, gmx_update_t *upd, gmx::Constraints *constr);
 
 void update_constraints(gmx_int64_t              step,
                         real                    *dvdlambda, /* FEP stuff */
@@ -147,7 +151,7 @@ void update_constraints(gmx_int64_t              step,
                         t_nrnb                  *nrnb,
                         gmx_wallcycle_t          wcycle,
                         gmx_update_t            *upd,
-                        gmx_constr              *constr,
+                        gmx::Constraints        *constr,
                         gmx_bool                 bFirstHalf,
                         gmx_bool                 bCalcVir);
 
index 04ff880cbfba2657fa6e9d54a11dfdd27d1a8566..b6d115d39df1b2b0da3458e7e8433ed83060ec7f 100644 (file)
@@ -48,7 +48,6 @@
 #include "gromacs/utility/real.h"
 
 class energyhistory_t;
-struct gmx_constr;
 struct gmx_mtop_t;
 struct gmx_membed_t;
 struct gmx_multisim_t;
@@ -70,6 +69,7 @@ class t_state;
 namespace gmx
 {
 
+class Constraints;
 class IMDOutputProvider;
 class MDLogger;
 class MDAtoms;
@@ -123,7 +123,7 @@ struct Integrator
     //! Handles virtual sites.
     gmx_vsite_t                     *vsite;
     //! Handles constraints.
-    gmx_constr                      *constr;
+    Constraints                     *constr;
     //! Handles writing output files.
     IMDOutputProvider               *outputProvider;
     //! Contains user input mdp options.
index 158d941c893b40c9966db3b22517df06c921a42a..60f4f370e7e9e35ecbd3b3dfc552223291a3b26f 100644 (file)
@@ -332,7 +332,7 @@ static void init_em(FILE *fplog, const char *title,
                     t_nrnb *nrnb, rvec mu_tot,
                     t_forcerec *fr, gmx_enerdata_t **enerd,
                     t_graph **graph, gmx::MDAtoms *mdAtoms, gmx_global_stat_t *gstat,
-                    gmx_vsite_t *vsite, gmx_constr_t constr, gmx_shellfc_t **shellfc,
+                    gmx_vsite_t *vsite, gmx::Constraints *constr, gmx_shellfc_t **shellfc,
                     int nfile, const t_filenm fnm[],
                     gmx_mdoutf_t *outf, t_mdebin **mdebin,
                     gmx_wallcycle_t wcycle)
@@ -365,7 +365,7 @@ static void init_em(FILE *fplog, const char *title,
 
         *shellfc = init_shell_flexcon(stdout,
                                       top_global,
-                                      n_flexible_constraints(constr),
+                                      gmx::n_flexible_constraints(constr),
                                       ir->nstcalcenergy,
                                       DOMAINDECOMP(cr));
     }
@@ -448,7 +448,7 @@ static void init_em(FILE *fplog, const char *title,
                       nullptr,
                       fr->bMolPBC, ems->s.box,
                       ems->s.lambda[efptFEP], &dvdl_constr,
-                      nullptr, nullptr, nrnb, econqCoord);
+                      nullptr, nullptr, nrnb, gmx::econqCoord);
         }
     }
 
@@ -568,7 +568,7 @@ static bool do_em_step(const t_commrec *cr,
                        gmx_bool bMolPBC,
                        em_state_t *ems1, real a, const PaddedRVecVector *force,
                        em_state_t *ems2,
-                       gmx_constr_t constr, gmx_localtop_t *top,
+                       gmx::Constraints *constr, gmx_localtop_t *top,
                        t_nrnb *nrnb, gmx_wallcycle_t wcycle,
                        gmx_int64_t count)
 
@@ -681,7 +681,7 @@ static bool do_em_step(const t_commrec *cr,
                       as_rvec_array(s1->x.data()), as_rvec_array(s2->x.data()),
                       nullptr, bMolPBC, s2->box,
                       s2->lambda[efptBONDED], &dvdl_constr,
-                      nullptr, nullptr, nrnb, econqCoord);
+                      nullptr, nullptr, nrnb, gmx::econqCoord);
         wallcycle_stop(wcycle, ewcCONSTR);
 
         // We should move this check to the different minimizers
@@ -700,7 +700,7 @@ static void em_dd_partition_system(FILE *fplog, int step, const t_commrec *cr,
                                    gmx_mtop_t *top_global, t_inputrec *ir,
                                    em_state_t *ems, gmx_localtop_t *top,
                                    gmx::MDAtoms *mdAtoms, t_forcerec *fr,
-                                   gmx_vsite_t *vsite, gmx_constr_t constr,
+                                   gmx_vsite_t *vsite, gmx::Constraints *constr,
                                    t_nrnb *nrnb, gmx_wallcycle_t wcycle)
 {
     /* Repartition the domain decomposition */
@@ -770,7 +770,7 @@ class EnergyEvaluator
         //! Handles virtual sites.
         gmx_vsite_t          *vsite;
         //! Handles constraints.
-        gmx_constr_t          constr;
+        gmx::Constraints     *constr;
         //! Handles strange things.
         t_fcdata             *fcd;
         //! Molecular graph for SHAKE.
@@ -886,7 +886,7 @@ EnergyEvaluator::run(em_state_t *ems, rvec mu_tot,
                   as_rvec_array(ems->s.x.data()), f_rvec, f_rvec,
                   fr->bMolPBC, ems->s.box,
                   ems->s.lambda[efptBONDED], &dvdl_constr,
-                  nullptr, &shake_vir, nrnb, econqForceDispl);
+                  nullptr, &shake_vir, nrnb, gmx::econqForceDispl);
         enerd->term[F_DVDL_CONSTR] += dvdl_constr;
         m_add(force_vir, shake_vir, vir);
         wallcycle_stop(wcycle, ewcCONSTR);
index c38535970692f1c20815cbf43c61a0d2daa429d4..a6a62e2039fde56be3d90a23d83984a48a5b8ac2 100644 (file)
@@ -386,12 +386,11 @@ int Mdrunner::mdrunner()
     gmx_ddbox_t               ddbox = {0};
     int                       npme_major, npme_minor;
     t_nrnb                   *nrnb;
-    t_forcerec               *fr            = nullptr;
-    t_fcdata                 *fcd           = nullptr;
-    real                      ewaldcoeff_q  = 0;
-    real                      ewaldcoeff_lj = 0;
-    gmx_vsite_t              *vsite         = nullptr;
-    gmx_constr_t              constr;
+    t_forcerec               *fr               = nullptr;
+    t_fcdata                 *fcd              = nullptr;
+    real                      ewaldcoeff_q     = 0;
+    real                      ewaldcoeff_lj    = 0;
+    gmx_vsite_t              *vsite            = nullptr;
     int                       nChargePerturbed = -1, nTypePerturbed = 0;
     gmx_wallcycle_t           wcycle;
     gmx_walltime_accounting_t walltime_accounting = nullptr;
@@ -1284,9 +1283,9 @@ int Mdrunner::mdrunner()
         /* Let init_constraints know whether we have essential dynamics constraints.
          * TODO: inputrec should tell us whether we use an algorithm, not a file option or the checkpoint
          */
-        bool doEdsam = (opt2fn_null("-ei", nfile, fnm) != nullptr || observablesHistory.edsamHistory);
+        bool         doEdsam = (opt2fn_null("-ei", nfile, fnm) != nullptr || observablesHistory.edsamHistory);
 
-        constr = init_constraints(fplog, &mtop, inputrec, doEdsam, cr);
+        Constraints *constr = init_constraints(fplog, &mtop, inputrec, doEdsam, cr);
 
         if (DOMAINDECOMP(cr))
         {