dune-grid 3.0-git
albertagrid/entity.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ALBERTA_ENTITY_HH
4#define DUNE_ALBERTA_ENTITY_HH
5
7
11
12#if HAVE_ALBERTA
13
14namespace Dune
15{
16
17 // Forward Declarations
18 // --------------------
19
20 template< int codim, class Grid >
21 class AlbertaGridEntityPointer;
22
23 template< int codim, class Grid, bool leafIterator >
24 class AlbertaGridTreeIterator;
25
26 template< class Grid >
27 class AlbertaGridHierarchicIterator;
28
29 template< class Grid >
30 class AlbertaGridLeafIntersection;
31
32 template< class Grid >
33 class AlbertaGridLeafIntersectionIterator;
34
35
36
37 // AlbertaGridEntity
38 // -----------------
39
44 template< int codim, int dim, class Grid >
46 : public EntityDefaultImplementation< codim, dim, Grid, AlbertaGridEntity >
47 {
49
50 enum { dimworld = Grid::dimensionworld };
51 friend class AlbertaGrid< dim, dimworld >;
52 friend class AlbertaGridEntity< 0, dim, Grid >;
53
54 template< int, class, bool > friend class AlbertaGridTreeIterator;
55 friend class AlbertaGridEntityPointer< codim, Grid >;
56
57 public:
58 static const int dimension = dim;
59 static const int codimension = codim;
60 static const int mydimension = dimension - codimension;
61
62 template< int cd >
63 struct Codim
64 {
65 typedef typename Grid::template Codim< cd >::Entity Entity;
66 };
67
68 typedef typename Grid::template Codim< codim >::Entity Entity;
69 typedef typename Grid::template Codim< codim >::EntitySeed EntitySeed;
70 typedef typename Grid::template Codim< codim >::Geometry Geometry;
71
73
74 private:
75 typedef typename Grid::Traits::template Codim< codim >::GeometryImpl GeometryImpl;
76
77 public:
79 explicit AlbertaGridEntity ( const Grid &grid );
80
82
85
87 int level () const;
88
91
93 Geometry geometry () const;
94
96 GeometryType type () const;
97
100
101 //***********************************************
102 // end of interface methods
103 //***********************************************
104
106 ALBERTA EL_INFO *getElInfo () const;
107
108 const ElementInfo &elementInfo () const { return elementInfo_; }
109
111 bool equals ( const This &other ) const;
112
113 void clearElement ();
114 void setElement ( const ElementInfo &elementInfo, int subEntity );
115
116 // same as setElInfo just with a entity given
117 void setEntity ( const This &other );
118
120 const Grid &grid () const
121 {
122 return *grid_;
123 }
124
126 int subEntity () const
127 {
128 return subEntity_;
129 }
130
132 int twist () const
133 {
134 return elementInfo().template twist< codimension >( subEntity() );
135 }
136
137 private:
138 // grid this entity belong to
139 const Grid *grid_;
140
141 // ALBERTA element info
142 ElementInfo elementInfo_;
143
144 // number of the subentity within the element (in ALBERTA numbering)
145 int subEntity_;
146 };
147
148
149
150 // AlbertaGridEntity for codimension 0
151 // -----------------------------------
152
160 template< int dim, class Grid >
161 class AlbertaGridEntity< 0, dim, Grid >
162 : public EntityDefaultImplementation< 0, dim, Grid, AlbertaGridEntity >
163 {
165
166 static const int dimworld = Grid::dimensionworld;
167
168 friend class AlbertaGrid< dim, dimworld >;
169 friend class AlbertaGridLeafIntersection< Grid >;
170 friend class AlbertaGridHierarchicIterator< Grid >;
171 template< int, class, bool > friend class AlbertaGridTreeIterator;
172 friend class AlbertaGridEntityPointer< 0, Grid >;
173
174 public:
175 static const int dimension = dim;
176 static const int codimension = 0;
177 static const int mydimension = dimension - codimension;
178
179 template< int codim >
180 struct Codim
181 {
182 typedef typename Grid::template Codim< codim >::Entity
184 };
185
186 typedef typename Grid::template Codim< 0 >::Entity Entity;
187 typedef typename Grid::template Codim< 0 >::EntitySeed EntitySeed;
188 typedef typename Grid::template Codim< 0 >::Geometry Geometry;
189 typedef typename Grid::template Codim< 0 >::LocalGeometry LocalGeometry;
190 typedef typename Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
191
193
196
198
200 explicit AlbertaGridEntity ( const Grid &grid );
201
203
206
208 int level () const;
209
211 int boundaryId () const;
212
214 Geometry geometry () const;
215
217 GeometryType type () const;
218
221
228 template< int codim >
229 int count () const
230 {
232 }
233
242 unsigned int subEntities (unsigned int codim) const
243 {
244 int n = dimension+1;
245 int k = dimension-codim+1;
246
247 // binomial: n over k
248 int binomial=1;
249 for (int i=n-k+1; i<=n; i++)
250 binomial *= i;
251 for (long i=2; i<=k; i++)
252 binomial /= i;
253
254 return binomial;
255 }
256
267 template< int codim >
268 typename Grid::template Codim< codim >::Entity subEntity ( int i ) const;
269
275 AlbertaGridLeafIntersectionIterator ileafbegin () const;
276
278 AlbertaGridLeafIntersectionIterator ileafend () const;
279
281 {
282 if( grid().maxLevel() == 0 )
283 return ileafbegin();
284 else
285 {
286 DUNE_THROW( NotImplemented, "method ilevelbegin not implemented for AlbertaGrid." );
287 return ileafend();
288 }
289 }
290
292 {
293 return ileafend();
294 }
295
297 bool isLeaf () const;
298
301 Entity father () const;
303 bool hasFather () const
304 {
305 return (this->level()>0);
306 }
307
316 LocalGeometry geometryInFather () const;
317
322 HierarchicIterator hbegin (int maxlevel) const;
323
325 HierarchicIterator hend (int maxlevel) const;
326
328 bool isNew () const;
329
331 bool mightVanish () const;
332
335 bool hasBoundaryIntersections () const ;
336
339
341 bool equals ( const This &i ) const;
342
343 // needed for LevelIterator to compare
344 ALBERTA EL_INFO *getElInfo () const;
345
346 const ElementInfo &elementInfo () const
347 {
348 return elementInfo_;
349 }
350
351 void clearElement ();
352 void setElement ( const ElementInfo &elementInfo, int subEntity );
353
354 // same as setElInfo just with a entity given
355 void setEntity ( const This &other );
356
358 const Grid &grid () const
359 {
360 return *grid_;
361 }
362
364 int subEntity () const
365 {
366 return 0;
367 }
368
370 int twist () const
371 {
372 return elementInfo().template twist< codimension >( subEntity() );
373 }
374
376 template< int codim >
377 int twist ( int i ) const
378 {
379 return elementInfo().template twist< codim >( grid().generic2alberta( codim, i ) );
380 }
381
382 private:
384 int nChild () const;
385
387 const Grid *grid_;
388
389 // Alberta element info
390 ElementInfo elementInfo_;
391 };
392
393} // namespace Dune
394
395#endif // #if HAVE_ALBERTA
396
397#endif // #ifndef DUNE_ALBERTA_ENTITY_HH
#define ALBERTA
Definition albertaheader.hh:27
provides a wrapper for ALBERTA's el_info structure
PartitionType
Attributes used in the generic overlap model.
Definition gridenums.hh:28
Include standard header files.
Definition agrid.hh:60
[ provides Dune::Grid ]
Definition agrid.hh:140
EntityPointer implementation for AlbertaGrid.
Definition albertagrid/entitypointer.hh:29
Definition treeiterator.hh:182
Definition hierarchiciterator.hh:29
Definition albertagrid/intersection.hh:103
Definition albertagrid/intersectioniterator.hh:25
Definition albertagrid/entity.hh:47
void clearElement()
Definition entity.cc:68
int twist() const
obtain twist
Definition albertagrid/entity.hh:132
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition entity.cc:60
Grid::template Codim< codim >::Entity Entity
Definition albertagrid/entity.hh:68
int level() const
level of this element
Definition entity.cc:92
void setElement(const ElementInfo &elementInfo, int subEntity)
Definition entity.cc:76
EntitySeed seed() const
obtain entity seed
Definition albertagrid/entity.hh:99
PartitionType partitionType() const
return partition type of this entity
Definition entity.cc:38
Grid::template Codim< codim >::Geometry Geometry
Definition albertagrid/entity.hh:70
void setEntity(const This &other)
Definition entity.cc:85
const ElementInfo & elementInfo() const
Definition albertagrid/entity.hh:108
Geometry geometry() const
geometry of this entity
Definition entity.cc:101
static const int dimension
Definition albertagrid/entity.hh:58
static const int codimension
Definition albertagrid/entity.hh:59
const Grid & grid() const
obtain a reference to the grid
Definition albertagrid/entity.hh:120
Grid::template Codim< codim >::EntitySeed EntitySeed
Definition albertagrid/entity.hh:69
static const int mydimension
Definition albertagrid/entity.hh:60
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition albertagrid/entity.hh:126
Alberta::ElementInfo< dimension > ElementInfo
Definition albertagrid/entity.hh:72
GeometryType type() const
type of geometry of this entity
Definition entity.cc:112
bool equals(const This &other) const
equality of entities
Definition entity.cc:46
AlbertaGridEntity()
Definition entity.cc:30
Definition albertagrid/entity.hh:64
Grid::template Codim< cd >::Entity Entity
Definition albertagrid/entity.hh:65
Definition albertagrid/entity.hh:163
Grid::HierarchicIterator HierarchicIterator
Definition albertagrid/entity.hh:192
EntitySeed seed() const
obtain entity seed
Definition albertagrid/entity.hh:220
Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl
Definition albertagrid/entity.hh:190
unsigned int subEntities(unsigned int codim) const
Obtain the number of subentities of a given codimension.
Definition albertagrid/entity.hh:242
int count() const
Definition albertagrid/entity.hh:229
const ElementInfo & elementInfo() const
Definition albertagrid/entity.hh:346
int twist() const
obtain twist
Definition albertagrid/entity.hh:370
Grid::template Codim< 0 >::Geometry Geometry
Definition albertagrid/entity.hh:188
bool hasFather() const
returns true if father entity exists
Definition albertagrid/entity.hh:303
Grid::template Codim< 0 >::Entity Entity
Definition albertagrid/entity.hh:186
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition albertagrid/entity.hh:364
int twist(int i) const
obtain twist of a subentity
Definition albertagrid/entity.hh:377
AlbertaGridLevelIntersectionIterator ilevelbegin() const
Definition albertagrid/entity.hh:280
Alberta::ElementInfo< dimension > ElementInfo
Definition albertagrid/entity.hh:197
Grid::template Codim< 0 >::EntitySeed EntitySeed
Definition albertagrid/entity.hh:187
AlbertaGridLevelIntersectionIterator ilevelend() const
Definition albertagrid/entity.hh:291
Grid::template Codim< 0 >::LocalGeometry LocalGeometry
Definition albertagrid/entity.hh:189
const Grid & grid() const
obtain a reference to the grid
Definition albertagrid/entity.hh:358
Dune::AlbertaGridLeafIntersectionIterator< Grid > AlbertaGridLeafIntersectionIterator
Definition albertagrid/entity.hh:194
AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator
Definition albertagrid/entity.hh:195
Grid::template Codim< codim >::Entity Entity
Definition albertagrid/entity.hh:183
Definition albertagrid/entityseed.hh:16
Definition misc.hh:145
Wrapper class for entities.
Definition common/entity.hh:62
Default Implementations for EntityImp.
Definition common/entity.hh:544
Grid abstract base class.
Definition common/grid.hh:373
GridFamily::Traits::HierarchicIterator HierarchicIterator
A type that is a model of Dune::HierarchicIterator A type of iterator that allows to examine,...
Definition common/grid.hh:486
@ dimensionworld
The dimension of the world the grid lives in.
Definition common/grid.hh:393