dune-grid  2.3.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 >::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 
83 
85  int level () const;
86 
89 
91  Geometry geometry () const;
92 
94  GeometryType type () const;
95 
98 
99  //***********************************************
100  // end of interface methods
101  //***********************************************
102 
104  ALBERTA EL_INFO *getElInfo () const;
105 
106  const ElementInfo &elementInfo () const { return elementInfo_; }
107 
109  bool equals ( const This &other ) const;
110 
111  void clearElement ();
112  void setElement ( const ElementInfo &elementInfo, int subEntity );
113 
114  // same as setElInfo just with a entity given
115  void setEntity ( const This &other );
116 
118  const Grid &grid () const
119  {
120  return *grid_;
121  }
122 
124  int subEntity () const
125  {
126  return subEntity_;
127  }
128 
130  int twist () const
131  {
132  return elementInfo().template twist< codimension >( subEntity() );
133  }
134 
135  private:
136  // grid this entity belong to
137  const Grid *grid_;
138 
139  // ALBERTA element info
140  ElementInfo elementInfo_;
141 
142  // number of the subentity within the element (in ALBERTA numbering)
143  int subEntity_;
144  };
145 
146 
147 
148  // AlbertaGridEntity for codimension 0
149  // -----------------------------------
150 
158  template< int dim, class Grid >
159  class AlbertaGridEntity< 0, dim, Grid >
160  : public EntityDefaultImplementation< 0, dim, Grid, AlbertaGridEntity >
161  {
163 
164  static const int dimworld = Grid::dimensionworld;
165 
166  friend class AlbertaGrid< dim, dimworld >;
169  template< int, class, bool > friend class AlbertaGridTreeIterator;
170  friend class AlbertaGridEntityPointer< 0, Grid >;
171 
172  public:
173  static const int dimension = dim;
174  static const int codimension = 0;
175  static const int mydimension = dimension - codimension;
176 
177  template< int codim >
178  struct Codim
179  {
180  typedef typename Grid::template Codim< codim >::EntityPointer
182  };
183 
184  typedef typename Grid::template Codim< 0 >::Entity Entity;
185  typedef typename Grid::template Codim< 0 >::EntitySeed EntitySeed;
186  typedef typename Grid::template Codim< 0 >::Geometry Geometry;
187  typedef typename Grid::template Codim< 0 >::LocalGeometry LocalGeometry;
188  typedef typename Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
189 
191  typedef typename Grid::template Codim< 0 >::EntityPointer EntityPointer;
192 
195 
197 
199  explicit AlbertaGridEntity ( const Grid &grid );
200 
203 
205  int level () const;
206 
208  int boundaryId () const;
209 
211  Geometry geometry () const;
212 
214  GeometryType type () const;
215 
218 
225  template< int codim >
226  int count () const
227  {
229  }
230 
241  template< int codim >
242  typename Codim< codim >::EntityPointer subEntity ( int i ) const;
243 
249  AlbertaGridLeafIntersectionIterator ileafbegin () const;
250 
252  AlbertaGridLeafIntersectionIterator ileafend () const;
253 
255  {
256  if( grid().maxLevel() == 0 )
257  return ileafbegin();
258  else
259  {
260  DUNE_THROW( NotImplemented, "method ilevelbegin not implemented for AlbertaGrid." );
261  return ileafend();
262  }
263  }
264 
266  {
267  return ileafend();
268  }
269 
271  bool isLeaf () const;
272 
275  EntityPointer father () const;
277  bool hasFather () const
278  {
279  return (this->level()>0);
280  }
281 
290  LocalGeometry geometryInFather () const;
291 
296  HierarchicIterator hbegin (int maxlevel) const;
297 
299  HierarchicIterator hend (int maxlevel) const;
300 
302  bool isNew () const;
303 
305  bool mightVanish () const;
306 
309  bool hasBoundaryIntersections () const ;
310 
313 
315  bool equals ( const This &i ) const;
316 
317  // needed for LevelIterator to compare
318  ALBERTA EL_INFO *getElInfo () const;
319 
320  const ElementInfo &elementInfo () const
321  {
322  return elementInfo_;
323  }
324 
325  void clearElement ();
326  void setElement ( const ElementInfo &elementInfo, int subEntity );
327 
328  // same as setElInfo just with a entity given
329  void setEntity ( const This &other );
330 
332  const Grid &grid () const
333  {
334  return *grid_;
335  }
336 
338  int subEntity () const
339  {
340  return 0;
341  }
342 
344  int twist () const
345  {
346  return elementInfo().template twist< codimension >( subEntity() );
347  }
348 
350  template< int codim >
351  int twist ( int i ) const
352  {
353  return elementInfo().template twist< codim >( grid().generic2alberta( codim, i ) );
354  }
355 
356  private:
358  int nChild () const;
359 
361  const Grid *grid_;
362 
363  // Alberta element info
364  ElementInfo elementInfo_;
365  };
366 
367 } // namespace Dune
368 
369 #endif // #if HAVE_ALBERTA
370 
371 #endif // #ifndef DUNE_ALBERTA_ENTITY_HH
Grid::template Codim< codim >::Entity Entity
Definition: albertagrid/entity.hh:68
const Grid & grid() const
obtain a reference to the grid
Definition: albertagrid/entity.hh:332
AlbertaGridLevelIntersectionIterator ilevelbegin() const
Definition: albertagrid/entity.hh:254
int level() const
level of this element
Definition: entity.cc:84
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:510
int twist() const
obtain twist
Definition: albertagrid/entity.hh:344
EntitySeed seed() const
obtain entity seed
Definition: albertagrid/entity.hh:217
Definition: albertagrid/entity.hh:24
PartitionType partitionType() const
return partition type of this entity
Definition: entity.cc:30
void setEntity(const This &other)
Definition: entity.cc:77
Definition: albertagrid/entity.hh:27
Grid::template Codim< 0 >::EntitySeed EntitySeed
Definition: albertagrid/entity.hh:185
static const int dimension
Definition: albertagrid/entity.hh:58
Grid::template Codim< codim >::EntityPointer EntityPointer
Definition: albertagrid/entity.hh:181
Dune::AlbertaGridLeafIntersectionIterator< Grid > AlbertaGridLeafIntersectionIterator
Definition: albertagrid/entity.hh:193
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Grid::template Codim< codim >::EntitySeed EntitySeed
Definition: albertagrid/entity.hh:69
Enables iteration over all codim zero entities in a subtree See also the documentation of Dune::Entit...
Definition: common/hierarchiciterator.hh:31
Geometry geometry() const
geometry of this entity
Definition: entity.cc:93
Grid::template Codim< cd >::EntityPointer EntityPointer
Definition: albertagrid/entity.hh:65
Grid::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: albertagrid/entity.hh:187
bool hasFather() const
returns true if father entity exists
Definition: albertagrid/entity.hh:277
Wrapper class for pointers to entities.
Definition: common/entitypointer.hh:91
Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl
Definition: albertagrid/entity.hh:188
Grid::template Codim< 0 >::Entity Entity
Definition: albertagrid/entity.hh:184
EntityPointer implementation for AlbertaGrid.
Definition: albertagrid/entity.hh:21
The dimension of the world the grid lives in.
Definition: common/grid.hh:406
static const int codimension
Definition: albertagrid/entity.hh:59
[ provides Dune::Grid ]
Definition: agrid.hh:137
int twist() const
obtain twist
Definition: albertagrid/entity.hh:130
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/entity.hh:72
Default Implementations for EntityImp.
Definition: common/entity.hh:552
provides a wrapper for ALBERTA's el_info structure
Definition: albertagrid/entity.hh:63
Definition: albertagrid/entity.hh:159
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:24
Grid::template Codim< 0 >::Geometry Geometry
Definition: albertagrid/entity.hh:186
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:320
Definition: albertagrid/entity.hh:33
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:386
int count() const
Definition: albertagrid/entity.hh:226
Definition: misc.hh:159
#define ALBERTA
Definition: albertaheader.hh:27
Grid::HierarchicIterator HierarchicIterator
Definition: albertagrid/entity.hh:190
Grid::template Codim< 0 >::EntityPointer EntityPointer
Definition: albertagrid/entity.hh:191
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/entity.hh:196
static const int mydimension
Definition: albertagrid/entity.hh:60
AlbertaGridEntity(const Grid &grid)
constructor
Definition: entity.cc:22
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition: entity.cc:52
AlbertaGridLevelIntersectionIterator ilevelend() const
Definition: albertagrid/entity.hh:265
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:338
Definition: albertagrid/entity.hh:30
int twist(int i) const
obtain twist of a subentity
Definition: albertagrid/entity.hh:351
void setElement(const ElementInfo &elementInfo, int subEntity)
Definition: entity.cc:68
Grid::template Codim< codim >::Geometry Geometry
Definition: albertagrid/entity.hh:70
AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator
Definition: albertagrid/entity.hh:194
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:124
Definition: albertagrid/entity.hh:45
bool equals(const This &other) const
equality of entities
Definition: entity.cc:38
const Grid & grid() const
obtain a reference to the grid
Definition: albertagrid/entity.hh:118
EntitySeed seed() const
obtain entity seed
Definition: albertagrid/entity.hh:97
GeometryType type() const
type of geometry of this entity
Definition: entity.cc:104
Definition: albertagrid/entityseed.hh:16
void clearElement()
Definition: entity.cc:60
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:106