DUNE-FEM (unstable)

filter.hh
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
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().template 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().template 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:
138  FilterType &asImp ()
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 >
154  class FilterDefaultImplementation
155  : public FilterInterface< FilterTraits >
156  {
157  typedef FilterDefaultImplementation< FilterTraits > ThisType;
158  typedef FilterInterface< FilterTraits > BaseType;
159 
160  public:
162  typedef typename BaseType::FilterType FilterType;
163 
165  template< int cd >
166  struct Codim
167  {
169  typedef typename BaseType::template Codim< cd >::EntityType EntityType;
170  };
171 
173  typedef typename BaseType::EntityType EntityType;
174 
175  protected:
176  using BaseType::asImp;
177 
178  FilterDefaultImplementation () = default;
179 
180  FilterDefaultImplementation ( const ThisType & ) = default;
181  FilterDefaultImplementation ( ThisType && ) = default;
182 
183  ThisType &operator= ( const ThisType & ) = default;
184  ThisType &operator= ( ThisType && ) = default;
185 
186  public:
187  using BaseType::contains;
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
Provides check for implementation of interface methods when using static polymorphism,...
Wrapper class for entities.
Definition: entity.hh:66
constexpr static int codimension
Know your own codimension.
Definition: entity.hh:106
Interface class for filter to use with a Dune::FilteredGridPart.
Definition: filter.hh:60
Traits ::FilterType FilterType
type of the filter implementation
Definition: filter.hh:69
bool intersectionNeighbor(const Intersection &intersection) const
returns true if for an intersection a neighbor exsits
Definition: filter.hh:132
bool contains(const Entity &entity) const
returns true if the given entity of the pointer in the domain
Definition: filter.hh:101
bool interiorIntersection(const Intersection &intersection) const
returns true if an intersection is interior
Definition: filter.hh:111
bool intersectionBoundary(const Intersection &intersection) const
returns true if an intersection is a boundary intersection
Definition: 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.hh:93
Codim< 0 >::EntityType EntityType
type of entity with codim=0
Definition: filter.hh:79
int intersectionBoundaryId(const Intersection &intersection) const
returns the boundary id for an intersection
Definition: filter.hh:125
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
Entity outside() const
return Entity on the outside of this intersection. That is the neighboring Entity.
Definition: intersection.hh:261
GridImp::template Codim< 0 >::Entity Entity
Type of entity that this Intersection belongs to.
Definition: intersection.hh:192
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137
Static tag representing a codimension.
Definition: dimension.hh:24
entity types
Definition: filter.hh:40
FilterType::template Codim< cd >::EntityType EntityType
entity type for given codimension
Definition: filter.hh:42
type definitions
Definition: filter.hh:33
FilterImp FilterType
filter type
Definition: filter.hh:35
Codim< 0 >::EntityType EntityType
entity type for codimension 0
Definition: filter.hh:46
entity types
Definition: filter.hh:167
BaseType::template Codim< cd >::EntityType EntityType
type of codim cd
Definition: filter.hh:169
entity types
Definition: filter.hh:74
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)