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

index 4733739411faae4707cba1b9afdfb9cc5e4b46db..3fa12229ecd78a7bf1af7ba1d13bd1d93d24f45d 100644 (file)
@@ -328,6 +328,44 @@ namespace IteratorFilters
     bool
     operator()(const Iterator &i) const;
   };
+
+
+  /**
+   * 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 boundary id.
+   *
+   * @ingroup Iterators
+   */
+  class BoundaryIdEqualTo
+  {
+  public:
+    /**
+     * Constructor. Store the boundary id which iterators shall have to be
+     * evaluated to true.
+     */
+    BoundaryIdEqualTo(const types::boundary_id boundary_id);
+
+    /**
+     * Constructor. Store a collection of boundary ids which iterators shall
+     * have to be evaluated to true.
+     */
+    BoundaryIdEqualTo(const std::set<types::boundary_id> &boundary_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::boundary_id> boundary_ids;
+  };
 } // namespace IteratorFilters
 
 
@@ -1440,6 +1478,30 @@ namespace IteratorFilters
   {
     return (i->at_boundary());
   }
+
+
+
+  // ---------------- IteratorFilters::BoundaryIdEqualTo ---------
+  inline BoundaryIdEqualTo::BoundaryIdEqualTo(
+    const types::boundary_id boundary_id)
+    : boundary_ids{boundary_id}
+  {}
+
+
+
+  inline BoundaryIdEqualTo::BoundaryIdEqualTo(
+    const std::set<types::boundary_id> &boundary_ids)
+    : boundary_ids(boundary_ids)
+  {}
+
+
+
+  template <class Iterator>
+  inline bool
+  BoundaryIdEqualTo::operator()(const Iterator &i) const
+  {
+    return boundary_ids.find(i->boundary_id()) != boundary_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.