dune-grid  2.4.1-rc2
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 >::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 
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 
101  //***********************************************
102  // end of interface methods
103  //***********************************************
104 
106  ALBERTA EL_INFO *getElInfo () const;
107 
108  const ElementInfo &elementInfo () const { return elementInfo_; }
109 
111  bool equals ( const This &other ) const;
112 
113  void clearElement ();
114  void setElement ( const ElementInfo &elementInfo, int subEntity );
115 
116  // same as setElInfo just with a entity given
117  void setEntity ( const This &other );
118 
120  const Grid &grid () const
121  {
122  return *grid_;
123  }
124 
126  int subEntity () const
127  {
128  return subEntity_;
129  }
130 
132  int twist () const
133  {
134  return elementInfo().template twist< codimension >( subEntity() );
135  }
136 
137  private:
138  // grid this entity belong to
139  const Grid *grid_;
140 
141  // ALBERTA element info
142  ElementInfo elementInfo_;
143 
144  // number of the subentity within the element (in ALBERTA numbering)
145  int subEntity_;
146  };
147 
148 
149 
150  // AlbertaGridEntity for codimension 0
151  // -----------------------------------
152 
160  template< int dim, class Grid >
161  class AlbertaGridEntity< 0, dim, Grid >
162  : public EntityDefaultImplementation< 0, dim, Grid, AlbertaGridEntity >
163  {
165 
166  static const int dimworld = Grid::dimensionworld;
167 
168  friend class AlbertaGrid< dim, dimworld >;
171  template< int, class, bool > friend class AlbertaGridTreeIterator;
172  friend class AlbertaGridEntityPointer< 0, Grid >;
173 
174  public:
175  static const int dimension = dim;
176  static const int codimension = 0;
177  static const int mydimension = dimension - codimension;
178 
179  template< int codim >
180  struct Codim
181  {
182  typedef typename Grid::template Codim< codim >::EntityPointer
184  typedef typename Grid::template Codim< codim >::Entity
186  };
187 
188  typedef typename Grid::template Codim< 0 >::Entity Entity;
189  typedef typename Grid::template Codim< 0 >::EntitySeed EntitySeed;
190  typedef typename Grid::template Codim< 0 >::Geometry Geometry;
191  typedef typename Grid::template Codim< 0 >::LocalGeometry LocalGeometry;
192  typedef typename Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
193 
195  typedef typename Grid::template Codim< 0 >::EntityPointer EntityPointer;
196 
198  typedef AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator;
199 
201 
203  explicit AlbertaGridEntity ( const Grid &grid );
204 
206 
208  AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity );
209 
211  int level () const;
212 
214  int boundaryId () const;
215 
217  Geometry geometry () const;
218 
220  GeometryType type () const;
221 
223  EntitySeed seed () const { return EntitySeed( AlbertaGridEntitySeed< 0, Grid >(elementInfo() )); }
224 
231  template< int codim >
232  int count () const
233  {
235  }
236 
245  unsigned int subEntities (unsigned int codim) const
246  {
247  int n = dimension+1;
248  int k = dimension-codim+1;
249 
250  // binomial: n over k
251  int binomial=1;
252  for (int i=n-k+1; i<=n; i++)
253  binomial *= i;
254  for (long i=2; i<=k; i++)
255  binomial /= i;
256 
257  return binomial;
258  }
259 
270  template< int codim >
271  typename Grid::template Codim< codim >::Entity subEntity ( int i ) const;
272 
278  AlbertaGridLeafIntersectionIterator ileafbegin () const;
279 
281  AlbertaGridLeafIntersectionIterator ileafend () const;
282 
283  AlbertaGridLevelIntersectionIterator ilevelbegin () const
284  {
285  if( grid().maxLevel() == 0 )
286  return ileafbegin();
287  else
288  {
289  DUNE_THROW( NotImplemented, "method ilevelbegin not implemented for AlbertaGrid." );
290  return ileafend();
291  }
292  }
293 
294  AlbertaGridLevelIntersectionIterator ilevelend () const
295  {
296  return ileafend();
297  }
298 
300  bool isLeaf () const;
301 
304  Entity father () const;
306  bool hasFather () const
307  {
308  return (this->level()>0);
309  }
310 
319  LocalGeometry geometryInFather () const;
320 
325  HierarchicIterator hbegin (int maxlevel) const;
326 
328  HierarchicIterator hend (int maxlevel) const;
329 
331  bool isNew () const;
332 
334  bool mightVanish () const;
335 
338  bool hasBoundaryIntersections () const ;
339 
342 
344  bool equals ( const This &i ) const;
345 
346  // needed for LevelIterator to compare
347  ALBERTA EL_INFO *getElInfo () const;
348 
349  const ElementInfo &elementInfo () const
350  {
351  return elementInfo_;
352  }
353 
354  void clearElement ();
355  void setElement ( const ElementInfo &elementInfo, int subEntity );
356 
357  // same as setElInfo just with a entity given
358  void setEntity ( const This &other );
359 
361  const Grid &grid () const
362  {
363  return *grid_;
364  }
365 
367  int subEntity () const
368  {
369  return 0;
370  }
371 
373  int twist () const
374  {
375  return elementInfo().template twist< codimension >( subEntity() );
376  }
377 
379  template< int codim >
380  int twist ( int i ) const
381  {
382  return elementInfo().template twist< codim >( grid().generic2alberta( codim, i ) );
383  }
384 
385  private:
387  int nChild () const;
388 
390  const Grid *grid_;
391 
392  // Alberta element info
393  ElementInfo elementInfo_;
394  };
395 
396 } // namespace Dune
397 
398 #endif // #if HAVE_ALBERTA
399 
400 #endif // #ifndef DUNE_ALBERTA_ENTITY_HH
void setEntity(const This &other)
Definition: entity.cc:85
Definition: albertagrid/entityseed.hh:16
Grid::template Codim< 0 >::Entity Entity
Definition: albertagrid/entity.hh:188
int level() const
level of this element
Definition: entity.cc:92
void clearElement()
Definition: entity.cc:68
Grid::template Codim< codim >::EntitySeed EntitySeed
Definition: albertagrid/entity.hh:69
Definition: albertagrid/entity.hh:24
Grid::template Codim< codim >::EntityPointer EntityPointer
Definition: albertagrid/entity.hh:183
Geometry geometry() const
geometry of this entity
Definition: entity.cc:101
Definition: albertagrid/entity.hh:27
bool hasFather() const
returns true if father entity exists
Definition: albertagrid/entity.hh:306
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
Definition: albertagrid/entity.hh:33
Grid::template Codim< codim >::Entity Entity
Definition: albertagrid/entity.hh:185
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:178
Definition: misc.hh:145
EntityPointer implementation for AlbertaGrid.
Definition: albertagrid/entity.hh:21
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:367
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:512
int twist() const
obtain twist
Definition: albertagrid/entity.hh:373
Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl
Definition: albertagrid/entity.hh:192
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:408
static const int dimension
Definition: albertagrid/entity.hh:58
const Grid & grid() const
obtain a reference to the grid
Definition: albertagrid/entity.hh:120
EntitySeed seed() const
obtain entity seed
Definition: albertagrid/entity.hh:99
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:349
Dune::AlbertaGridLeafIntersectionIterator< Grid > AlbertaGridLeafIntersectionIterator
Definition: albertagrid/entity.hh:197
Grid::HierarchicIterator HierarchicIterator
Definition: albertagrid/entity.hh:194
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/entity.hh:72
AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator
Definition: albertagrid/entity.hh:198
#define ALBERTA
Definition: albertaheader.hh:27
Grid::template Codim< cd >::EntityPointer EntityPointer
Definition: albertagrid/entity.hh:65
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:126
[ provides Dune::Grid ]
Definition: agrid.hh:137
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition: entity.cc:60
AlbertaGridLevelIntersectionIterator ilevelbegin() const
Definition: albertagrid/entity.hh:283
Definition: albertagrid/entity.hh:30
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/entity.hh:200
Definition: albertagrid/entity.hh:63
Definition: albertagrid/entity.hh:161
int twist() const
obtain twist
Definition: albertagrid/entity.hh:132
Default Implementations for EntityImp.
Definition: common/entity.hh:739
AlbertaGridLevelIntersectionIterator ilevelend() const
Definition: albertagrid/entity.hh:294
EntitySeed seed() const
obtain entity seed
Definition: albertagrid/entity.hh:223
provides a wrapper for ALBERTA&#39;s el_info structure
static const int mydimension
Definition: albertagrid/entity.hh:60
Grid::template Codim< 0 >::EntitySeed EntitySeed
Definition: albertagrid/entity.hh:189
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:388
GeometryType type() const
type of geometry of this entity
Definition: entity.cc:112
void setElement(const ElementInfo &elementInfo, int subEntity)
Definition: entity.cc:76
Grid::template Codim< codim >::Geometry Geometry
Definition: albertagrid/entity.hh:70
Include standard header files.
Definition: agrid.hh:59
int twist(int i) const
obtain twist of a subentity
Definition: albertagrid/entity.hh:380
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:108
AlbertaGridEntity()
Definition: entity.cc:30
Grid::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: albertagrid/entity.hh:191
const Grid & grid() const
obtain a reference to the grid
Definition: albertagrid/entity.hh:361
int count() const
Definition: albertagrid/entity.hh:232
unsigned int subEntities(unsigned int codim) const
Obtain the number of subentities of a given codimension.
Definition: albertagrid/entity.hh:245
Grid::template Codim< codim >::Entity Entity
Definition: albertagrid/entity.hh:68
Grid::template Codim< 0 >::EntityPointer EntityPointer
Definition: albertagrid/entity.hh:195
PartitionType partitionType() const
return partition type of this entity
Definition: entity.cc:38
Grid::template Codim< 0 >::Geometry Geometry
Definition: albertagrid/entity.hh:190
Definition: albertagrid/entity.hh:45
static const int codimension
Definition: albertagrid/entity.hh:59