dune-grid  2.5.1
albertagrid/entity.hh
Go to the documentation of this file.
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 
7 
11 
12 #if HAVE_ALBERTA
13 
14 namespace Dune
15 {
16 
17  // Forward Declarations
18  // --------------------
19 
20  template< int codim, class Grid >
22 
23  template< int codim, class Grid, bool leafIterator >
25 
26  template< class Grid >
28 
29  template< class Grid >
31 
32  template< class Grid >
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 
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 >;
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
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 
216 
218  typedef AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator;
219 
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  {
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
provides a wrapper for ALBERTA&#39;s el_info structure
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/entity.hh:72
bool hasFather() const
returns true if father entity exists
Definition: albertagrid/entity.hh:326
AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator
Definition: albertagrid/entity.hh:218
GeometryType type() const
type of geometry of this entity
Definition: entity.cc:112
Definition: albertagrid/entity.hh:45
Definition: albertagrid/entity.hh:27
#define ALBERTA
Definition: albertaheader.hh:27
Grid::template Codim< 0 >::EntitySeed EntitySeed
Definition: albertagrid/entity.hh:210
Grid::template Codim< cd >::Entity Entity
Definition: albertagrid/entity.hh:65
int level() const
level of this element
Definition: entity.cc:92
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:178
Definition: albertagrid/entity.hh:184
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
unsigned int subEntities(unsigned int cd) const
Obtain the number of subentities of a given codimension.
Definition: albertagrid/entity.hh:265
static const int mydimension
Definition: albertagrid/entity.hh:60
Definition: albertagrid/entityseed.hh:16
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:387
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/entity.hh:220
void setEntity(const This &other)
Definition: entity.cc:85
void setElement(const ElementInfo &elementInfo, int subEntity)
Definition: entity.cc:76
PartitionType partitionType() const
return partition type of this entity
Definition: entity.cc:38
AlbertaGridLevelIntersectionIterator ilevelend() const
Definition: albertagrid/entity.hh:314
int twist(int i) const
obtain twist of a subentity
Definition: albertagrid/entity.hh:400
unsigned int subEntities(unsigned int cd) const
Obtain the number of subentities of a given codimension.
Definition: albertagrid/entity.hh:109
[ provides Dune::Grid ]
Definition: agrid.hh:137
Grid::HierarchicIterator HierarchicIterator
Definition: albertagrid/entity.hh:215
int twist() const
obtain twist
Definition: albertagrid/entity.hh:155
const Grid & grid() const
obtain a reference to the grid
Definition: albertagrid/entity.hh:381
const Grid & grid() const
obtain a reference to the grid
Definition: albertagrid/entity.hh:143
Grid::template Codim< codim >::Entity Entity
Definition: albertagrid/entity.hh:206
Grid::template Codim< codim >::Geometry Geometry
Definition: albertagrid/entity.hh:70
static const int dimension
Definition: albertagrid/entity.hh:58
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition: entity.cc:60
Default Implementations for EntityImp.
Definition: common/entity.hh:568
EntitySeed seed() const
obtain entity seed
Definition: albertagrid/entity.hh:243
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:149
int count() const
Definition: albertagrid/entity.hh:252
AlbertaGridLevelIntersectionIterator ilevelbegin() const
Definition: albertagrid/entity.hh:303
Include standard header files.
Definition: agrid.hh:59
Definition: albertagrid/entity.hh:33
Geometry geometry() const
geometry of this entity
Definition: entity.cc:101
Grid::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: albertagrid/entity.hh:212
Grid::template Codim< 0 >::Geometry Geometry
Definition: albertagrid/entity.hh:211
Grid::template Codim< codim >::EntitySeed EntitySeed
Definition: albertagrid/entity.hh:69
int twist() const
obtain twist
Definition: albertagrid/entity.hh:393
Dune::AlbertaGridLeafIntersectionIterator< Grid > AlbertaGridLeafIntersectionIterator
Definition: albertagrid/entity.hh:217
Grid::template Codim< codim >::Entity Entity
Definition: albertagrid/entity.hh:68
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:131
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:486
Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl
Definition: albertagrid/entity.hh:213
Definition: albertagrid/entity.hh:24
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:369
Definition: misc.hh:145
void clearElement()
Definition: entity.cc:68
EntitySeed seed() const
obtain entity seed
Definition: albertagrid/entity.hh:99
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:373
Grid::template Codim< 0 >::Entity Entity
Definition: albertagrid/entity.hh:209
Definition: albertagrid/entity.hh:63
AlbertaGridEntity()
Definition: entity.cc:30
static const int codimension
Definition: albertagrid/entity.hh:59
Definition: albertagrid/entity.hh:30
EntityPointer implementation for AlbertaGrid.
Definition: albertagrid/entity.hh:21
bool equals(const This &other) const
equality of entities
Definition: entity.cc:46
The dimension of the world the grid lives in.
Definition: common/grid.hh:393