DUNE-FEM (unstable)

entity.hh
1#ifndef DUNE_FEM_GRIDPART_IDGRIDPART_ENTITY_HH
2#define DUNE_FEM_GRIDPART_IDGRIDPART_ENTITY_HH
3
4#include <type_traits>
5#include <utility>
6
7//- dune-grid includes
8#include <dune/grid/common/entity.hh>
9#include <dune/grid/common/gridenums.hh>
10
11//- dune-fem includes
12#include <dune/fem/gridpart/common/defaultgridpartentity.hh>
13#include <dune/fem/gridpart/idgridpart/geometry.hh>
14
15namespace Dune
16{
17 namespace Fem {
18
19 // IdEntityBasic
20 // -------------
21
22 template< int codim, int dim, class GridFamily >
23 class IdEntityBasic
24 : public DefaultGridPartEntity < codim, dim, GridFamily >
25 {
26 protected:
27 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
28
29 public:
34 static const int codimension = codim;
36 static const int dimension = std::remove_const< GridFamily >::type::dimension;
38 static const int mydimension = dimension - codimension;
40 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
41
48 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
49
51 typedef typename GridFamily::template Codim< codimension >::EntitySeed EntitySeedType;
53 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
54
57 // type of the host grid
58 typedef typename Traits::HostGridPartType HostGridPartType;
59
60 protected:
61 // type of extra data, e.g. a pointer to grid (here empty)
62 typedef typename Traits::ExtraData ExtraData;
63
64 public:
69 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
70
77 IdEntityBasic () = default;
78
83 IdEntityBasic ( ExtraData data, HostEntityType hostEntity )
84 : data_( std::move( data ) ),
85 hostEntity_( std::move( hostEntity ) )
86 {}
87
97 GeometryType type () const
98 {
99 return hostEntity().type();
100 }
101
103 int level () const
104 {
105 return hostEntity().level();
106 }
107
109 PartitionType partitionType () const
110 {
111 return hostEntity().partitionType();
112 }
113
115 Geometry geometry () const
116 {
117 return Geometry( hostEntity().geometry() );
118 }
119
121 EntitySeedType seed () const { return hostEntity().seed(); }
122
124 bool equals ( const IdEntityBasic &rhs ) const
125 {
126 return hostEntity() == rhs.hostEntity();
127 }
128
129 unsigned int subEntities( const unsigned int c ) const
130 {
131 return hostEntity().subEntities( c );
132 }
133
140 const HostEntityType &hostEntity () const
141 {
142 return hostEntity_;
143 }
144
145 const ExtraData &data () const { return data_; }
146
149 protected:
150 ExtraData data_;
151 HostEntityType hostEntity_;
152 };
153
154
155
156 // IdGridEntity
157 // ------------
158
159 template< int codim, int dim, class GridFamily >
160 class IdEntity : public IdEntityBasic< codim, dim, GridFamily >
161 {
162 typedef IdEntityBasic< codim, dim, GridFamily > BaseType ;
163 protected:
164 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
165
166 public:
167 // type of the host grid
168 typedef typename Traits::HostGridPartType HostGridPartType;
169 protected:
170 // type of extra data, e.g. a pointer to grid (here empty)
171 typedef typename Traits::ExtraData ExtraData;
172
173 public:
174 using BaseType :: codimension ;
175
180 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
181
185 IdEntity () = default;
186
187 IdEntity ( ExtraData data, HostEntityType hostEntity )
188 : BaseType( data, hostEntity )
189 {}
190 };
191
192
193 // IdGridEntity for codimension 0
194 // ----------------------------------
195
200 template< int dim, class GridFamily >
201 class IdEntity< 0, dim, GridFamily > : public IdEntityBasic< 0, dim, GridFamily >
202 {
203 typedef IdEntityBasic< 0, dim, GridFamily > BaseType ;
204 protected:
205 typedef typename BaseType::Traits Traits;
206
207 // type of extra data, e.g. a pointer to grid (here empty)
208 typedef typename BaseType::ExtraData ExtraData;
209
210 public:
211 typedef typename BaseType::HostGridPartType HostGridPartType;
212
213 using BaseType::codimension ;
214 using BaseType::data ;
215 using BaseType::hostEntity ;
220 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
223 public:
228 typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
229
238 IdEntity () = default;
239
245 IdEntity ( ExtraData data, HostEntityType hostEntity )
246 : BaseType( data, hostEntity )
247 {}
248
251 template< int codim >
252 int count () const
253 {
254 return hostEntity().template count< codim >();
255 }
256
257 template< int codim >
258 typename Traits::template Codim< codim >::Entity
259 subEntity ( int i ) const
260 {
261 typedef typename Traits::template Codim< codim >::Entity::Implementation EntityImpl;
262 return EntityImpl( data(), hostEntity().template subEntity< codim >( i ) );
263 }
264
265 bool hasBoundaryIntersections () const
266 {
267 return hostEntity().hasBoundaryIntersections();
268 }
269
272 };
273
274 } // namespace Fem
275
276} // namespace Dune
277
278#endif // #ifndef DUNE_IDGRID_ENTITY_HH
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition: entity.hh:228
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
type of corresponding host entity
Definition: entity.hh:220
IdEntity()=default
construct a null entity
IdEntity(ExtraData data, HostEntityType hostEntity)
construct an initialized entity
Definition: entity.hh:245
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
Dune namespace
Definition: alignedallocator.hh:13
STL namespace.
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (May 9, 22:32, 2026)