Dune Core Modules (2.5.2)

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 
14 namespace 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 
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 
84  AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity );
85 
87  int level () const;
88 
91 
93  Geometry geometry () const;
94 
96  GeometryType type () const;
97 
99  EntitySeed seed () const { return EntitySeed( AlbertaGridEntitySeed< codim, Grid >( elementInfo(), subEntity() ) ); }
100 
109  unsigned int subEntities ( unsigned int cd ) const
110  {
111  int n = mydimension+1;
112  int k = dimension-cd+1;
113 
114  // binomial: n over k
115  int binomial=1;
116  for (int i=n-k+1; i<=n; i++)
117  binomial *= i;
118  for (long i=2; i<=k; i++)
119  binomial /= i;
120 
121  return binomial;
122  }
123 
124  //***********************************************
125  // end of interface methods
126  //***********************************************
127 
129  ALBERTA EL_INFO *getElInfo () const;
130 
131  const ElementInfo &elementInfo () const { return elementInfo_; }
132 
134  bool equals ( const This &other ) const;
135 
136  void clearElement ();
137  void setElement ( const ElementInfo &elementInfo, int subEntity );
138 
139  // same as setElInfo just with a entity given
140  void setEntity ( const This &other );
141 
143  const Grid &grid () const
144  {
145  return *grid_;
146  }
147 
149  int subEntity () const
150  {
151  return subEntity_;
152  }
153 
155  int twist () const
156  {
157  return elementInfo().template twist< codimension >( subEntity() );
158  }
159 
160  private:
161  // grid this entity belong to
162  const Grid *grid_;
163 
164  // ALBERTA element info
165  ElementInfo elementInfo_;
166 
167  // number of the subentity within the element (in ALBERTA numbering)
168  int subEntity_;
169  };
170 
171 
172 
173  // AlbertaGridEntity for codimension 0
174  // -----------------------------------
175 
183  template< int dim, class Grid >
184  class AlbertaGridEntity< 0, dim, Grid >
185  : public EntityDefaultImplementation< 0, dim, Grid, AlbertaGridEntity >
186  {
188 
189  static const int dimworld = Grid::dimensionworld;
190 
191  friend class AlbertaGrid< dim, dimworld >;
192  friend class AlbertaGridLeafIntersection< Grid >;
193  friend class AlbertaGridHierarchicIterator< Grid >;
194  template< int, class, bool > friend class AlbertaGridTreeIterator;
195  friend class AlbertaGridEntityPointer< 0, Grid >;
196 
197  public:
198  static const int dimension = dim;
199  static const int codimension = 0;
200  static const int mydimension = dimension - codimension;
201 
202  template< int codim >
203  struct Codim
204  {
205  typedef typename Grid::template Codim< codim >::Entity
206  Entity;
207  };
208 
209  typedef typename Grid::template Codim< 0 >::Entity Entity;
210  typedef typename Grid::template Codim< 0 >::EntitySeed EntitySeed;
211  typedef typename Grid::template Codim< 0 >::Geometry Geometry;
212  typedef typename Grid::template Codim< 0 >::LocalGeometry LocalGeometry;
213  typedef typename Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
214 
215  typedef typename Grid::HierarchicIterator HierarchicIterator;
216 
217  typedef Dune::AlbertaGridLeafIntersectionIterator< Grid > AlbertaGridLeafIntersectionIterator;
218  typedef AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator;
219 
220  typedef Alberta::ElementInfo< dimension > ElementInfo;
221 
223  explicit AlbertaGridEntity ( const Grid &grid );
224 
226 
228  AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity );
229 
231  int level () const;
232 
234  int boundaryId () const;
235 
237  Geometry geometry () const;
238 
240  GeometryType type () const;
241 
243  EntitySeed seed () const { return EntitySeed( AlbertaGridEntitySeed< 0, Grid >(elementInfo() )); }
244 
251  template< int codim >
252  int count () const
253  {
254  return Alberta::NumSubEntities< dimension, codim >::value;
255  }
256 
265  unsigned int subEntities ( unsigned int cd ) const
266  {
267  int n = mydimension+1;
268  int k = dimension-cd+1;
269 
270  // binomial: n over k
271  int binomial=1;
272  for (int i=n-k+1; i<=n; i++)
273  binomial *= i;
274  for (long i=2; i<=k; i++)
275  binomial /= i;
276 
277  return binomial;
278  }
279 
290  template< int codim >
291  typename Grid::template Codim< codim >::Entity subEntity ( int i ) const;
292 
298  AlbertaGridLeafIntersectionIterator ileafbegin () const;
299 
301  AlbertaGridLeafIntersectionIterator ileafend () const;
302 
303  AlbertaGridLevelIntersectionIterator ilevelbegin () const
304  {
305  if( grid().maxLevel() == 0 )
306  return ileafbegin();
307  else
308  {
309  DUNE_THROW( NotImplemented, "method ilevelbegin not implemented for AlbertaGrid." );
310  return ileafend();
311  }
312  }
313 
314  AlbertaGridLevelIntersectionIterator ilevelend () const
315  {
316  return ileafend();
317  }
318 
320  bool isLeaf () const;
321 
324  Entity father () const;
326  bool hasFather () const
327  {
328  return (this->level()>0);
329  }
330 
339  LocalGeometry geometryInFather () const;
340 
345  HierarchicIterator hbegin (int maxlevel) const;
346 
348  HierarchicIterator hend (int maxlevel) const;
349 
351  bool isNew () const;
352 
354  bool mightVanish () const;
355 
358  bool hasBoundaryIntersections () const ;
359 
362 
364  bool equals ( const This &i ) const;
365 
366  // needed for LevelIterator to compare
367  ALBERTA EL_INFO *getElInfo () const;
368 
369  const ElementInfo &elementInfo () const
370  {
371  return elementInfo_;
372  }
373 
374  void clearElement ();
375  void setElement ( const ElementInfo &elementInfo, int subEntity );
376 
377  // same as setElInfo just with a entity given
378  void setEntity ( const This &other );
379 
381  const Grid &grid () const
382  {
383  return *grid_;
384  }
385 
387  int subEntity () const
388  {
389  return 0;
390  }
391 
393  int twist () const
394  {
395  return elementInfo().template twist< codimension >( subEntity() );
396  }
397 
399  template< int codim >
400  int twist ( int i ) const
401  {
402  return elementInfo().template twist< codim >( grid().generic2alberta( codim, i ) );
403  }
404 
405  private:
407  int nChild () const;
408 
410  const Grid *grid_;
411 
412  // Alberta element info
413  ElementInfo elementInfo_;
414  };
415 
416 } // namespace Dune
417 
418 #endif // #if HAVE_ALBERTA
419 
420 #endif // #ifndef DUNE_ALBERTA_ENTITY_HH
EntityPointer implementation for AlbertaGrid.
Definition: entitypointer.hh:19
EntitySeed seed() const
obtain entity seed
Definition: entity.hh:243
int count() const
Definition: entity.hh:252
int twist() const
obtain twist
Definition: entity.hh:393
bool hasFather() const
returns true if father entity exists
Definition: entity.hh:326
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: entity.hh:387
int twist(int i) const
obtain twist of a subentity
Definition: entity.hh:400
const Grid & grid() const
obtain a reference to the grid
Definition: entity.hh:381
unsigned int subEntities(unsigned int cd) const
Obtain the number of subentities of a given codimension.
Definition: entity.hh:265
Definition: entity.hh:47
const Grid & grid() const
obtain a reference to the grid
Definition: entity.hh:143
int twist() const
obtain twist
Definition: entity.hh:155
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:99
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:109
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: entity.hh:149
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:29
Definition: treeiterator.hh:182
[ provides Dune::Grid ]
Definition: agrid.hh:140
Default Implementations for EntityImp.
Definition: entity.hh:569
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:268
Grid abstract base class.
Definition: grid.hh:373
@ dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:393
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
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
int binomial(int upper, int lower)
calculate
Definition: simplex.cc:294
Dune namespace.
Definition: alignment.hh:11
Static tag representing a codimension.
Definition: dimension.hh:22
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)