dune-fem 2.12-git
Loading...
Searching...
No Matches
gridpart/filter/simple.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_GRIDPART_FILTER_SIMPLE_HH
2#define DUNE_FEM_GRIDPART_FILTER_SIMPLE_HH
3
4#include <array>
5#include <tuple>
6#include <utility>
7#include <vector>
8
10
12
15
16namespace Dune
17{
18
19 namespace Fem
20 {
21
22 // Internal Forward Declarations
23 // -----------------------------
24
25 template< class GridPart >
26 class SimpleFilter;
27
28
29
30 // SimpleFilterTraits
31 // ---------------------
32
33 template< class GridPart >
35 {
37
38 template< int codim >
39 struct Codim
40 {
41 typedef typename GridPart::template Codim< codim >::EntityType EntityType;
42 };
43 };
44
45
46
47 // SimpleFilter
48 // ---------------
49
50 template< class GridPart >
52 : public FilterDefaultImplementation< SimpleFilterTraits< GridPart > >
53 {
56
58
59 public:
60 template< int codim >
61 using Codim = typename Base::template Codim< codim >;
62
63 template< class Contains >
64 SimpleFilter ( const GridPart &gridPart, Contains contains, int domainId )
65 : mapper_( gridPart, [](Dune::GeometryType, unsigned int ) {return true;} ),
66 contains_( mapper_.size(), false ),
67 mapper0_( gridPart, [](Dune::GeometryType gt, unsigned int dim) {return gt.dim()==dim;} ),
68 domainIds_( mapper0_.size(), -1 )
69 {
70 for( const typename Codim< 0 >::EntityType &entity : elements( gridPart ) )
71 {
72 domainIds_[ mapper0_.index( entity ) ] = contains( entity );
73 if( domainIds_[ mapper0_.index( entity ) ] == domainId )
74 mark( entity, AllCodims() );
75 }
76 }
77
78 template< int codim >
79 bool contains ( const typename Codim< codim >::EntityType &entity ) const
80 {
81 return contains_[ mapper_.index( entity ) ];
82 }
83
84 template< class Entity >
85 bool contains ( const Entity &entity ) const
86 {
87 return contains< Entity::codimension >( entity );
88 }
89
90 template< class Intersection >
91 bool interiorIntersection ( const Intersection &intersection ) const
92 {
93 return contains( intersection.outside() );
94 }
95
96 template< class Intersection >
97 bool intersectionBoundary ( const Intersection & ) const
98 {
99 return true;
100 }
101
102 template< class Intersection >
103 int intersectionBoundaryId ( const Intersection &intersection ) const
104 {
105 return ( intersection.boundary() ?
107 domainIds_[ mapper0_.index( intersection.outside() ) ] );
108 }
109
110 template< class Intersection >
111 bool intersectionNeighbor ( const Intersection & ) const
112 {
113 return false;
114 }
115
116 private:
117 template< int codim >
118 void mark ( const typename Codim< 0 >::EntityType &entity, Dune::Codim< codim > )
119 {
120 for( unsigned int i = 0, n = entity.subEntities( codim ); i < n; ++i )
121 contains_[ mapper_.subIndex( entity, i, codim ) ] = true;
122 }
123
124 template< int... codim >
125 void mark ( const typename Codim< 0 >::EntityType &entity, std::integer_sequence< int, codim... > )
126 {
127 std::ignore = std::make_tuple( (mark( entity, Dune::Codim< codim >() ), codim)... );
128 }
129
131 std::vector< bool > contains_;
133 std::vector< int > domainIds_;
134 };
135
136 } // namespace Fem
137
138} // namespace Dune
139
140#endif // #ifndef DUNE_FEM_GRIDPART_FILTER_SIMPLE_HH
size_type dim() const
Entity outside() const
bool boundary() const
Index subIndex(const typename GV::template Codim< 0 >::Entity &e, int i, unsigned int codim) const
Index index(const EntityType &e) const
Definition filter/filter.hh:156
Definition gridpart/filter/simple.hh:53
bool intersectionNeighbor(const Intersection &) const
Definition gridpart/filter/simple.hh:111
bool contains(const Entity &entity) const
Definition gridpart/filter/simple.hh:85
bool contains(const typename Codim< codim >::EntityType &entity) const
Definition gridpart/filter/simple.hh:79
bool interiorIntersection(const Intersection &intersection) const
Definition gridpart/filter/simple.hh:91
typename Base::template Codim< codim > Codim
Definition gridpart/filter/simple.hh:61
int intersectionBoundaryId(const Intersection &intersection) const
Definition gridpart/filter/simple.hh:103
bool intersectionBoundary(const Intersection &) const
Definition gridpart/filter/simple.hh:97
SimpleFilter(const GridPart &gridPart, Contains contains, int domainId)
Definition gridpart/filter/simple.hh:64
Definition gridpart/filter/simple.hh:35
SimpleFilter< GridPart > FilterType
Definition gridpart/filter/simple.hh:36
Definition gridpart/filter/simple.hh:40
GridPart::template Codim< codim >::EntityType EntityType
Definition gridpart/filter/simple.hh:41
Definition boundaryidprovider.hh:27
T make_tuple(T... args)