Adds cut-off checks for triclinic domain decomposition
[alexxy/gromacs.git] / src / mdlib / domdec_setup.c
index 0e2eb9b012956a261d6a85985017e311f9ae8567..d02c25be8ce22135abf661df50371378961990c4 100644 (file)
@@ -361,11 +361,16 @@ static float comm_cost_est(gmx_domdec_t *dd, real limit, real cutoff,
     {
         bt[i] = ddbox->box_size[i]*ddbox->skew_fac[i];
 
-        /* Without PBC there are no cell size limits with 2 cells */
+        /* Without PBC and with 2 cells, there are no lower limits on the cell size */
         if (!(i >= ddbox->npbcdim && nc[i] <= 2) && bt[i] < nc[i]*limit)
         {
             return -1;
         }
+        /* With PBC, check if the cut-off fits in nc[i]-1 cells */
+        if (i < ddbox->npbcdim && nc[i] > 1 && (nc[i] - 1)*bt[i] < nc[i]*cutoff)
+        {
+            return -1;
+        }
     }
 
     if (npme_tot > 1)