Move nsgrid header/source from mdlib to domdec
authorJoe Jordan <ejjordan12@gmail.com>
Mon, 29 Mar 2021 08:35:17 +0000 (08:35 +0000)
committerMark Abraham <mark.j.abraham@gmail.com>
Mon, 29 Mar 2021 08:35:17 +0000 (08:35 +0000)
The function get_nsgrid_boundaries is only called in domdec module
so it should live there. Removed an unused constant and moved another
to the source which is the only consumer. Also removed a todo which
no longer makes sense.

src/gromacs/domdec/box.cpp
src/gromacs/domdec/nsgrid.cpp [moved from src/gromacs/mdlib/nsgrid.cpp with 92% similarity]
src/gromacs/domdec/nsgrid.h [moved from src/gromacs/mdlib/nsgrid.h with 86% similarity]
src/gromacs/domdec/partition.cpp
src/gromacs/domdec/redistribute.cpp

index 8db33b3928aa6ec3ada55c308fe7c666e6bb819d..a614ebe2026b1637327b224684a326ce5d65f771 100644 (file)
 #include "gromacs/domdec/domdec.h"
 #include "gromacs/domdec/domdec_network.h"
 #include "gromacs/domdec/domdec_struct.h"
+#include "gromacs/domdec/nsgrid.h"
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/math/functions.h"
 #include "gromacs/math/vec.h"
