Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / pulling / pull_rotation.c
index 244e440953b88c02987fa3d3cc80838ebdad9dbf..dd74b44df552cf7ba942084e83cb17eb2dc805f6 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.
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
+
+#include "pull_rotation.h"
+
+#include "config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "domdec.h"
-#include "smalloc.h"
-#include "network.h"
-#include "pbc.h"
-#include "mdrun.h"
-#include "txtdump.h"
-#include "names.h"
-#include "mtop_util.h"
-#include "names.h"
-#include "nrjac.h"
-#include "vec.h"
-#include "gmx_ga2la.h"
-#include "xvgr.h"
-#include "copyrite.h"
-#include "macros.h"
-
-#include "gromacs/fileio/futil.h"
+
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/fileio/trnio.h"
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/legacyheaders/copyrite.h"
+#include "gromacs/legacyheaders/domdec.h"
+#include "gromacs/legacyheaders/gmx_ga2la.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/mdrun.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/legacyheaders/network.h"
+#include "gromacs/legacyheaders/txtdump.h"
+#include "gromacs/linearalgebra/nrjac.h"
+#include "gromacs/math/utilities.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/mdlib/groupcoord.h"
+#include "gromacs/pbcutil/pbc.h"
 #include "gromacs/timing/cyclecounter.h"
 #include "gromacs/timing/wallcycle.h"
+#include "gromacs/topology/mtop_util.h"
+#include "gromacs/utility/futil.h"
 #include "gromacs/utility/qsort_threadsafe.h"
-#include "gromacs/pulling/pull_rotation.h"
-#include "gromacs/mdlib/groupcoord.h"
+#include "gromacs/utility/smalloc.h"
 
 static char *RotStr = {"Enforced rotation:"};
 
@@ -941,7 +942,7 @@ static FILE *open_rot_out(const char *fn, t_rot *rot, const output_env_t oenv)
             add_to_string_aligned(&LegendStr, buf);
 
             sprintf(buf2, "%s (degrees)", buf);
-            setname[nsets] = strdup(buf2);
+            setname[nsets] = gmx_strdup(buf2);
             nsets++;
         }
         for (g = 0; g < rot->ngrp; g++)
@@ -961,19 +962,19 @@ static FILE *open_rot_out(const char *fn, t_rot *rot, const output_env_t oenv)
             }
             add_to_string_aligned(&LegendStr, buf);
             sprintf(buf2, "%s (degrees)", buf);
-            setname[nsets] = strdup(buf2);
+            setname[nsets] = gmx_strdup(buf2);
             nsets++;
 
             sprintf(buf, "tau%d", g);
             add_to_string_aligned(&LegendStr, buf);
             sprintf(buf2, "%s (kJ/mol)", buf);
-            setname[nsets] = strdup(buf2);
+            setname[nsets] = gmx_strdup(buf2);
             nsets++;
 
             sprintf(buf, "energy%d", g);
             add_to_string_aligned(&LegendStr, buf);
             sprintf(buf2, "%s (kJ/mol)", buf);
-            setname[nsets] = strdup(buf2);
+            setname[nsets] = gmx_strdup(buf2);
             nsets++;
         }
         fprintf(fp, "#\n");
@@ -1972,7 +1973,7 @@ static real do_flex2_lowlevel(
              * However, since the atom is located directly on the pivot, this
              * slab's contribution to the force on that atom will be zero
              * anyway. Therefore, we directly move on to the next slab.       */
-            if (0 == norm(tmpvec2) )
+            if (gmx_numzero(norm(tmpvec2))) /* 0 == norm(xj - xcn) */
             {
                 continue;
             }
@@ -2200,22 +2201,22 @@ static real do_flex_lowlevel(
 
             rvec_sub(yj0, ycn, yj0_ycn); /* yj0_ycn = yj0 - ycn */
 
-            /* Rotate: */
-            mvmul(erg->rotmat, yj0_ycn, tmpvec2); /* tmpvec2= Omega.(yj0-ycn) */
-
-            /* Subtract the slab center from xj */
-            rvec_sub(xj, xcn, xj_xcn);           /* xj_xcn = xj - xcn         */
-
-            /* In rare cases, when an atom position coincides with a slab center
-             * (xj_xcn == 0) we cannot compute the vector product for qjn.
+            /* In rare cases, when an atom position coincides with a reference slab
+             * center (yj0_ycn == 0) we cannot compute the normal vector qjn.
              * However, since the atom is located directly on the pivot, this
              * slab's contribution to the force on that atom will be zero
              * anyway. Therefore, we directly move on to the next slab.       */
-            if (0 == norm(xj_xcn) )
+            if (gmx_numzero(norm(yj0_ycn))) /* 0 == norm(yj0 - ycn) */
             {
                 continue;
             }
 
+            /* Rotate: */
+            mvmul(erg->rotmat, yj0_ycn, tmpvec2); /* tmpvec2= Omega.(yj0-ycn) */
+
+            /* Subtract the slab center from xj */
+            rvec_sub(xj, xcn, xj_xcn);           /* xj_xcn = xj - xcn         */
+
             /* Calculate qjn */
             cprod(rotg->vec, tmpvec2, tmpvec); /* tmpvec= v x Omega.(yj0-ycn) */
 
@@ -3346,7 +3347,7 @@ static void get_firstlast_slab_ref(t_rotgrp *rotg, real mc[], int ref_firstindex
 /* Special version of copy_rvec:
  * During the copy procedure of xcurr to b, the correct PBC image is chosen
  * such that the copied vector ends up near its reference position xref */
-static inline void copy_correct_pbc_image(
+static gmx_inline void copy_correct_pbc_image(
         const rvec  xcurr,  /* copy vector xcurr ...                */
         rvec        b,      /* ... to b ...                         */
         const rvec  xref,   /* choosing the PBC image such that b ends up near xref */