Dune Core Modules (2.3.1)

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 >
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 >::EntityPointer EntityPointer;
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
72 typedef Alberta::ElementInfo< dimension > ElementInfo;
73
74 private:
75 typedef typename Grid::Traits::template Codim< codim >::GeometryImpl GeometryImpl;
76
77 public:
79 explicit AlbertaGridEntity ( const Grid &grid );
80
82 AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity );
83
85 int level () const;
86
89
91 Geometry geometry () const;
92
94 GeometryType type () const;
95
97 EntitySeed seed () const { return EntitySeed( AlbertaGridEntitySeed< codim, Grid >( elementInfo(), subEntity() ) ); }
98
99 //***********************************************
100 // end of interface methods
101 //***********************************************
102
104 ALBERTA EL_INFO *getElInfo () const;
105
106 const ElementInfo &elementInfo () const { return elementInfo_; }
107
109 bool equals ( const This &other ) const;
110
111 void clearElement ();
112 void setElement ( const ElementInfo &elementInfo, int subEntity );
113
114 // same as setElInfo just with a entity given
115 void setEntity ( const This &other );
116
118 const Grid &grid () const
119 {
120 return *grid_;
121 }
122
124 int subEntity () const
125 {
126 return subEntity_;
127 }
128
130 int twist () const
131 {
132 return elementInfo().template twist< codimension >( subEntity() );
133 }
134
135 private:
136 // grid this entity belong to
137 const Grid *grid_;
138
139 // ALBERTA element info
140 ElementInfo elementInfo_;
141
142 // number of the subentity within the element (in ALBERTA numbering)
143 int subEntity_;
144 };
145
146
147
148 // AlbertaGridEntity for codimension 0
149 // -----------------------------------
150
158 template< int dim, class Grid >
159 class AlbertaGridEntity< 0, dim, Grid >
160 : public EntityDefaultImplementation< 0, dim, Grid, AlbertaGridEntity >
161 {
163
164 static const int dimworld = Grid::dimensionworld;
165
166 friend class AlbertaGrid< dim, dimworld >;
167 friend class AlbertaGridLeafIntersection< Grid >;
168 friend class AlbertaGridHierarchicIterator< Grid >;
169 template< int, class, bool > friend class AlbertaGridTreeIterator;
170 friend class AlbertaGridEntityPointer< 0, Grid >;
171
172 public:
173 static const int dimension = dim;
174 static const int codimension = 0;
175 static const int mydimension = dimension - codimension;
176
177 template< int codim >
178 struct Codim
179 {
180 typedef typename Grid::template Codim< codim >::EntityPointer
182 };
183
184 typedef typename Grid::template Codim< 0 >::Entity Entity;
185 typedef typename Grid::template Codim< 0 >::EntitySeed EntitySeed;
186 typedef typename Grid::template Codim< 0 >::Geometry Geometry;
187 typedef typename Grid::template Codim< 0 >::LocalGeometry LocalGeometry;
188 typedef typename Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
189
190 typedef typename Grid::HierarchicIterator HierarchicIterator;
191 typedef typename Grid::template Codim< 0 >::EntityPointer EntityPointer;
192
193 typedef Dune::AlbertaGridLeafIntersectionIterator< Grid > AlbertaGridLeafIntersectionIterator;
194 typedef AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator;
195
196 typedef Alberta::ElementInfo< dimension > ElementInfo;
197
199 explicit AlbertaGridEntity ( const Grid &grid );
200
202 AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity );
203
205 int level () const;
206
208 int boundaryId () const;
209
211 Geometry geometry () const;
212
214 GeometryType type () const;
215
217 EntitySeed seed () const { return EntitySeed( AlbertaGridEntitySeed< 0, Grid >(elementInfo() )); }
218
225 template< int codim >
226 int count () const
227 {
228 return Alberta::NumSubEntities< dimension, codim >::value;
229 }
230
241 template< int codim >
242 typename Codim< codim >::EntityPointer subEntity ( int i ) const;
243
249 AlbertaGridLeafIntersectionIterator ileafbegin () const;
250
252 AlbertaGridLeafIntersectionIterator ileafend () const;
253
254 AlbertaGridLevelIntersectionIterator ilevelbegin () const
255 {
256 if( grid().maxLevel() == 0 )
257 return ileafbegin();
258 else
259 {
260 DUNE_THROW( NotImplemented, "method ilevelbegin not implemented for AlbertaGrid." );
261 return ileafend();
262 }
263 }
264
265 AlbertaGridLevelIntersectionIterator ilevelend () const
266 {
267 return ileafend();
268 }
269
271 bool isLeaf () const;
272
275 EntityPointer father () const;
277 bool hasFather () const
278 {
279 return (this->level()>0);
280 }
281
290 LocalGeometry geometryInFather () const;
291
296 HierarchicIterator hbegin (int maxlevel) const;
297
299 HierarchicIterator hend (int maxlevel) const;
300
302 bool isNew () const;
303
305 bool mightVanish () const;
306
309 bool hasBoundaryIntersections () const ;
310
313
315 bool equals ( const This &i ) const;
316
317 // needed for LevelIterator to compare
318 ALBERTA EL_INFO *getElInfo () const;
319
320 const ElementInfo &elementInfo () const
321 {
322 return elementInfo_;
323 }
324
325 void clearElement ();
326 void setElement ( const ElementInfo &elementInfo, int subEntity );
327
328 // same as setElInfo just with a entity given
329 void setEntity ( const This &other );
330
332 const Grid &grid () const
333 {
334 return *grid_;
335 }
336
338 int subEntity () const
339 {
340 return 0;
341 }
342
344 int twist () const
345 {
346 return elementInfo().template twist< codimension >( subEntity() );
347 }
348
350 template< int codim >
351 int twist ( int i ) const
352 {
353 return elementInfo().template twist< codim >( grid().generic2alberta( codim, i ) );
354 }
355
356 private:
358 int nChild () const;
359
361 const Grid *grid_;
362
363 // Alberta element info
364 ElementInfo elementInfo_;
365 };
366
367} // namespace Dune
368
369#endif // #if HAVE_ALBERTA
370
371#endif // #ifndef DUNE_ALBERTA_ENTITY_HH
EntityPointer implementation for AlbertaGrid.
Definition: entitypointer.hh:29
EntitySeed seed() const
obtain entity seed
Definition: entity.hh:217
int count() const
Definition: entity.hh:226
int twist() const
obtain twist
Definition: entity.hh:344
Codim< codim >::EntityPointer subEntity(int i) const
bool hasFather() const
returns true if father entity exists
Definition: entity.hh:277
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: entity.hh:338
int twist(int i) const
obtain twist of a subentity
Definition: entity.hh:351
const Grid & grid() const
obtain a reference to the grid
Definition: entity.hh:332
Definition: entity.hh:47
int twist() const
obtain twist
Definition: entity.hh:130
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition: entity.cc:52
int level() const
level of this element
Definition: entity.cc:84
EntitySeed seed() const
obtain entity seed
Definition: entity.hh:97
PartitionType partitionType() const
return partition type of this entity
Definition: entity.cc:30
AlbertaGridEntity(const Grid &grid)
constructor
Definition: entity.cc:22
Geometry geometry() const
geometry of this entity
Definition: entity.cc:93
const Grid & grid() const
obtain a reference to the grid
Definition: entity.hh:118
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: entity.hh:124
GeometryType type() const
type of geometry of this entity
Definition: entity.cc:104
bool equals(const This &other) const
equality of entities
Definition: entity.cc:38
Definition: hierarchiciterator.hh:29
Definition: treeiterator.hh:182
[ provides Dune::Grid ]
Definition: agrid.hh:140
Default Implementations for EntityImp.
Definition: entity.hh:553
GridImp::template Codim< cd >::EntityPointer EntityPointer
The corresponding entity seed (for storage of entities)
Definition: entity.hh:574
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Grid abstract base class.
Definition: grid.hh:386
GridFamily::Traits::HierarchicIterator HierarchicIterator
A type that is a model of Dune::HierarchicIterator A type of iterator that allows to examine,...
Definition: grid.hh:510
@ dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:406
Enables iteration over all codim zero entities in a subtree See also the documentation of Dune::Entit...
Definition: hierarchiciterator.hh:33
Default exception for dummy implementations.
Definition: exceptions.hh:289
provides a wrapper for ALBERTA's el_info structure
#define DUNE_THROW(E, m)
Definition: exceptions.hh:244
Dune namespace.
Definition: alignment.hh:14
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)