-#include "gromacs/mdlib/nsgrid.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/pbcutil/pbc.h"
@@ -254,14 +254,14 @@ static void low_set_ddbox(int                            numPbcDimensions,
     {
         calc_pos_av_stddev(x, av, stddev, mpiCommunicator);
 
-        /* GRID_STDDEV_FAC * stddev
+        /* c_gridStdDevFactor * stddev
          * gives a uniform load for a rectangular block of cg's.
          * For a sphere it is not a bad approximation for 4x1x1 up to 4x2x2.
          */
         for (int d = ddbox->nboundeddim; d < DIM; d++)
         {
-            const real b0 = av[d] - GRID_STDDEV_FAC * stddev[d];
-            const real b1 = av[d] + GRID_STDDEV_FAC * stddev[d];
+            const real b0 = av[d] - c_gridStdDevFactor * stddev[d];
+            const real b1 = av[d] + c_gridStdDevFactor * stddev[d];
             if (debug)
             {
                 fprintf(debug, "Setting global DD grid boundaries to %f - %f\n", b0, b1);
similarity index 92%
rename from src/gromacs/mdlib/nsgrid.cpp
rename to src/gromacs/domdec/nsgrid.cpp
index 4b821c6484e66d4dec2bfb5376047da4a1847d91..095a59d2aa6f57e9b15a03a540c9681548057d86 100644 (file)
 #include "gromacs/math/vec.h"
 #include "gromacs/utility/fatalerror.h"
 
+/*! \brief The extent of the neighborsearch grid is a bit larger than sqrt(3)
+ * to account for less dense regions at the edges of the system.
+ */
+constexpr real c_stdDevFactor = 2.0;
+
 /***********************************
  *         Grid Routines
  ***********************************/
@@ -89,11 +94,11 @@ static void get_nsgrid_boundaries_vac(real av, real stddev, real* bound0, real*
      * For a sphere stddev is r/sqrt(5): 99.2% falls within the width.
      * For a Gaussian distribution 98% fall within the width.
      */
-    *bound0 = av - NSGRID_STDDEV_FAC * stddev;
-    *bound1 = av + NSGRID_STDDEV_FAC * stddev;
+    *bound0 = av - c_stdDevFactor * stddev;
+    *bound1 = av + c_stdDevFactor * stddev;
 
-    *bdens0 = av - GRID_STDDEV_FAC * stddev;
-    *bdens1 = av + GRID_STDDEV_FAC * stddev;
+    *bdens0 = av - c_gridStdDevFactor * stddev;
+    *bdens1 = av + c_gridStdDevFactor * stddev;
 }
 
 static void dd_box_bounds_to_ns_bounds(real box0, real box_size, real* gr0, real* gr1)
@@ -102,10 +107,10 @@ static void dd_box_bounds_to_ns_bounds(real box0, real box_size, real* gr0, real
 
     /* Redetermine av and stddev from the DD box boundaries */
     av     = box0 + 0.5 * box_size;
-    stddev = 0.5 * box_size / GRID_STDDEV_FAC;
+    stddev = 0.5 * box_size / c_gridStdDevFactor;
 
-    *gr0 = av - NSGRID_STDDEV_FAC * stddev;
-    *gr1 = av + NSGRID_STDDEV_FAC * stddev;
+    *gr0 = av - c_stdDevFactor * stddev;
+    *gr1 = av + c_stdDevFactor * stddev;
 }
 
 void get_nsgrid_boundaries(int           nboundeddim,
similarity index 86%
rename from src/gromacs/mdlib/nsgrid.h
rename to src/gromacs/domdec/nsgrid.h
index 421b917b309f68e9a4bf73446a55bdfee31670d0..58e27a6566a13b9ab2e68838fdd32b41343b3edd 100644 (file)
 #ifndef GMX_MDLIB_NSGRID_H
 #define GMX_MDLIB_NSGRID_H
 
-#include <cstdio>
-
 #include "gromacs/math/vectypes.h"
 #include "gromacs/utility/real.h"
 
 struct gmx_domdec_t;
-struct gmx_domdec_zones_t;
 struct gmx_ddbox_t;
-struct t_forcerec;
 
 /*! \brief Used when estimating the interaction density.
  *
- * GRID_STDDEV_FAC * stddev estimates the interaction density. The
+ * c_gridStdDevFactor * stddev estimates the interaction density. The
  * value sqrt(3) == 1.73205080757 gives a uniform load for a
  * rectangular 3D block of charge groups. For a sphere, it is not a
  * bad approximation for 4x1x1 up to 4x2x2.
@@ -57,17 +53,7 @@ struct t_forcerec;
  * \todo It would be nicer to use sqrt(3) here, when all code that
  * includes this file is in C++, which will let us cope with the
  * std::sqrt<T> on Windows. */
-static const real GRID_STDDEV_FAC = 1.73205080757;
-
-/*! \brief The extent of the neighborsearch grid is a bit larger than sqrt(3)
- * to account for less dense regions at the edges of the system.
- */
-static const real NSGRID_STDDEV_FAC = 2.0;
-
-#define NSGRID_SIGNAL_MOVED_FAC 4
-/* A cell index of NSGRID_SIGNAL_MOVED_FAC*ncells signals
- * that a charge group moved to another DD domain.
- */
+constexpr real c_gridStdDevFactor = 1.73205080757;
 
 void get_nsgrid_boundaries(int                  nboundeddim,
                            matrix               box,
index 7c821ef18be1bba26b0f5139e41724abe1dbc741..23bd260326a97ef09fcf5d7666ab499da38c76f2 100644 (file)
@@ -60,6 +60,7 @@
 #include "gromacs/domdec/ga2la.h"
 #include "gromacs/domdec/localatomsetmanager.h"
 #include "gromacs/domdec/mdsetup.h"
+#include "gromacs/domdec/nsgrid.h"
 #include "gromacs/ewald/pme_pp.h"
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/gmxlib/nrnb.h"
@@ -69,7 +70,6 @@
 #include "gromacs/mdlib/forcerec.h"
 #include "gromacs/mdlib/gmx_omp_nthreads.h"
 #include "gromacs/mdlib/mdatoms.h"
-#include "gromacs/mdlib/nsgrid.h"
 #include "gromacs/mdlib/vsite.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/mdtypes/forcerec.h"
@@ -3079,7 +3079,6 @@ void dd_partition_system(FILE*                     fplog,
         wallcycle_sub_stop(wcycle, ewcsDD_REDIST);
     }
 
-    // TODO: Integrate this code in the nbnxm module
     get_nsgrid_boundaries(ddbox.nboundeddim,
                           state_local->box,
                           dd,
index 0aaf1cdefd2f64f30e105e6b200f26fdf8405046..53d5514c9481d7c47ee8d9073b16051b3e766beb 100644 (file)
@@ -54,7 +54,6 @@
 #include "gromacs/gmxlib/nrnb.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/mdlib/gmx_omp_nthreads.h"
-#include "gromacs/mdlib/nsgrid.h"
 #include "gromacs/mdtypes/forcerec.h"
 #include "gromacs/mdtypes/nblist.h"
 #include "gromacs/mdtypes/state.h"