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
135 const HostEntityType &hostEntity () const
136 {
137 return hostEntity_;
138 }
139
140 const ExtraData &data () const { return data_; }
141
144 protected:
145 ExtraData data_;
146 HostEntityType hostEntity_;
147 };
148
149
150
151 // IdGridEntity
152 // ------------
153
154 template< int codim, int dim, class GridFamily >
155 class IdEntity : public IdEntityBasic< codim, dim, GridFamily >
156 {
157 typedef IdEntityBasic< codim, dim, GridFamily > BaseType ;
158 protected:
159 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
160
161 public:
162 // type of the host grid
163 typedef typename Traits::HostGridPartType HostGridPartType;
164 protected:
165 // type of extra data, e.g. a pointer to grid (here empty)
166 typedef typename Traits::ExtraData ExtraData;
167
168 public:
169 using BaseType :: codimension ;
170
175 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
176
180 IdEntity () = default;
181
182 IdEntity ( ExtraData data, HostEntityType hostEntity )
183 : BaseType( data, hostEntity )
184 {}
185 };
186
187
188 // IdGridEntity for codimension 0
189 // ----------------------------------
190
195 template< int dim, class GridFamily >
196 class IdEntity< 0, dim, GridFamily > : public IdEntityBasic< 0, dim, GridFamily >
197 {
198 typedef IdEntityBasic< 0, dim, GridFamily > BaseType ;
199 protected:
200 typedef typename BaseType::Traits Traits;
201
202 // type of extra data, e.g. a pointer to grid (here empty)
203 typedef typename BaseType::ExtraData ExtraData;
204
205 public:
206 typedef typename BaseType::HostGridPartType HostGridPartType;
207
208 using BaseType::codimension ;
209 using BaseType::data ;
210 using BaseType::hostEntity ;
215 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
218 public:
223 typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
224
233 IdEntity () = default;
234
240 IdEntity ( ExtraData data, HostEntityType hostEntity )
241 : BaseType( data, hostEntity )
242 {}
243
246 unsigned int subEntities( const unsigned int codim ) const
247 {
248 return hostEntity().subEntities( codim );
249 }
250
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:223
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
type of corresponding host entity
Definition: entity.hh:215
IdEntity()=default
construct a null entity
IdEntity(ExtraData data, HostEntityType hostEntity)
construct an initialized entity
Definition: entity.hh:240
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.
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 (Jul 27, 22:29, 2024)