Introduce extractILists helper function
authorBerk Hess <hess@kth.se>
Mon, 17 Sep 2018 07:56:57 +0000 (09:56 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 18 Sep 2018 13:31:48 +0000 (15:31 +0200)
Change-Id: I768da6d065366992d556f0fa046b2ee28417e2fc

src/gromacs/topology/idef.h

index 9059e089e41569e534b88224a4986715bed2110f..f82c54c2d719d017914da2fa0ee11797df695385 100644 (file)
@@ -240,6 +240,36 @@ struct t_ilist
  *      identifier is an index in a params[] and functype[] array.
  */
 
+/*! \brief Type for returning a list of InteractionList references
+ *
+ * TODO: Remove when the function type is made part of InteractionList
+ */
+struct InteractionListHandle
+{
+    const int               functionType; //!< The function type
+    const std::vector<int> &iatoms;       //!< Reference to interaction list
+};
+
+/*! \brief Returns a list of all non-empty InteractionList entries with any of the interaction flags in \p flags set
+ *
+ * \param[in] ilists  Set of interaction lists
+ * \param[in] flags   Bit mask with one or more IF_... bits set
+ */
+static inline const std::vector<InteractionListHandle>
+extractILists(const InteractionLists &ilists,
+              int                     flags)
+{
+    std::vector<InteractionListHandle> handles;
+    for (size_t ftype = 0; ftype < ilists.size(); ftype++)
+    {
+        if ((interaction_function[ftype].flags & flags) && ilists[ftype].size() > 0)
+        {
+            handles.push_back({ static_cast<int>(ftype), ilists[ftype].iatoms });
+        }
+    }
+    return handles;
+}
+
 typedef struct
 {
     real *cmap; /* Has length 4*grid_spacing*grid_spacing, */