entity.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=2 sw=2 sts=2:
3#ifndef DUNE_POLYHEDRALGRID_ENTITY_HH
4#define DUNE_POLYHEDRALGRID_ENTITY_HH
5
6//- dune-common includes
7#include <dune/common/typetraits.hh>
8
9//- dune-grid includes
10#include <dune/grid/common/entity.hh>
11
12namespace Dune
13{
14
15 // PolyhedralGridEntityBasic
16 // -----------------
17
22 template< int codim, int dim, class Grid >
24 {
25 protected:
26 typedef typename std::remove_const< Grid >::type::Traits Traits;
27
28 public:
33 static const int codimension = codim;
35 static const int dimension = Traits::dimension;
37 static const int mydimension = dimension - codimension;
39 static const int dimensionworld = Traits::dimensionworld;
40
47 typedef typename Traits::ctype ctype;
48
49 typedef typename Traits::Index Index;
50
52 typedef typename Grid::template Codim< codimension >::Entity Entity;
53
55 typedef typename Grid::template Codim< codimension >::EntitySeed EntitySeed;
57 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
58 typedef typename Traits::template Codim< codimension >::GeometryImpl GeometryImpl;
59
62 protected:
63 // type of extra data, e.g. a pointer to grid (here empty)
64 typedef typename Traits::ExtraData ExtraData;
65
66 public:
72 : data_( nullptr ),
73 seed_()
74 {}
75
78 : data_( data ),
79 seed_()
80 {}
81
85 : data_( data )
86 , seed_( seed )
87 {}
88
98 GeometryType type () const
99 {
100 return data()->geometryType(seed_);
101 }
102
104 int level () const
105 {
106 return 0;
107 }
108
110 PartitionType partitionType () const
111 {
112 return InteriorEntity; // data()->partitionType( *this );
113 }
114
117 {
118 return Geometry( GeometryImpl( data(), seed_ ) );
119 }
120
122 EntitySeed seed () const { return seed_; }
123
129 ExtraData data() const { return data_; }
130
131 Index index () const { return seed_.index(); }
132
135 bool equals(const PolyhedralGridEntityBasic& other) const
136 {
137 return seed_.equals(other.seed_);
138 }
139
140 protected:
143 };
144
145
146
147 // PolyhedralGridEntity
148 // ------------
149
150 template< int codim, int dim, class Grid >
151 class PolyhedralGridEntity : public PolyhedralGridEntityBasic< codim, dim, Grid >
152 {
154 protected:
155 typedef typename std::remove_const< Grid >::type::Traits Traits;
156
157 protected:
158 // type of extra data, e.g. a pointer to grid (here empty)
159 typedef typename Traits::ExtraData ExtraData;
160
161 using Base::seed_;
162 public:
164 using Base :: codimension ;
165 using Base :: data ;
166
168 : Base()
169 {}
170
171 explicit PolyhedralGridEntity ( ExtraData data_param )
172 : Base( data_param )
173 {}
174
176 : Base( data_param, seed )
177 {}
178
179 unsigned int subEntities( const unsigned int cd ) const
180 {
181 if( cd == Base :: codimension )
182 return 1;
183 else
184 return data()->subEntities( seed_, cd );
185 }
186
187 template< int cd >
188 typename Grid::template Codim< cd >::EntityPointer
189 subEntity ( int i ) const
190 {
191 typedef typename Traits::template Codim< cd >::EntityPointerImpl EntityPointerImpl;
192 typedef typename Traits::template Codim< cd >::EntityImpl EntityImpl;
193 return EntityPointerImpl( EntityImpl( data(), data()->template subEntitySeed< cd >( seed_, i ) ) );
194 }
195 };
196
197
198 // PolyhedralGridEntity for codimension 0
199 // ----------------------------------
200
205 template< int dim, class Grid >
206 class PolyhedralGridEntity< 0, dim, Grid > : public PolyhedralGridEntityBasic< 0, dim, Grid >
207 {
210
211 protected:
212 typedef typename Base::Traits Traits;
213
214 // type of extra data, e.g. a pointer to grid (here empty)
215 typedef typename Base::ExtraData ExtraData;
216
217 using Base::seed_;
218 public:
219 using Base::codimension ;
220 using Base::data ;
221
222 protected:
223 typedef typename Traits :: LeafIntersectionIteratorImpl LeafIntersectionIteratorImpl;
224 typedef typename Traits::template Codim< codimension >::LocalGeometryImpl LocalGeometryImpl;
225
226 public:
231
233 typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
235 typedef typename Traits::template Codim< codimension >::Entity Entity;
237 typedef typename Traits::template Codim< codimension >::EntityPointer EntityPointer;
238
240 typedef typename Traits::HierarchicIterator HierarchicIterator;
242 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
244 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
245
253 : Base()
254 {}
255
257 explicit PolyhedralGridEntity ( ExtraData data_param )
258 : Base( data_param )
259 {}
260
263 : Base( data_param, seed )
264 {}
265
268 const This& dereference() const
269 { return *this; }
270
272 { return *this; }
273
274 unsigned int subEntities( const unsigned int codim ) const
275 {
276 if( codim == 0 )
277 return 1;
278 else
279 return data()->subEntities( seed_, codim );
280 }
281
282 template< int codim >
283 int count () const
284 {
285 return subEntities( codim );
286 }
287
288 template< int codim >
289 typename Grid::template Codim< codim >::EntityPointer
290 subEntity ( int i ) const
291 {
292 typedef typename Traits::template Codim< codim >::EntityPointerImpl EntityPointerImpl;
293 typedef typename Traits::template Codim< codim >::EntityImpl EntityImpl;
294 return EntityPointerImpl( EntityImpl( data(), data()->template subEntitySeed< codim >( seed_, i ) ) );
295 }
296
298 {
299 return data()->hasBoundaryIntersections( this->seed() );
300 }
301
302 LeafIntersectionIterator ibegin () const
303 {
305 }
306
308 {
310 }
311
312 LeafIntersectionIterator ileafbegin () const { return ibegin(); }
313 LevelIntersectionIterator ilevelbegin () const { return ibegin(); }
314
315 LeafIntersectionIterator ileafend () const { return iend(); }
316 LevelIntersectionIterator ilevelend () const { return iend(); }
317
318 bool isLeaf () const
319 {
320 return true;
321 }
322
324 {
325 DUNE_THROW(InvalidStateException,"no father available");
326 typedef typename Traits::template Codim< 0 >::EntityImpl EntityImpl;
327 typedef typename Traits::template Codim< 0 >::EntityPointerImpl EntityPointerImpl;
328 return EntityPointer( EntityPointerImpl( EntityImpl( data() ) ) );
329 }
330
331 bool hasFather () const
332 {
333 return false;
334 }
335
337 {
338 DUNE_THROW(InvalidStateException,"no father available");
339 return LocalGeometry( LocalGeometryImpl( data() ) );
340 }
341
342 HierarchicIterator hbegin ( int maxLevel ) const
343 {
344 return hend( maxLevel );
345 }
346
348 {
349 typedef typename Traits :: HierarchicIteratorImpl HierarchicIteratorImpl ;
350 return HierarchicIterator( HierarchicIteratorImpl( data(), false ) );
351 }
352
353 bool isRegular () const
354 {
355 return true;
356 }
357
358 bool isNew () const
359 {
360 return false;
361 }
362
363 bool mightVanish () const
364 {
365 return false;
366 }
367
370 };
371
372
373} // namespace Dune
374
375#endif // #ifndef DUNE_POLYHEDRALGRID_ENTITY_HH
construct a null entity
Definition: entity.hh:207
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition: entity.hh:233
PolyhedralGridEntity(ExtraData data_param, const EntitySeed &seed)
construct an initialized entity
Definition: entity.hh:262
Traits::template Codim< codimension >::Entity Entity
type of corresponding entity
Definition: entity.hh:235
bool isNew() const
Definition: entity.hh:358
LevelIntersectionIterator ilevelend() const
Definition: entity.hh:316
LeafIntersectionIterator ileafend() const
Definition: entity.hh:315
Base::ExtraData ExtraData
Definition: entity.hh:215
This & dereference()
Definition: entity.hh:271
HierarchicIterator hbegin(int maxLevel) const
Definition: entity.hh:342
Base::EntitySeed EntitySeed
Definition: entity.hh:230
PolyhedralGridEntity(ExtraData data_param)
construct a null entity with data pointer
Definition: entity.hh:257
Base::Traits Traits
Definition: entity.hh:212
bool hasBoundaryIntersections() const
Definition: entity.hh:297
LeafIntersectionIterator ileafbegin() const
Definition: entity.hh:312
Grid::template Codim< codim >::EntityPointer subEntity(int i) const
Definition: entity.hh:290
LeafIntersectionIterator ibegin() const
Definition: entity.hh:302
HierarchicIterator hend(int) const
Definition: entity.hh:347
Traits::template Codim< codimension >::EntityPointer EntityPointer
type of corresponding entity
Definition: entity.hh:237
const This & dereference() const
Definition: entity.hh:268
Traits::LeafIntersectionIteratorImpl LeafIntersectionIteratorImpl
Definition: entity.hh:223
LevelIntersectionIterator ilevelbegin() const
Definition: entity.hh:313
EntityPointer father() const
Definition: entity.hh:323
Traits::HierarchicIterator HierarchicIterator
type of hierarchic iterator
Definition: entity.hh:240
int count() const
Definition: entity.hh:283
LocalGeometry geometryInFather() const
Definition: entity.hh:336
PolyhedralGridEntity()
construct a null entity
Definition: entity.hh:252
bool isLeaf() const
Definition: entity.hh:318
Traits::template Codim< codimension >::LocalGeometryImpl LocalGeometryImpl
Definition: entity.hh:224
bool isRegular() const
Definition: entity.hh:353
unsigned int subEntities(const unsigned int codim) const
Definition: entity.hh:274
Traits::LeafIntersectionIterator LeafIntersectionIterator
type of leaf intersection iterator
Definition: entity.hh:242
LeafIntersectionIterator iend() const
Definition: entity.hh:307
bool hasFather() const
Definition: entity.hh:331
bool mightVanish() const
Definition: entity.hh:363
Traits::LevelIntersectionIterator LevelIntersectionIterator
type of level intersection iterator
Definition: entity.hh:244
Definition: entity.hh:24
static const int codimension
codimensioon of the entity
Definition: entity.hh:33
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: entity.hh:57
Grid::template Codim< codimension >::Entity Entity
type of entity
Definition: entity.hh:52
ExtraData data_
Definition: entity.hh:141
int level() const
obtain the level of this entity
Definition: entity.hh:104
PolyhedralGridEntityBasic()
construct a null entity
Definition: entity.hh:71
static const int mydimension
dimension of the entity
Definition: entity.hh:37
Traits::ctype ctype
coordinate type of the grid
Definition: entity.hh:47
static const int dimension
dimension of the grid
Definition: entity.hh:35
EntitySeed seed_
Definition: entity.hh:142
static const int dimensionworld
dimension of the world
Definition: entity.hh:39
PolyhedralGridEntityBasic(ExtraData data, const EntitySeed &seed)
construct an initialized entity
Definition: entity.hh:84
Index index() const
Definition: entity.hh:131
PartitionType partitionType() const
obtain the partition type of this entity
Definition: entity.hh:110
Grid::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: entity.hh:55
ExtraData data() const
Definition: entity.hh:129
Geometry geometry() const
Definition: entity.hh:116
bool equals(const PolyhedralGridEntityBasic &other) const
Definition: entity.hh:135
Traits::Index Index
Definition: entity.hh:49
PolyhedralGridEntityBasic(ExtraData data)
construct a null entity with data pointer
Definition: entity.hh:77
EntitySeed seed() const
return EntitySeed
Definition: entity.hh:122
GeometryType type() const
obtain the name of the corresponding reference element
Definition: entity.hh:98
Traits::ExtraData ExtraData
Definition: entity.hh:64
Traits::template Codim< codimension >::GeometryImpl GeometryImpl
Definition: entity.hh:58
std::remove_const< Grid >::type::Traits Traits
Definition: entity.hh:26
Definition: entity.hh:152
PolyhedralGridEntity(ExtraData data_param)
Definition: entity.hh:171
Base::EntitySeed EntitySeed
Definition: entity.hh:163
Grid::template Codim< cd >::EntityPointer subEntity(int i) const
Definition: entity.hh:189
EntitySeed seed_
Definition: entity.hh:142
PolyhedralGridEntity()
Definition: entity.hh:167
unsigned int subEntities(const unsigned int cd) const
Definition: entity.hh:179
Traits::ExtraData ExtraData
Definition: entity.hh:159
std::remove_const< Grid >::type::Traits Traits
Definition: entity.hh:155
PolyhedralGridEntity(ExtraData data_param, const EntitySeed &seed)
Definition: entity.hh:175
The namespace Dune is the main namespace for all Dune code.
Definition: common/CartesianIndexMapper.hpp:10