DUNE-FEM (unstable)

simple.hh
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
9#include <dune/geometry/dimension.hh>
10
12
13#include <dune/fem/gridpart/filter/filter.hh>
14#include <dune/fem/misc/boundaryidprovider.hh>
15
16namespace Dune
17{
18
19 namespace Fem
20 {
21
22 // Internal Forward Declarations
23 // -----------------------------
24
25 template< class GridPart >
26 struct SimpleFilter;
27
28
29
30 // SimpleFilterTraits
31 // ---------------------
32
33 template< class GridPart >
34 struct SimpleFilterTraits
35 {
36 typedef SimpleFilter< GridPart > FilterType;
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 >
51 class SimpleFilter
52 : public FilterDefaultImplementation< SimpleFilterTraits< GridPart > >
53 {
54 typedef SimpleFilter< GridPart > This;
55 typedef FilterDefaultImplementation< SimpleFilterTraits< GridPart > > Base;
56
57 typedef std::make_integer_sequence< int, GridPart::dimension+1 > AllCodims;
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,int ) {return true;} ),
66 contains_( mapper_.size(), false ),
67 mapper0_( gridPart, [](Dune::GeometryType gt,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() ?
106 Dune::Fem::BoundaryIdProvider<typename GridPart::GridType>::boundaryId( intersection ) :
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
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:158
Mapper for multiple codim and multiple geometry types.
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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)