From 5f23da34a9b899f58c43bfc9c30b7d1b2b36699e Mon Sep 17 00:00:00 2001
From: Felix Schindler <felix.schindler@wwu.de>
Date: Tue, 17 Oct 2017 20:58:51 +0200
Subject: [PATCH] [walker.apply-on] add CustomBoundaryIntersections filter

---
 dune/xt/grid/walker/apply-on.hh | 41 +++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/dune/xt/grid/walker/apply-on.hh b/dune/xt/grid/walker/apply-on.hh
index 6e643291b..aee787348 100644
--- a/dune/xt/grid/walker/apply-on.hh
+++ b/dune/xt/grid/walker/apply-on.hh
@@ -343,6 +343,47 @@ private:
 }; // class BoundaryIntersections
 
 
+template <class GridLayerImp>
+class CustomBoundaryIntersections : public WhichIntersection<GridLayerImp>
+{
+  typedef WhichIntersection<GridLayerImp> BaseType;
+
+public:
+  using typename BaseType::GridLayerType;
+  using typename BaseType::IntersectionType;
+
+  /**
+   * \attention Takes ownership of boundary_type, do not delete manually!
+   */
+  explicit CustomBoundaryIntersections(const BoundaryInfo<IntersectionType>& boundary_info, BoundaryType* boundary_type)
+    : boundary_info_(boundary_info)
+    , boundary_type_(boundary_type)
+  {
+  }
+
+  explicit CustomBoundaryIntersections(const BoundaryInfo<IntersectionType>& boundary_info,
+                                       const std::shared_ptr<BoundaryType>& boundary_type)
+    : boundary_info_(boundary_info)
+    , boundary_type_(boundary_type)
+  {
+  }
+
+  WhichIntersection<GridLayerType>* copy() const override final
+  {
+    return new CustomBoundaryIntersections<GridLayerType>(boundary_info_, boundary_type_);
+  }
+
+  bool apply_on(const GridLayerType& /*grid_layer*/, const IntersectionType& intersection) const override final
+  {
+    return boundary_info_.type(intersection) == *boundary_type_;
+  }
+
+protected:
+  const BoundaryInfo<IntersectionType>& boundary_info_;
+  const std::shared_ptr<BoundaryType> boundary_type_;
+}; // class CustomBoundaryIntersections
+
+
 template <class GridLayerImp>
 class DirichletIntersections
     : public internal::WhichIntersectionBase<GridLayerImp, DirichletIntersections<GridLayerImp>, true>
-- 
GitLab