Added pullCheckPbcWithinGroup() to check one group
authorMagnus Lundborg <lundborg.magnus@gmail.com>
Tue, 25 Sep 2018 11:33:05 +0000 (13:33 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 26 Sep 2018 20:04:11 +0000 (22:04 +0200)
This function checks if a single group obeys PBC restrictions.

Change-Id: I26e99335c9d127ada1a229597bce489416b21408

src/gromacs/pulling/pull.h
src/gromacs/pulling/pullutil.cpp

index 9ea3eefe200d4d5b768c31ba4d5f4d85d6fcd990..89a9039bba0516519908ad6f58a5aa4ee6161cf6 100644 (file)
@@ -54,6 +54,7 @@
 
 #include "gromacs/math/vectypes.h"
 #include "gromacs/mdtypes/pull-params.h"
+#include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/real.h"
 
@@ -314,6 +315,32 @@ int pullCheckPbcWithinGroups(const pull_t &pull,
                              const t_pbc  &pbc,
                              real          pbcMargin);
 
+/*! \brief Checks whether a specific group that uses a reference atom is within PBC restrictions
+ *
+ * Groups that use a reference atom for determining PBC should have all their
+ * atoms within half the box size from the PBC atom. The box size is used
+ * per dimension for rectangular boxes, but can be a combination of
+ * dimensions for triclinic boxes, depending on which dimensions are
+ * involved in the pull coordinates a group is involved in. A margin is specified
+ * to ensure that atoms are not too close to the maximum distance. Only one group is
+ * checked.
+ *
+ * Should be called without MPI parallelization and after pull_calc_coms()
+ * has been called at least once.
+ *
+ * \param[in] pull       The pull data structure
+ * \param[in] x          The coordinates
+ * \param[in] pbc        Information struct about periodicity
+ * \param[in] groupNr    The index of the group (in pull.group[]) to check
+ * \param[in] pbcMargin  The minimum margin (as a fraction) to half the box size
+ * \returns true if the group obeys PBC otherwise false
+ */
+bool pullCheckPbcWithinGroup(const pull_t                  &pull,
+                             gmx::ArrayRef<const gmx::RVec> x,
+                             const t_pbc                   &pbc,
+                             int                            groupNr,
+                             real                           pbcMargin);
+
 /*! \brief Returns if we have pull coordinates with potential pulling.
  *
  * \param[in] pull     The pull data structure.
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));
+}