dune-fem  2.4.1-rc
threadfilter.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_THEADFILTER_HH
2 #define DUNE_FEM_THEADFILTER_HH
3 
4 //- system includes
5 #include <algorithm>
6 
7 //- dune-fem includes
10 
11 namespace Dune
12 {
13  namespace Fem
14  {
15 
16  // forward declarations
17  // --------------------
18 
19  template< class > class FilterDefaultImplementation;
20  template< class > class ThreadFilter;
21 
22 
23  // ThreadFilterTraits
24  // ------------------------
25 
26  template< class GridPartImp >
28  {
30  typedef GridPartImp GridPartType;
31 
34 
36  template < int cd >
37  struct Codim
38  {
40  typedef typename GridPartType::template Codim< cd >::EntityType EntityType;
41  };
42 
45  };
46 
47 
48  // ThreadFilter
49  // ------------------
50 
51  template< class GridPartImp >
52  class ThreadFilter
53  : public FilterDefaultImplementation< ThreadFilterTraits< GridPartImp > >
54  {
55  // type of grid part
56  typedef GridPartImp GridPartType;
57 
58  // type of traits
60 
61  // this type
62  typedef ThreadFilter< GridPartType > ThisType;
63 
64  // base type
66 
67  static const int dimension = GridPartType::GridType::dimension;
68 
69  static const int nCodim = dimension+1;
70 
71  public:
73  typedef typename Traits::FilterType FilterType;
74 
76  typedef typename GridPartType :: IndexSetType IndexSetType;
77 
78  template< int cd >
79  struct Codim
80  {
81  typedef typename Traits::template Codim< cd >::EntityType EntityType;
82  };
83 
85  typedef typename Traits::EntityType EntityType;
86 
88 
90  ThreadFilter ( const GridPartType & gridPart,
91  const ThreadArrayType& threadNum,
92  const int thead )
93  : indexSet_( gridPart.indexSet() ),
94  threadNum_( threadNum ),
95  thread_( thead )
96  { }
97 
99  ThreadFilter ( const ThisType & other )
100  : indexSet_( other.indexSet_ ),
101  threadNum_( other.threadNum_ ),
102  thread_( other.thread_ )
103  {
104  }
105 
107  template< class Intersection >
108  bool interiorIntersection( const Intersection &intersection ) const
109  {
110  return false;
111  }
112 
115  template< int cd >
116  bool contains ( const typename Codim< cd >::EntityType & entity ) const
117  {
118  if( cd == 0 )
119  {
120  return (thread_ == threadNum_[ indexSet_.index( entity ) ]);
121  }
122  else
123  return false ;
124  }
125 
128  template< class Entity >
129  bool contains ( const Entity & entity ) const
130  {
131  enum { cc = Entity::codimension };
132  return contains< cc >( entity );
133  }
134 
136  template< class Intersection >
137  bool intersectionBoundary( const Intersection & intersection ) const
138  {
139  return intersection.boundary();
140  }
141 
143  template< class Intersection >
144  int intersectionBoundaryId ( const Intersection & intersection ) const
145  {
146  return intersection.boundaryId();
147  }
148 
150  template< class Intersection >
151  bool intersectionNeighbor ( const Intersection & intersection ) const
152  {
153  return intersection.neighbor();
154  }
155 
156  protected:
157  const IndexSetType& indexSet_;
158  const ThreadArrayType& threadNum_ ;
159  const int thread_;
160  };
161 
162  } // end namespace Fem
163 
164 } // end namespace Dune
165 
166 #endif // #ifndef DUNE_FEM_THREADFILTER_HH
bool contains(const typename Codim< cd >::EntityType &entity) const
returns true if the given entity has the correct thread number for higher codims false is returned ...
Definition: threadfilter.hh:116
Codim< 0 >::EntityType EntityType
entity type for codimension 0
Definition: threadfilter.hh:44
bool intersectionBoundary(const Intersection &intersection) const
returns true if an intersection is a boundary intersection
Definition: threadfilter.hh:137
const IndexSetType & indexSet_
Definition: threadfilter.hh:157
GridPartImp GridPartType
grid part type
Definition: threadfilter.hh:30
Definition: threadfilter.hh:79
Definition: arrays.hh:36
MutableArray< int > ThreadArrayType
Definition: threadfilter.hh:87
int intersectionBoundaryId(const Intersection &intersection) const
returns the boundary id for an intersection
Definition: threadfilter.hh:144
Definition: threadfilter.hh:27
bool intersectionNeighbor(const Intersection &intersection) const
returns true if for an intersection a neighbor exsits
Definition: threadfilter.hh:151
entity types
Definition: threadfilter.hh:37
ThreadFilter< GridPartType > FilterType
filter type
Definition: threadfilter.hh:33
ThreadFilter(const ThisType &other)
copy constructor
Definition: threadfilter.hh:99
GridPartType::template Codim< cd >::EntityType EntityType
entity type for given codimension
Definition: threadfilter.hh:40
GridPartType::IndexSetType IndexSetType
type of index set
Definition: threadfilter.hh:76
bool contains(const Entity &entity) const
returns true if the given entity has the correct thread number for higher codims false is returned ...
Definition: threadfilter.hh:129
Definition: coordinate.hh:4
ThreadFilter(const GridPartType &gridPart, const ThreadArrayType &threadNum, const int thead)
constructor
Definition: threadfilter.hh:90
Definition: threadfilter.hh:20
Traits::template Codim< cd >::EntityType EntityType
Definition: threadfilter.hh:81
const int thread_
Definition: threadfilter.hh:159
Definition: basicfilterwrapper.hh:20
const ThreadArrayType & threadNum_
Definition: threadfilter.hh:158
bool interiorIntersection(const Intersection &intersection) const
return false since all interior intersections should be skipped
Definition: threadfilter.hh:108
Traits::FilterType FilterType
type of the filter implementation
Definition: threadfilter.hh:73
Traits::EntityType EntityType
type of codim 0 entity
Definition: threadfilter.hh:85