dune-fem  2.4.1-rc
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 >
32  struct DefaultFilterTraits
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 >
59  class FilterInterface
60  {
61  typedef FilterInterface< FilterTraits > ThisType;
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  // constructor
83  FilterInterface () { }
84 
85  // copy constructor
86  FilterInterface ( const ThisType & );
87 
88  // assignment operator
89  ThisType & operator= ( const ThisType & );
90 
91  public:
93  template< int cd >
94  bool contains ( const typename Codim< cd >::EntityType & entity ) const
95  {
96  CHECK_INTERFACE_IMPLEMENTATION( asImp().contains( entity ) );
97  return asImp().contains< cd >( entity );
98  }
99 
101  template< class Entity >
102  bool contains ( const Entity & entity ) const
103  {
104  enum { cc = Entity::codimension };
105  CHECK_INTERFACE_IMPLEMENTATION( asImp().contains< cc >( entity ) );
106  return asImp().contains< cc >( entity );
107  }
108 
110  // (allows boundarys within a given domain)
111  template< class Intersection >
112  bool interiorIntersection ( const Intersection &intersection ) const
113  {
114  return asImp().interiorIntersection( intersection );
115  }
116 
118  template< class Intersection >
119  bool intersectionBoundary( const Intersection &intersection ) const
120  {
121  return asImp().intersectionBoundary( intersection );
122  }
123 
125  template< class Intersection >
126  int intersectionBoundaryId ( const Intersection &intersection ) const
127  {
128  return asImp().intersectionBoundaryId( intersection );
129  }
130 
132  template< class Intersection >
133  bool intersectionNeighbor ( const Intersection &intersection ) const
134  {
135  return asImp().intersectionNeighbor( intersection );
136  }
137 
138  protected:
139  FilterType &asImp ()
140  {
141  return static_cast< FilterType & >( *this );
142  }
143 
144  const FilterType &asImp () const
145  {
146  return static_cast< const FilterType & >( *this );
147  }
148  };
149 
150 
151  // FilterDefaultImplementation
152  // ---------------------------
153 
154  template< class FilterTraits >
156  : public FilterInterface< FilterTraits >
157  {
159  typedef FilterInterface< FilterTraits > BaseType;
160 
161  public:
164 
166  template< int cd >
167  struct Codim
168  {
170  typedef typename BaseType::template Codim< cd >::EntityType EntityType;
171  };
172 
175 
176  protected:
177  using BaseType::asImp;
178 
179  // constructor
181 
182  // copy constructor
183  FilterDefaultImplementation ( const ThisType & );
184 
185  // assignment operator
186  ThisType &operator= ( const ThisType & );
187 
188  public:
189  using BaseType::contains;
190 
192  template< class Intersection >
193  bool interiorIntersection( const Intersection &intersection ) const
194  {
195  typedef typename Intersection::Entity EntityType;
196  const EntityType outside(intersection.outside());
197  return asImp().contains( outside );
198  }
199 
201  template< int cd >
202  bool contains ( const typename Codim< cd >::EntityType & ) const;
203 
205  template< class Intersection >
206  bool intersectionBoundary( const Intersection & ) const;
207 
209  template< class Intersection >
210  int intersectionBoundaryId ( const Intersection & ) const;
211 
213  template< class Intersection >
214  bool intersectionNeighbor ( const Intersection & ) const;
215  };
216 
217  } // namespace Fem
218 
219 } // namespace Dune
220 
221 #endif // #ifndef DUNE_FEM_GRIDPART_FILTER_FILTER_HH
int intersectionBoundaryId(const Intersection &intersection) const
returns the boundary id for an intersection
Definition: filter/filter.hh:126
BaseType::EntityType EntityType
type of codim 0 entity
Definition: filter/filter.hh:174
type definitions
Definition: filter/filter.hh:22
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:23
BaseType::template Codim< cd >::EntityType EntityType
type of codim cd
Definition: filter/filter.hh:170
bool intersectionBoundary(const Intersection &intersection) const
returns true if an intersection is a boundary intersection
Definition: filter/filter.hh:119
const FilterType & asImp() const
Definition: filter/filter.hh:144
Definition: coordinate.hh:4
FilterDefaultImplementation()
Definition: filter/filter.hh:180
entity types
Definition: filter/filter.hh:39
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:94
FilterType::template Codim< cd >::EntityType EntityType
entity type for given codimension
Definition: filter/filter.hh:42
bool interiorIntersection(const Intersection &intersection) const
returns true if an intersection is interior
Definition: filter/filter.hh:112
Definition: basicfilterwrapper.hh:20
FilterImp FilterType
filter type
Definition: filter/filter.hh:35
bool interiorIntersection(const Intersection &intersection) const
default implementation returns contains from neighbor
Definition: filter/filter.hh:193
bool contains(const Entity &entity) const
returns true if the given entity of the pointer in the domain
Definition: filter/filter.hh:102
entity types
Definition: filter/filter.hh:73
Codim< 0 >::EntityType EntityType
type of entity with codim=0
Definition: filter/filter.hh:79
Traits::template Codim< cd >::EntityType EntityType
Definition: filter/filter.hh:75
BaseType::FilterType FilterType
type of the filter implementation
Definition: filter/filter.hh:163
bool intersectionNeighbor(const Intersection &intersection) const
returns true if for an intersection a neighbor exsits
Definition: filter/filter.hh:133
FilterType & asImp()
Definition: filter/filter.hh:139
Traits::FilterType FilterType
type of the filter implementation
Definition: filter/filter.hh:69
entity types
Definition: filter/filter.hh:167