Clean up nbnxm bounding boxes
[alexxy/gromacs.git] / src / gromacs / nbnxm / grid.h
index 35a5266cc46068400dda3ae437dbf16be1c89622..23e0571ed42c2d29830d670f5d6094cf4aba2c94 100644 (file)
@@ -140,14 +140,22 @@ struct BoundingBox
     Corner upper; //!< upper, along x and y and z, corner
 };
 
+/*! \internal
+ * \brief Bounding box for one dimension of a grid cell
+ */
+struct BoundingBox1D
+{
+    float lower; //!< lower bound
+    float upper; //!< upper bound
+};
+
+/*! \brief The number of bounds along one dimension of a bounding box */
+static constexpr int c_numBoundingBoxBounds1D = 2;
 
 #ifndef DOXYGEN
 
 // TODO: Convert macros to constexpr int
 
-/* Pair search box lower and upper bound in z only. */
-#define NNBSBB_D         2
-
 /* Bounding box calculations are (currently) always in single precision, so
  * we only need to check for single precision support here.
  * This uses less (cache-)memory and SIMD is faster, at least on x86.
@@ -182,7 +190,7 @@ struct BoundingBox
 /* Store bounding boxes corners as quadruplets: xxxxyyyyzzzz */
 #    define NBNXN_BBXXXX  1
 /* Size of a quadruplet of bounding boxes, each 2 corners, stored packed */
-#    define NNBSBB_XXXX  (2*DIM*STRIDE_PBB)
+#    define NNBSBB_XXXX  (STRIDE_PBB*DIM*Nbnxm::c_numBoundingBoxBounds1D)
 
 #else  /* NBNXN_SEARCH_BB_SIMD4 */
 
@@ -362,7 +370,7 @@ class Grid
         }
 
         //! Returns the bounding boxes along z for all cells on the grid
-        gmx::ArrayRef<const float> zBoundingBoxes() const
+        gmx::ArrayRef<const BoundingBox1D> zBoundingBoxes() const
         {
             return bbcz_;
         }
@@ -475,7 +483,7 @@ class Grid
 
         /* Bounding boxes */
         //! Bounding boxes in z for the cells
-        std::vector<float>                                  bbcz_;
+        std::vector<BoundingBox1D>                          bbcz_;
         //! 3D bounding boxes for the sub cells
         std::vector < BoundingBox, gmx::AlignedAllocator < BoundingBox>> bb_;
         //! 3D j-bounding boxes for the case where the i- and j-cluster sizes are different