Merge release-2018 into master
[alexxy/gromacs.git] / src / gromacs / mdlib / constr.cpp
index 8a15aad14c329d320674175511b9d3ec481052dd..71bb29eb5e5386b3b9a5c4e0a2cdb7aef165d591 100644 (file)
@@ -682,6 +682,28 @@ Constraints::Impl::apply(bool                  bLog,
     }
     wallcycle_stop(wcycle, ewcCONSTR);
 
+    if (v != nullptr && md.cFREEZE)
+    {
+        /* Set the velocities of frozen dimensions to zero */
+
+        // cppcheck-suppress unreadVariable
+        int gmx_unused numThreads = gmx_omp_nthreads_get(emntUpdate);
+
+#pragma omp parallel for num_threads(numThreads) schedule(static)
+        for (int i = 0; i < md.homenr; i++)
+        {
+            int freezeGroup = md.cFREEZE[i];
+
+            for (int d = 0; d < DIM; d++)
+            {
+                if (ir.opts.nFreeze[freezeGroup][d])
+                {
+                    v[i][d] = 0;
+                }
+            }
+        }
+    }
+
     return bOK;
 }