DUNE-FEM (unstable)

entity.hh
1#ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_ENTITY_HH
2#define DUNE_FEM_GRIDPART_GEOGRIDPART_ENTITY_HH
3
4#include <type_traits>
5#include <utility>
6
7#include <dune/grid/common/entity.hh>
8#include <dune/grid/common/gridenums.hh>
9
10#include <dune/fem/gridpart/common/defaultgridpartentity.hh>
11#include <dune/fem/gridpart/geogridpart/cornerstorage.hh>
12
13namespace Dune
14{
15
16 namespace Fem
17 {
18
19 // GeoEntity
20 // ---------
21
22 template< int codim, int dim, class GridFamily >
23 class GeoEntity
24 : public DefaultGridPartEntity < codim, dim, GridFamily >
25 {
26 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
27
28 public:
29 static const int codimension = codim;
30 static const int dimension = std::remove_const< GridFamily >::type::dimension;
31 static const int mydimension = dimension - codimension;
32 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
33
34 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
35
36 typedef typename Traits::template Codim< codimension >::EntitySeed EntitySeed;
37 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
38
39 typedef typename Traits::HostGridPartType HostGridPartType;
40
41 private:
42 typedef typename Traits::CoordFunctionType CoordFunctionType;
43
44 typedef typename Geometry::Implementation GeometryImplType;
45
46 typedef GeoCoordVector< mydimension, GridFamily > CoordVectorType;
47
48 public:
49 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
50
51 GeoEntity () = default;
52
53 GeoEntity ( const CoordFunctionType &coordFunction, HostEntityType hostEntity )
54 : coordFunction_( &coordFunction ),
55 hostEntity_( std::move( hostEntity ) )
56 {}
57
58 GeometryType type () const
59 {
60 return hostEntity().type();
61 }
62
63 PartitionType partitionType () const
64 {
65 return hostEntity().partitionType();
66 }
67
68 Geometry geometry () const
69 {
70 if( !geo_ )
71 {
72 CoordVectorType coords( coordFunction(), hostEntity() );
73 geo_ = GeometryImplType( type(), coords );
74 }
75 return Geometry( geo_ );
76 }
77
78 EntitySeed seed () const { return EntitySeed( hostEntity().seed() ); }
79
80 bool equals ( const GeoEntity &rhs ) const
81 {
82 return hostEntity() == rhs.hostEntity();
83 }
84
85 const CoordFunctionType &coordFunction () const
86 {
87 assert( coordFunction_ );
88 return *coordFunction_;
89 }
90
91 const HostEntityType &hostEntity () const
92 {
93 return hostEntity_;
94 }
95
96 unsigned int subEntities ( unsigned int cdim ) const { return hostEntity().subEntities( cdim ); }
97
98 private:
99 const CoordFunctionType *coordFunction_ = nullptr;
100 HostEntityType hostEntity_;
101
102 mutable GeometryImplType geo_;
103 };
104
105
106
107 // GeoEntity for codimension 0
108 // ---------------------------
109
110 template< int dim, class GridFamily >
111 class GeoEntity< 0, dim, GridFamily >
112 : public DefaultGridPartEntity < 0, dim, GridFamily >
113 {
114 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
115
116 public:
117 static const int codimension = 0;
118 static const int dimension = std::remove_const< GridFamily >::type::dimension;
119 static const int mydimension = dimension - codimension;
120 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
121
122 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
123
124 typedef typename Traits::template Codim< codimension >::EntitySeed EntitySeed;
125 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
126 typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
127
128 typedef typename Traits::HierarchicIterator HierarchicIterator;
129 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
130 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
131
132 typedef typename Traits::HostGridPartType HostGridPartType;
133 private:
134
135 typedef typename Traits::CoordFunctionType CoordFunctionType;
136
137 typedef typename Geometry::Implementation GeometryImplType;
138
139 typedef GeoCoordVector< mydimension, GridFamily > CoordVectorType;
140
141 public:
142 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
143
144 GeoEntity () = default;
145
146 GeoEntity ( const CoordFunctionType &coordFunction, HostEntityType hostEntity )
147 : coordFunction_( &coordFunction ),
148 hostEntity_( std::move( hostEntity ) )
149 {}
150
151 template< class LocalFunction >
152 GeoEntity ( const GeoEntity &other, const LocalFunction &localCoordFunction )
153 : coordFunction_( other.coordFunction_ ),
154 hostEntity_( other.hostEntity_ )
155 {
156 GeoLocalCoordVector< mydimension, GridFamily, LocalFunction > coords( localCoordFunction );
157 geo_ = GeometryImplType( type(), coords );
158 }
159
160 GeometryType type () const
161 {
162 return hostEntity().type();
163 }
164
165 PartitionType partitionType () const
166 {
167 return hostEntity().partitionType();
168 }
169
170 Geometry geometry () const
171 {
172 if( !geo_ )
173 {
174 CoordVectorType coords( coordFunction(), hostEntity() );
175 geo_ = GeometryImplType( type(), coords );
176 }
177 return Geometry( geo_ );
178 }
179
180 EntitySeed seed () const { return EntitySeed( hostEntity().seed() ); }
181
182 template< int codim >
183 int count () const
184 {
185 return hostEntity().template count< codim >();
186 }
187
188 unsigned int subEntities ( unsigned int codim ) const { return hostEntity().subEntities( codim ); }
189
190 template< int codim >
191 typename Traits::template Codim< codim >::Entity
192 subEntity ( int i ) const
193 {
194 typedef typename Traits::template Codim< codim >::Entity::Implementation EntityImpl;
195 return EntityImpl( *coordFunction_, hostEntity().template subEntity< codim >( i ) );
196 }
197
198 bool hasBoundaryIntersections () const
199 {
200 return hostEntity().hasBoundaryIntersections();
201 }
202
203 bool equals ( const GeoEntity &rhs ) const
204 {
205 return hostEntity() == rhs.hostEntity();
206 }
207
208 const CoordFunctionType &coordFunction () const
209 {
210 assert( coordFunction_ );
211 return *coordFunction_;
212 }
213
214 const HostEntityType &hostEntity () const
215 {
216 return hostEntity_;
217 }
218
219 void setHostEntity ( const HostEntityType &hostEntity )
220 {
221 hostEntity_ = &hostEntity;
222 }
223
224 private:
225 const CoordFunctionType *coordFunction_ = nullptr;
226 HostEntityType hostEntity_;
227
228 mutable GeometryImplType geo_;
229 };
230
231 } // namespace Fem
232
233} // namespace Dune
234
235#endif // #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_ENTITY_HH
GeometryImp< mydim, cdim, GridImp > Implementation
type of underlying implementation
Definition: geometry.hh:78
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
constexpr auto equals
Function object for performing equality comparison.
Definition: hybridutilities.hh:572
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)