From: Jean-Paul Pelteret Date: Thu, 30 Dec 2021 06:56:21 +0000 (+0100) Subject: Add manifold ID iterator filter predicate X-Git-Tag: v9.4.0-rc1~686^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=252dee8b261f65069605cb928e5e4ce0412dac1f;p=dealii.git Add manifold ID iterator filter predicate --- diff --git a/include/deal.II/grid/filtered_iterator.h b/include/deal.II/grid/filtered_iterator.h index 3fa12229ec..9f202eac46 100644 --- a/include/deal.II/grid/filtered_iterator.h +++ b/include/deal.II/grid/filtered_iterator.h @@ -366,6 +366,44 @@ namespace IteratorFilters */ const std::set 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 &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 + bool + operator()(const Iterator &i) const; + + protected: + /** + * Stored value to compare the material id with. + */ + const std::set 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 &manifold_ids) + : manifold_ids(manifold_ids) + {} + + + + template + inline bool + ManifoldIdEqualTo::operator()(const Iterator &i) const + { + return manifold_ids.find(i->manifold_id()) != manifold_ids.end(); + } } // namespace IteratorFilters