DUNE PDELab (git)

entity.hh
1// SPDX-FileCopyrightText: Copyright © 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
8#include <dune/grid/common/entity.hh>
9
11#include <dune/grid/albertagrid/entityseed.hh>
12#include <dune/grid/albertagrid/geometry.hh>
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
71 typedef Alberta::ElementInfo< dimension > ElementInfo;
72
73 private:
74 typedef typename Grid::Traits::template Codim< codim >::GeometryImpl GeometryImpl;
75
76 public:
78 explicit AlbertaGridEntity ( const Grid &grid );
79
81
83 AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity );
84
86 int level () const;
87
90
92 Geometry geometry () const;
93
95 GeometryType type () const;
96
98 EntitySeed seed () const { return EntitySeed( AlbertaGridEntitySeed< codim, Grid >( elementInfo(), subEntity() ) ); }
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
204 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
213 typedef typename Grid::HierarchicIterator HierarchicIterator;
214
215 typedef Dune::AlbertaGridLeafIntersectionIterator< Grid > AlbertaGridLeafIntersectionIterator;
216 typedef AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator;
217
218 typedef Alberta::ElementInfo< dimension > ElementInfo;
219
221 explicit AlbertaGridEntity ( const Grid &grid );
222
224
226 AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity );
227
229 int level () const;
230
232 int boundaryId () const;
233
235 Geometry geometry () const;
236
238 GeometryType type () const;
239
241 EntitySeed seed () const { return EntitySeed( AlbertaGridEntitySeed< 0, Grid >(elementInfo() )); }
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
289 AlbertaGridLevelIntersectionIterator ilevelbegin () const
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
300 AlbertaGridLevelIntersectionIterator ilevelend () const
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
EntitySeed seed() const
obtain entity seed
Definition: entity.hh:241
int twist() const
obtain twist
Definition: entity.hh:379
bool hasFather() const
returns true if father entity exists
Definition: entity.hh:312
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: entity.hh:373
int twist(int i) const
obtain twist of a subentity
Definition: entity.hh:386
const Grid & grid() const
obtain a reference to the grid
Definition: entity.hh:367
unsigned int subEntities(unsigned int cd) const
Obtain the number of subentities of a given codimension.
Definition: entity.hh:251
Definition: entity.hh:46
int twist() const
obtain twist
Definition: entity.hh:154
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition: entity.cc:62
int level() const
level of this element
Definition: entity.cc:94
EntitySeed seed() const
obtain entity seed
Definition: entity.hh:98
PartitionType partitionType() const
return partition type of this entity
Definition: entity.cc:40
Geometry geometry() const
geometry of this entity
Definition: entity.cc:103
unsigned int subEntities(unsigned int cd) const
Obtain the number of subentities of a given codimension.
Definition: entity.hh:108
const Grid & grid() const
obtain a reference to the grid
Definition: entity.hh:142
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: entity.hh:148
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
Definition: hierarchiciterator.hh:29
Definition: treeiterator.hh:189
[ provides Dune::Grid ]
Definition: agrid.hh:109
Default Implementations for EntityImp.
Definition: entity.hh:542
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Grid abstract base class.
Definition: 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: grid.hh:482
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:390
Default exception for dummy implementations.
Definition: exceptions.hh:263
provides a wrapper for ALBERTA's el_info structure
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
Dune namespace.
Definition: alignedallocator.hh:13
static constexpr T binomial(const T &n, const T &k) noexcept
calculate the binomial coefficient n over k as a constexpr
Definition: math.hh:131
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)