Dune Core Modules (2.7.0)

entity.hh
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
6#include <dune/grid/common/entity.hh>
7
9#include <dune/grid/albertagrid/entityseed.hh>
10#include <dune/grid/albertagrid/geometry.hh>
11
12#if HAVE_ALBERTA
13
14namespace Dune
15{
16
17 // Forward Declarations
18 // --------------------
19
20 template< int codim, class Grid, bool leafIterator >
21 class AlbertaGridTreeIterator;
22
23 template< class Grid >
24 class AlbertaGridHierarchicIterator;
25
26 template< class Grid >
27 class AlbertaGridLeafIntersection;
28
29 template< class Grid >
30 class AlbertaGridLeafIntersectionIterator;
31
32
33
34 // AlbertaGridEntity
35 // -----------------
36
41 template< int codim, int dim, class Grid >
43 : public EntityDefaultImplementation< codim, dim, Grid, AlbertaGridEntity >
44 {
46
47 enum { dimworld = Grid::dimensionworld };
48 friend class AlbertaGrid< dim, dimworld >;
49 friend class AlbertaGridEntity< 0, dim, Grid >;
50
51 friend class AlbertaGridHierarchicIterator< Grid >;
52 template< int, class, bool > friend class AlbertaGridTreeIterator;
53
54 public:
55 static const int dimension = dim;
56 static const int codimension = codim;
57 static const int mydimension = dimension - codimension;
58
59 template< int cd >
60 struct Codim
61 {
62 typedef typename Grid::template Codim< cd >::Entity Entity;
63 };
64
65 typedef typename Grid::template Codim< codim >::Entity Entity;
66 typedef typename Grid::template Codim< codim >::EntitySeed EntitySeed;
67 typedef typename Grid::template Codim< codim >::Geometry Geometry;
68
69 typedef Alberta::ElementInfo< dimension > ElementInfo;
70
71 private:
72 typedef typename Grid::Traits::template Codim< codim >::GeometryImpl GeometryImpl;
73
74 public:
76 explicit AlbertaGridEntity ( const Grid &grid );
77
79
81 AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity );
82
84 int level () const;
85
88
90 Geometry geometry () const;
91
93 GeometryType type () const;
94
96 EntitySeed seed () const { return EntitySeed( AlbertaGridEntitySeed< codim, Grid >( elementInfo(), subEntity() ) ); }
97
106 unsigned int subEntities ( unsigned int cd ) const
107 {
108 int n = mydimension+1;
109 int k = dimension-cd+1;
110
111 // binomial: n over k
112 int binomial=1;
113 for (int i=n-k+1; i<=n; i++)
114 binomial *= i;
115 for (long i=2; i<=k; i++)
116 binomial /= i;
117
118 return binomial;
119 }
120
121 //***********************************************
122 // end of interface methods
123 //***********************************************
124
126 ALBERTA EL_INFO *getElInfo () const;
127
128 const ElementInfo &elementInfo () const { return elementInfo_; }
129
131 bool equals ( const This &other ) const;
132
133 void clearElement ();
134 void setElement ( const ElementInfo &elementInfo, int subEntity );
135
136 // same as setElInfo just with a entity given
137 void setEntity ( const This &other );
138
140 const Grid &grid () const
141 {
142 return *grid_;
143 }
144
146 int subEntity () const
147 {
148 return subEntity_;
149 }
150
152 int twist () const
153 {
154 return elementInfo().template twist< codimension >( subEntity() );
155 }
156
157 private:
158 // grid this entity belong to
159 const Grid *grid_;
160
161 // ALBERTA element info
162 ElementInfo elementInfo_;
163
164 // number of the subentity within the element (in ALBERTA numbering)
165 int subEntity_;
166 };
167
168
169
170 // AlbertaGridEntity for codimension 0
171 // -----------------------------------
172
180 template< int dim, class Grid >
181 class AlbertaGridEntity< 0, dim, Grid >
182 : public EntityDefaultImplementation< 0, dim, Grid, AlbertaGridEntity >
183 {
185
186 static const int dimworld = Grid::dimensionworld;
187
188 friend class AlbertaGrid< dim, dimworld >;
189 friend class AlbertaGridLeafIntersection< Grid >;
190 friend class AlbertaGridHierarchicIterator< Grid >;
191 template< int, class, bool > friend class AlbertaGridTreeIterator;
192
193 public:
194 static const int dimension = dim;
195 static const int codimension = 0;
196 static const int mydimension = dimension - codimension;
197
198 template< int codim >
199 struct Codim
200 {
201 typedef typename Grid::template Codim< codim >::Entity
202 Entity;
203 };
204
205 typedef typename Grid::template Codim< 0 >::Entity Entity;
206 typedef typename Grid::template Codim< 0 >::EntitySeed EntitySeed;
207 typedef typename Grid::template Codim< 0 >::Geometry Geometry;
208 typedef typename Grid::template Codim< 0 >::LocalGeometry LocalGeometry;
209 typedef typename Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
210
211 typedef typename Grid::HierarchicIterator HierarchicIterator;
212
213 typedef Dune::AlbertaGridLeafIntersectionIterator< Grid > AlbertaGridLeafIntersectionIterator;
214 typedef AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator;
215
216 typedef Alberta::ElementInfo< dimension > ElementInfo;
217
219 explicit AlbertaGridEntity ( const Grid &grid );
220
222
224 AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity );
225
227 int level () const;
228
230 int boundaryId () const;
231
233 Geometry geometry () const;
234
236 GeometryType type () const;
237
239 EntitySeed seed () const { return EntitySeed( AlbertaGridEntitySeed< 0, Grid >(elementInfo() )); }
240
249 unsigned int subEntities ( unsigned int cd ) const
250 {
251 int n = mydimension+1;
252 int k = dimension-cd+1;
253
254 // binomial: n over k
255 int binomial=1;
256 for (int i=n-k+1; i<=n; i++)
257 binomial *= i;
258 for (long i=2; i<=k; i++)
259 binomial /= i;
260
261 return binomial;
262 }
263
274 template< int codim >
275 typename Grid::template Codim< codim >::Entity subEntity ( int i ) const;
276
282 AlbertaGridLeafIntersectionIterator ileafbegin () const;
283
285 AlbertaGridLeafIntersectionIterator ileafend () const;
286
287 AlbertaGridLevelIntersectionIterator ilevelbegin () const
288 {
289 if( grid().maxLevel() == 0 )
290 return ileafbegin();
291 else
292 {
293 DUNE_THROW( NotImplemented, "method ilevelbegin not implemented for AlbertaGrid." );
294 return ileafend();
295 }
296 }
297
298 AlbertaGridLevelIntersectionIterator ilevelend () const
299 {
300 return ileafend();
301 }
302
304 bool isLeaf () const;
305
308 Entity father () const;
310 bool hasFather () const
311 {
312 return (this->level()>0);
313 }
314
323 LocalGeometry geometryInFather () const;
324
329 HierarchicIterator hbegin (int maxlevel) const;
330
332 HierarchicIterator hend (int maxlevel) const;
333
335 bool isNew () const;
336
338 bool mightVanish () const;
339
342 bool hasBoundaryIntersections () const ;
343
346
348 bool equals ( const This &i ) const;
349
350 // needed for LevelIterator to compare
351 ALBERTA EL_INFO *getElInfo () const;
352
353 const ElementInfo &elementInfo () const
354 {
355 return elementInfo_;
356 }
357
358 void clearElement ();
359 void setElement ( const ElementInfo &elementInfo, int subEntity );
360
361 // same as setElInfo just with a entity given
362 void setEntity ( const This &other );
363
365 const Grid &grid () const
366 {
367 return *grid_;
368 }
369
371 int subEntity () const
372 {
373 return 0;
374 }
375
377 int twist () const
378 {
379 return elementInfo().template twist< codimension >( subEntity() );
380 }
381
383 template< int codim >
384 int twist ( int i ) const
385 {
386 return elementInfo().template twist< codim >( grid().generic2alberta( codim, i ) );
387 }
388
389 private:
391 int nChild () const;
392
394 const Grid *grid_;
395
396 // Alberta element info
397 ElementInfo elementInfo_;
398 };
399
400} // namespace Dune
401
402#endif // #if HAVE_ALBERTA
403
404#endif // #ifndef DUNE_ALBERTA_ENTITY_HH
EntitySeed seed() const
obtain entity seed
Definition: entity.hh:239
int twist() const
obtain twist
Definition: entity.hh:377
bool hasFather() const
returns true if father entity exists
Definition: entity.hh:310
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: entity.hh:371
int twist(int i) const
obtain twist of a subentity
Definition: entity.hh:384
const Grid & grid() const
obtain a reference to the grid
Definition: entity.hh:365
unsigned int subEntities(unsigned int cd) const
Obtain the number of subentities of a given codimension.
Definition: entity.hh:249
Definition: entity.hh:44
int twist() const
obtain twist
Definition: entity.hh:152
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition: entity.cc:60
int level() const
level of this element
Definition: entity.cc:92
EntitySeed seed() const
obtain entity seed
Definition: entity.hh:96
PartitionType partitionType() const
return partition type of this entity
Definition: entity.cc:38
Geometry geometry() const
geometry of this entity
Definition: entity.cc:101
unsigned int subEntities(unsigned int cd) const
Obtain the number of subentities of a given codimension.
Definition: entity.hh:106
const Grid & grid() const
obtain a reference to the grid
Definition: entity.hh:140
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: entity.hh:146
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
Definition: hierarchiciterator.hh:27
Definition: treeiterator.hh:184
[ provides Dune::Grid ]
Definition: agrid.hh:139
Default Implementations for EntityImp.
Definition: entity.hh:548
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:279
Grid abstract base class.
Definition: 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: grid.hh:486
@ dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:393
Default exception for dummy implementations.
Definition: exceptions.hh:261
provides a wrapper for ALBERTA's el_info structure
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
Dune namespace.
Definition: alignedallocator.hh:14
static constexpr T binomial(const T &n, const T &k) noexcept
calculate the binomial coefficient n over k as a constexpr
Definition: math.hh:128
Static tag representing a codimension.
Definition: dimension.hh:22
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Oct 13, 22:30, 2024)