Added pullCheckPbcWithinGroup() to check one group
[alexxy/gromacs.git] / src / gromacs / pulling / pullutil.cpp
index 8280f6d61fe235993ca43c634d7ae36dd57e01aa..b771a60b034683893bd8a19aa212f2c9597a3ee3 100644 (file)
@@ -934,3 +934,46 @@ int pullCheckPbcWithinGroups(const pull_t &pull,
 
     return -1;
 }
+
+bool pullCheckPbcWithinGroup(const pull_t                  &pull,
+                             gmx::ArrayRef<const gmx::RVec> x,
+                             const t_pbc                   &pbc,
+                             int                            groupNr,
+                             real                           pbcMargin)
+{
+    if (pbc.ePBC == epbcNONE)
+    {
+        return true;
+    }
+    GMX_ASSERT(groupNr < static_cast<int>(pull.group.size()), "groupNr is out of range");
+
+    /* Check PBC if the group uses a PBC reference atom treatment. */
+    const pull_group_work_t &group = pull.group[groupNr];
+    if (group.epgrppbc != epgrppbcREFAT)
+    {
+        return true;
+    }
+
+    /* Determine what dimensions are used for each group by pull coordinates */
+    BoolVec dimUsed = { false, false, false };
+    for (size_t c = 0; c < pull.coord.size(); c++)
+    {
+        const t_pull_coord &coordParams = pull.coord[c].params;
+        for (int groupIndex = 0; groupIndex < coordParams.ngroup; groupIndex++)
+        {
+            if (coordParams.group[groupIndex] == groupNr)
+            {
+                for (int d = 0; d < DIM; d++)
+                {
+                    if (coordParams.dim[d] &&
+                        !(coordParams.eGeom == epullgCYL && groupIndex == 0))
+                    {
+                        dimUsed[d] = true;
+                    }
+                }
+            }
+        }
+    }
+
+    return (pullGroupObeysPbcRestrictions(group, dimUsed, as_rvec_array(x.data()), pbc, pull.comm.pbcAtomBuffer[groupNr], pbcMargin));
+}