From: Joe Jordan Date: Mon, 29 Mar 2021 08:35:17 +0000 (+0000) Subject: Move nsgrid header/source from mdlib to domdec X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=c5001464bb456f464ee6fc94e75c7cc4990a5139;p=alexxy%2Fgromacs.git Move nsgrid header/source from mdlib to domdec 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. --- diff --git a/src/gromacs/domdec/box.cpp b/src/gromacs/domdec/box.cpp index 8db33b3928..a614ebe202 100644 --- a/src/gromacs/domdec/box.cpp +++ b/src/gromacs/domdec/box.cpp @@ -52,10 +52,10 @@ #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); diff --git a/src/gromacs/mdlib/nsgrid.cpp b/src/gromacs/domdec/nsgrid.cpp similarity index 92% rename from src/gromacs/mdlib/nsgrid.cpp rename to src/gromacs/domdec/nsgrid.cpp index 4b821c6484..095a59d2aa 100644 --- a/src/gromacs/mdlib/nsgrid.cpp +++ b/src/gromacs/domdec/nsgrid.cpp @@ -49,6 +49,11 @@ #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, diff --git a/src/gromacs/mdlib/nsgrid.h b/src/gromacs/domdec/nsgrid.h similarity index 86% rename from src/gromacs/mdlib/nsgrid.h rename to src/gromacs/domdec/nsgrid.h index 421b917b30..58e27a6566 100644 --- a/src/gromacs/mdlib/nsgrid.h +++ b/src/gromacs/domdec/nsgrid.h @@ -37,19 +37,15 @@ #ifndef GMX_MDLIB_NSGRID_H #define GMX_MDLIB_NSGRID_H -#include - #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 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, diff --git a/src/gromacs/domdec/partition.cpp b/src/gromacs/domdec/partition.cpp index 7c821ef18b..23bd260326 100644 --- a/src/gromacs/domdec/partition.cpp +++ b/src/gromacs/domdec/partition.cpp @@ -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, diff --git a/src/gromacs/domdec/redistribute.cpp b/src/gromacs/domdec/redistribute.cpp index 0aaf1cdefd..53d5514c94 100644 --- a/src/gromacs/domdec/redistribute.cpp +++ b/src/gromacs/domdec/redistribute.cpp @@ -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"