dune-fem  2.8-git
filter/filter.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_FILTER_FILTER_HH
2 #define DUNE_FEM_GRIDPART_FILTER_FILTER_HH
3 
4 //- system includes
5 #include <algorithm>
6 #include <cassert>
7 #include <vector>
8 
9 //- dune-common includes
10 #include <dune/common/bartonnackmanifcheck.hh>
11 
12 
13 namespace Dune
14 {
15 
16  namespace Fem
17  {
18 
19  // forward declarations
20  // --------------------
21 
22  template< class > struct DefaultFilterTraits;
23  template< class > class FilterInterface;
24  template< class > class FilterDefaultImplementation;
25 
26 
27  // DefaultFilterTraits
28  // -------------------
29 
31  template < class FilterImp >
33  {
35  typedef FilterImp FilterType;
36 
38  template < int cd >
39  struct Codim
40  {
42  typedef typename FilterType::template Codim< cd >::EntityType EntityType;
43  };
44 
47 
48  }; // end DefaultFilterTraits
49 
50 
51 
52  // FilterInterface
53  // ---------------
54 
58  template< class FilterTraits >
60  {
62 
63  friend class FilterDefaultImplementation< FilterTraits >;
64 
65  typedef FilterTraits Traits;
66 
67  public:
69  typedef typename Traits :: FilterType FilterType;
70 
72  template< int cd >
73  struct Codim
74  {
75  typedef typename Traits::template Codim< cd >::EntityType EntityType;
76  };
77 
80 
81  private:
82  FilterInterface () = default;
83 
84  FilterInterface ( const ThisType & ) = default;
85  FilterInterface ( ThisType && ) = default;
86 
87  ThisType &operator= ( const ThisType & ) = default;
88  ThisType &operator= ( ThisType && ) = default;
89 
90  public:
92  template< int cd >
93  bool contains ( const typename Codim< cd >::EntityType & entity ) const
94  {
95  CHECK_INTERFACE_IMPLEMENTATION( asImp().contains( entity ) );
96  return asImp().contains< cd >( entity );
97  }
98 
100  template< class Entity >
101  bool contains ( const Entity & entity ) const
102  {
103  enum { cc = Entity::codimension };
104  CHECK_INTERFACE_IMPLEMENTATION( asImp().contains< cc >( entity ) );
105  return asImp().contains< cc >( entity );
106  }
107 
109  // (allows boundarys within a given domain)
110  template< class Intersection >
111  bool interiorIntersection ( const Intersection &intersection ) const
112  {
113  return asImp().interiorIntersection( intersection );
114  }
115 
117  template< class Intersection >
118  bool intersectionBoundary( const Intersection &intersection ) const
119  {
120  return asImp().intersectionBoundary( intersection );
121  }
122 
124  template< class Intersection >
125  int intersectionBoundaryId ( const Intersection &intersection ) const
126  {
127  return asImp().intersectionBoundaryId( intersection );
128  }
129 
131  template< class Intersection >
132  bool intersectionNeighbor ( const Intersection &intersection ) const
133  {
134  return asImp().intersectionNeighbor( intersection );
135  }
136 
137  protected:
139  {
140  return static_cast< FilterType & >( *this );
141  }
142 
143  const FilterType &asImp () const
144  {
145  return static_cast< const FilterType & >( *this );
146  }
147  };
148 
149 
150  // FilterDefaultImplementation
151  // ---------------------------
152 
153  template< class FilterTraits >
155  : public FilterInterface< FilterTraits >
156  {
159 
160  public:
163 
165  template< int cd >
166  struct Codim
167  {
169  typedef typename BaseType::template Codim< cd >::EntityType EntityType;
170  };
171 
174 
175  protected:
177 
179 
180  FilterDefaultImplementation ( const ThisType & ) = default;
182 
183  ThisType &operator= ( const ThisType & ) = default;
184  ThisType &operator= ( ThisType && ) = default;
185 
186  public:
188 
190  template< class Intersection >
191  bool interiorIntersection( const Intersection &intersection ) const
192  {
193  typedef typename Intersection::Entity EntityType;
194  const EntityType outside(intersection.outside());
195  return asImp().contains( outside );
196  }
197 
199  template< int cd >
200  bool contains ( const typename Codim< cd >::EntityType & ) const;
201 
203  template< class Intersection >
204  bool intersectionBoundary( const Intersection & ) const;
205 
207  template< class Intersection >
208  int intersectionBoundaryId ( const Intersection & ) const;
209 
211  template< class Intersection >
212  bool intersectionNeighbor ( const Intersection & ) const;
213  };
214 
215  } // namespace Fem
216 
217 } // namespace Dune
218 
219 #endif // #ifndef DUNE_FEM_GRIDPART_FILTER_FILTER_HH
Definition: bindguard.hh:11
Definition: filter/filter.hh:156
FilterDefaultImplementation(const ThisType &)=default
FilterType & asImp()
Definition: filter/filter.hh:138
bool intersectionBoundary(const Intersection &) const
returns true if an intersection is a boundary intersection
int intersectionBoundaryId(const Intersection &) const
returns the boundary id for an intersection
ThisType & operator=(const ThisType &)=default
BaseType::EntityType EntityType
type of codim 0 entity
Definition: filter/filter.hh:173
FilterDefaultImplementation(ThisType &&)=default
bool intersectionNeighbor(const Intersection &) const
returns true if for an intersection a neighbor exsits
bool interiorIntersection(const Intersection &intersection) const
default implementation returns contains from neighbor
Definition: filter/filter.hh:191
BaseType::FilterType FilterType
type of the filter implementation
Definition: filter/filter.hh:162
bool contains(const typename Codim< cd >::EntityType &) const
returns true if the given entity of the pointer in the domain
type definitions
Definition: filter/filter.hh:33
FilterImp FilterType
filter type
Definition: filter/filter.hh:35
Codim< 0 >::EntityType EntityType
entity type for codimension 0
Definition: filter/filter.hh:46
Interface class for filter to use with a Dune::FilteredGridPart.
Definition: filter/filter.hh:60
Traits ::FilterType FilterType
type of the filter implementation
Definition: filter/filter.hh:69
const FilterType & asImp() const
Definition: filter/filter.hh:143
FilterType & asImp()
Definition: filter/filter.hh:138
bool intersectionNeighbor(const Intersection &intersection) const
returns true if for an intersection a neighbor exsits
Definition: filter/filter.hh:132
bool contains(const Entity &entity) const
returns true if the given entity of the pointer in the domain
Definition: filter/filter.hh:101
bool interiorIntersection(const Intersection &intersection) const
returns true if an intersection is interior
Definition: filter/filter.hh:111
bool intersectionBoundary(const Intersection &intersection) const
returns true if an intersection is a boundary intersection
Definition: filter/filter.hh:118
bool contains(const typename Codim< cd >::EntityType &entity) const
returns true if the given entity of the pointer in the domain
Definition: filter/filter.hh:93
Codim< 0 >::EntityType EntityType
type of entity with codim=0
Definition: filter/filter.hh:79
int intersectionBoundaryId(const Intersection &intersection) const
returns the boundary id for an intersection
Definition: filter/filter.hh:125
entity types
Definition: filter/filter.hh:40
FilterType::template Codim< cd >::EntityType EntityType
entity type for given codimension
Definition: filter/filter.hh:42
entity types
Definition: filter/filter.hh:74
Traits::template Codim< cd >::EntityType EntityType
Definition: filter/filter.hh:75
entity types
Definition: filter/filter.hh:167
BaseType::template Codim< cd >::EntityType EntityType
type of codim cd
Definition: filter/filter.hh:169