Fixed bug in parallel v/f constraining
authorBerk Hess <hess@kth.se>
Mon, 17 Mar 2014 15:48:53 +0000 (16:48 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sun, 23 Mar 2014 10:58:30 +0000 (11:58 +0100)
Constraining v or f with 3 or more decomposition domains in one
or more dimensions could lead to modification of communicated
v and f components by the box size for inter charge-group constraints.
Fixes #1462

Change-Id: Idece9d2d0d8f48e65a654d5c2892fbe1ff836ba0

include/domdec.h
src/mdlib/clincs.c
src/mdlib/constr.c
src/mdlib/domdec_con.c

index e94139b3a6b0b8523b0164e3d35726668e189387..6b41839b6ed59bdd870cad95251ed9a5c0b537b0 100644 (file)
@@ -243,8 +243,8 @@ void dd_move_f_vsites(gmx_domdec_t *dd, rvec *f, rvec *fshift);
 void dd_clear_f_vsites(gmx_domdec_t *dd, rvec *f);
 
 void dd_move_x_constraints(gmx_domdec_t *dd, matrix box,
-                           rvec *x0, rvec *x1);
-/* Move x0 and also x1 if x1!=NULL */
+                           rvec *x0, rvec *x1, gmx_bool bX1IsCoord);
+/* Move x0 and also x1 if x1!=NULL. bX1IsCoord tells if to do PBC on x1 */
 
 void dd_move_x_vsites(gmx_domdec_t *dd, matrix box, rvec *x);
 
index db31dea0403ce1523cbb867e65b2d666f6d36a11..c1a7ba196cd1c7d9b8c6773458f8adfc5e4422e0 100644 (file)
@@ -631,7 +631,7 @@ static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
                 /* Communicate the corrected non-local coordinates */
                 if (DOMAINDECOMP(cr))
                 {
-                    dd_move_x_constraints(cr->dd, box, xp, NULL);
+                    dd_move_x_constraints(cr->dd, box, xp, NULL, FALSE);
                 }
                 else
                 {
index 0e1a6ee524089e1867cc68db7995b81821178c11..a5e1754373791c8cc0709023446f2c2ddef2659b 100644 (file)
@@ -415,7 +415,7 @@ gmx_bool constrain(FILE *fplog, gmx_bool bLog, gmx_bool bEner,
      */
     if (cr->dd)
     {
-        dd_move_x_constraints(cr->dd, box, x, xprime);
+        dd_move_x_constraints(cr->dd, box, x, xprime, econq == econqCoord);
     }
     else if (PARTDECOMP(cr))
     {
index 773c61ec6690782d4b2381e8da5bf3d706f93968..dae0764abd4252f9c5207e22573286268c8b8590 100644 (file)
@@ -236,7 +236,9 @@ void dd_clear_f_vsites(gmx_domdec_t *dd, rvec *f)
 }
 
 static void dd_move_x_specat(gmx_domdec_t *dd, gmx_domdec_specat_comm_t *spac,
-                             matrix box, rvec *x0, rvec *x1)
+                             matrix box,
+                             rvec *x0,
+                             rvec *x1, gmx_bool bX1IsCoord)
 {
     gmx_specatsend_t *spas;
     rvec             *x, *vbuf, *rbuf;
@@ -245,7 +247,7 @@ static void dd_move_x_specat(gmx_domdec_t *dd, gmx_domdec_specat_comm_t *spac,
     rvec              shift = {0, 0, 0};
 
     nvec = 1;
-    if (x1)
+    if (x1 != NULL)
     {
         nvec++;
     }
@@ -285,7 +287,7 @@ static void dd_move_x_specat(gmx_domdec_t *dd, gmx_domdec_specat_comm_t *spac,
                 {
                     x = (v == 0 ? x0 : x1);
                     /* Copy the required coordinates to the send buffer */
-                    if (!bPBC)
+                    if (!bPBC || (v == 1 && !bX1IsCoord))
                     {
                         /* Only copy */
                         for (i = 0; i < spas->nsend; i++)
@@ -414,11 +416,12 @@ static void dd_move_x_specat(gmx_domdec_t *dd, gmx_domdec_specat_comm_t *spac,
     }
 }
 
-void dd_move_x_constraints(gmx_domdec_t *dd, matrix box, rvec *x0, rvec *x1)
+void dd_move_x_constraints(gmx_domdec_t *dd, matrix box,
+                           rvec *x0, rvec *x1, gmx_bool bX1IsCoord)
 {
     if (dd->constraint_comm)
     {
-        dd_move_x_specat(dd, dd->constraint_comm, box, x0, x1);
+        dd_move_x_specat(dd, dd->constraint_comm, box, x0, x1, bX1IsCoord);
     }
 }
 
@@ -426,7 +429,7 @@ void dd_move_x_vsites(gmx_domdec_t *dd, matrix box, rvec *x)
 {
     if (dd->vsite_comm)
     {
-        dd_move_x_specat(dd, dd->vsite_comm, box, x, NULL);
+        dd_move_x_specat(dd, dd->vsite_comm, box, x, NULL, FALSE);
     }
 }