dune-grid 2.9.0
albertagrid/entity.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_ALBERTA_ENTITY_HH
6#define DUNE_ALBERTA_ENTITY_HH
7
9
13
14#if HAVE_ALBERTA
15
16namespace Dune
17{
18
19 // Forward Declarations
20 // --------------------
21
22 template< int codim, class Grid, bool leafIterator >
23 class AlbertaGridTreeIterator;
24
25 template< class Grid >
26 class AlbertaGridHierarchicIterator;
27
28 template< class Grid >
29 class AlbertaGridLeafIntersection;
30
31 template< class Grid >
32 class AlbertaGridLeafIntersectionIterator;
33
34
35
36 // AlbertaGridEntity
37 // -----------------
38
43 template< int codim, int dim, class Grid >
45 : public EntityDefaultImplementation< codim, dim, Grid, AlbertaGridEntity >
46 {
48
49 constexpr static int dimworld = Grid::dimensionworld;
50 friend class AlbertaGrid< dim, dimworld >;
51 friend class AlbertaGridEntity< 0, dim, Grid >;
52
53 friend class AlbertaGridHierarchicIterator< Grid >;
54 template< int, class, bool > friend class AlbertaGridTreeIterator;
55
56 public:
57 static const int dimension = dim;
58 static const int codimension = codim;
59 static const int mydimension = dimension - codimension;
60
61 template< int cd >
62 struct Codim
63 {
64 typedef typename Grid::template Codim< cd >::Entity Entity;
65 };
66
67 typedef typename Grid::template Codim< codim >::Entity Entity;
68 typedef typename Grid::template Codim< codim >::EntitySeed EntitySeed;
69 typedef typename Grid::template Codim< codim >::Geometry Geometry;
70
72
73 private:
74 typedef typename Grid::Traits::template Codim< codim >::GeometryImpl GeometryImpl;
75
76 public:
78 explicit AlbertaGridEntity ( const Grid &grid );
79
81
84
86 int level () const;
87
90
92 Geometry geometry () const;
93
95 GeometryType type () const;
96
99
108 unsigned int subEntities ( unsigned int cd ) const
109 {
110 int n = mydimension+1;
111 int k = dimension-cd+1;
112
113 // binomial: n over k
114 int binomial=1;
115 for (int i=n-k+1; i<=n; i++)
116 binomial *= i;
117 for (long i=2; i<=k; i++)
118 binomial /= i;
119
120 return binomial;
121 }
122
123 //***********************************************
124 // end of interface methods
125 //***********************************************
126
128 ALBERTA EL_INFO *getElInfo () const;
129
130 const ElementInfo &elementInfo () const { return elementInfo_; }
131
133 bool equals ( const This &other ) const;
134
135 void clearElement ();
136 void setElement ( const ElementInfo &elementInfo, int subEntity );
137
138 // same as setElInfo just with a entity given
139 void setEntity ( const This &other );
140
142 const Grid &grid () const
143 {
144 return *grid_;
145 }
146
148 int subEntity () const
149 {
150 return subEntity_;
151 }
152
154 int twist () const
155 {
156 return elementInfo().template twist< codimension >( subEntity() );
157 }
158
159 private:
160 // grid this entity belong to
161 const Grid *grid_;
162
163 // ALBERTA element info
164 ElementInfo elementInfo_;
165
166 // number of the subentity within the element (in ALBERTA numbering)
167 int subEntity_;
168 };
169
170
171
172 // AlbertaGridEntity for codimension 0
173 // -----------------------------------
174
182 template< int dim, class Grid >
183 class AlbertaGridEntity< 0, dim, Grid >
184 : public EntityDefaultImplementation< 0, dim, Grid, AlbertaGridEntity >
185 {
187
188 static const int dimworld = Grid::dimensionworld;
189
190 friend class AlbertaGrid< dim, dimworld >;
191 friend class AlbertaGridLeafIntersection< Grid >;
192 friend class AlbertaGridHierarchicIterator< Grid >;
193 template< int, class, bool > friend class AlbertaGridTreeIterator;
194
195 public:
196 static const int dimension = dim;
197 static const int codimension = 0;
198 static const int mydimension = dimension - codimension;
199
200 template< int codim >
201 struct Codim
202 {
203 typedef typename Grid::template Codim< codim >::Entity
205 };
206
207 typedef typename Grid::template Codim< 0 >::Entity Entity;
208 typedef typename Grid::template Codim< 0 >::EntitySeed EntitySeed;
209 typedef typename Grid::template Codim< 0 >::Geometry Geometry;
210 typedef typename Grid::template Codim< 0 >::LocalGeometry LocalGeometry;
211 typedef typename Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
212
214
217
219
221 explicit AlbertaGridEntity ( const Grid &grid );
222
224
227
229 int level () const;
230
232 int boundaryId () const;
233
235 Geometry geometry () const;
236
238 GeometryType type () const;
239
242
251 unsigned int subEntities ( unsigned int cd ) const
252 {
253 int n = mydimension+1;
254 int k = dimension-cd+1;
255
256 // binomial: n over k
257 int binomial=1;
258 for (int i=n-k+1; i<=n; i++)
259 binomial *= i;
260 for (long i=2; i<=k; i++)
261 binomial /= i;
262
263 return binomial;
264 }
265
276 template< int codim >
277 typename Grid::template Codim< codim >::Entity subEntity ( int i ) const;
278
284 AlbertaGridLeafIntersectionIterator ileafbegin () const;
285
287 AlbertaGridLeafIntersectionIterator ileafend () const;
288
290 {
291 if( grid().maxLevel() == 0 )
292 return ileafbegin();
293 else
294 {
295 DUNE_THROW( NotImplemented, "method ilevelbegin not implemented for AlbertaGrid." );
296 return ileafend();
297 }
298 }
299
301 {
302 return ileafend();
303 }
304
306 bool isLeaf () const;
307
310 Entity father () const;
312 bool hasFather () const
313 {
314 return (this->level()>0);
315 }
316
325 LocalGeometry geometryInFather () const;
326
331 HierarchicIterator hbegin (int maxlevel) const;
332
334 HierarchicIterator hend (int maxlevel) const;
335
337 bool isNew () const;
338
340 bool mightVanish () const;
341
344 bool hasBoundaryIntersections () const ;
345
348
350 bool equals ( const This &i ) const;
351
352 // needed for LevelIterator to compare
353 ALBERTA EL_INFO *getElInfo () const;
354
355 const ElementInfo &elementInfo () const
356 {
357 return elementInfo_;
358 }
359
360 void clearElement ();
361 void setElement ( const ElementInfo &elementInfo, int subEntity );
362
363 // same as setElInfo just with a entity given
364 void setEntity ( const This &other );
365
367 const Grid &grid () const
368 {
369 return *grid_;
370 }
371
373 int subEntity () const
374 {
375 return 0;
376 }
377
379 int twist () const
380 {
381 return elementInfo().template twist< codimension >( subEntity() );
382 }
383
385 template< int codim >
386 int twist ( int i ) const
387 {
388 return elementInfo().template twist< codim >( grid().generic2alberta( codim, i ) );
389 }
390
391 private:
393 int nChild () const;
394
396 const Grid *grid_;
397
398 // Alberta element info
399 ElementInfo elementInfo_;
400 };
401
402} // namespace Dune
403
404#endif // #if HAVE_ALBERTA
405
406#endif // #ifndef DUNE_ALBERTA_ENTITY_HH
provides a wrapper for ALBERTA's el_info structure
#define ALBERTA
Definition: albertaheader.hh:29
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
[ provides Dune::Grid ]
Definition: agrid.hh:109
Definition: treeiterator.hh:189
Definition: hierarchiciterator.hh:29
Definition: albertagrid/intersection.hh:105
Definition: albertagrid/intersectioniterator.hh:27
Definition: albertagrid/entity.hh:46
void clearElement()
Definition: entity.cc:70
int twist() const
obtain twist
Definition: albertagrid/entity.hh:154
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition: entity.cc:62
Grid::template Codim< codim >::Entity Entity
Definition: albertagrid/entity.hh:67
int level() const
level of this element
Definition: entity.cc:94
void setElement(const ElementInfo &elementInfo, int subEntity)
Definition: entity.cc:78
EntitySeed seed() const
obtain entity seed
Definition: albertagrid/entity.hh:98
PartitionType partitionType() const
return partition type of this entity
Definition: entity.cc:40
Grid::template Codim< codim >::Geometry Geometry
Definition: albertagrid/entity.hh:69
void setEntity(const This &other)
Definition: entity.cc:87
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:130
Geometry geometry() const
geometry of this entity
Definition: entity.cc:103
static const int dimension
Definition: albertagrid/entity.hh:57
unsigned int subEntities(unsigned int cd) const
Obtain the number of subentities of a given codimension.
Definition: albertagrid/entity.hh:108
static const int codimension
Definition: albertagrid/entity.hh:58
const Grid & grid() const
obtain a reference to the grid
Definition: albertagrid/entity.hh:142
Grid::template Codim< codim >::EntitySeed EntitySeed
Definition: albertagrid/entity.hh:68
static const int mydimension
Definition: albertagrid/entity.hh:59
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:148
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/entity.hh:71
GeometryType type() const
type of geometry of this entity
Definition: entity.cc:114
bool equals(const This &other) const
equality of entities
Definition: entity.cc:48
AlbertaGridEntity()
Definition: entity.cc:32
Definition: albertagrid/entity.hh:63
Grid::template Codim< cd >::Entity Entity
Definition: albertagrid/entity.hh:64
Definition: albertagrid/entity.hh:185
Grid::HierarchicIterator HierarchicIterator
Definition: albertagrid/entity.hh:213
EntitySeed seed() const
obtain entity seed
Definition: albertagrid/entity.hh:241
Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl
Definition: albertagrid/entity.hh:211
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:355
int twist() const
obtain twist
Definition: albertagrid/entity.hh:379
Grid::template Codim< 0 >::Geometry Geometry
Definition: albertagrid/entity.hh:209
bool hasFather() const
returns true if father entity exists
Definition: albertagrid/entity.hh:312
Grid::template Codim< 0 >::Entity Entity
Definition: albertagrid/entity.hh:207
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:373
int twist(int i) const
obtain twist of a subentity
Definition: albertagrid/entity.hh:386
AlbertaGridLevelIntersectionIterator ilevelbegin() const
Definition: albertagrid/entity.hh:289
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/entity.hh:218
Grid::template Codim< 0 >::EntitySeed EntitySeed
Definition: albertagrid/entity.hh:208
AlbertaGridLevelIntersectionIterator ilevelend() const
Definition: albertagrid/entity.hh:300
Grid::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: albertagrid/entity.hh:210
const Grid & grid() const
obtain a reference to the grid
Definition: albertagrid/entity.hh:367
unsigned int subEntities(unsigned int cd) const
Obtain the number of subentities of a given codimension.
Definition: albertagrid/entity.hh:251
Dune::AlbertaGridLeafIntersectionIterator< Grid > AlbertaGridLeafIntersectionIterator
Definition: albertagrid/entity.hh:215
AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator
Definition: albertagrid/entity.hh:216
Grid::template Codim< codim >::Entity Entity
Definition: albertagrid/entity.hh:204
Definition: albertagrid/entityseed.hh:18
Wrapper class for entities.
Definition: common/entity.hh:66
Default Implementations for EntityImp.
Definition: common/entity.hh:542
Grid abstract base class.
Definition: common/grid.hh:375
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:482
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition: common/grid.hh:390