]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add manifold ID iterator filter predicate
authorJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 30 Dec 2021 06:56:21 +0000 (07:56 +0100)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 30 Dec 2021 08:05:16 +0000 (09:05 +0100)
include/deal.II/grid/filtered_iterator.h

index 3fa12229ecd78a7bf1af7ba1d13bd1d93d24f45d..9f202eac461e015b13181f6dd083eb02e26e5ee4 100644 (file)
@@ -366,6 +366,44 @@ namespace IteratorFilters
      */
     const std::set<types::boundary_id> boundary_ids;
   };
+
+
+  /**
+   * Filter for iterators that evaluates to true if the iterator of the object
+   * pointed to is equal to a value or set of values given to the constructor,
+   * assuming that the iterator allows querying for a manifold id.
+   *
+   * @ingroup Iterators
+   */
+  class ManifoldIdEqualTo
+  {
+  public:
+    /**
+     * Constructor. Store the boundary id which iterators shall have to be
+     * evaluated to true.
+     */
+    ManifoldIdEqualTo(const types::manifold_id manifold_id);
+
+    /**
+     * Constructor. Store a collection of boundary ids which iterators shall
+     * have to be evaluated to true.
+     */
+    ManifoldIdEqualTo(const std::set<types::manifold_id> &manifold_ids);
+
+    /**
+     * Evaluation operator. Returns true if the boundary id of the object
+     * pointed to is equal within the stored set of value allowable values.
+     */
+    template <class Iterator>
+    bool
+    operator()(const Iterator &i) const;
+
+  protected:
+    /**
+     * Stored value to compare the material id with.
+     */
+    const std::set<types::manifold_id> manifold_ids;
+  };
 } // namespace IteratorFilters
 
 
@@ -1502,6 +1540,30 @@ namespace IteratorFilters
   {
     return boundary_ids.find(i->boundary_id()) != boundary_ids.end();
   }
+
+
+
+  // ---------------- IteratorFilters::ManifoldIdEqualTo ---------
+  inline ManifoldIdEqualTo::ManifoldIdEqualTo(
+    const types::manifold_id manifold_id)
+    : manifold_ids{manifold_id}
+  {}
+
+
+
+  inline ManifoldIdEqualTo::ManifoldIdEqualTo(
+    const std::set<types::manifold_id> &manifold_ids)
+    : manifold_ids(manifold_ids)
+  {}
+
+
+
+  template <class Iterator>
+  inline bool
+  ManifoldIdEqualTo::operator()(const Iterator &i) const
+  {
+    return manifold_ids.find(i->manifold_id()) != manifold_ids.end();
+  }
 } // namespace IteratorFilters
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.