dune-grid  3.0-git
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 
85 
87  int level () const;
88 
91 
93  Geometry geometry () const;
94 
96  GeometryType type () const;
97 
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 >::Entity
184  };
185 
186  typedef typename Grid::template Codim< 0 >::Entity Entity;
187  typedef typename Grid::template Codim< 0 >::EntitySeed EntitySeed;
188  typedef typename Grid::template Codim< 0 >::Geometry Geometry;
189  typedef typename Grid::template Codim< 0 >::LocalGeometry LocalGeometry;
190  typedef typename Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
191 
193 
196 
198 
200  explicit AlbertaGridEntity ( const Grid &grid );
201 
203 
206 
208  int level () const;
209 
211  int boundaryId () const;
212 
214  Geometry geometry () const;
215 
217  GeometryType type () const;
218 
221 
228  template< int codim >
229  int count () const
230  {
232  }
233 
242  unsigned int subEntities (unsigned int codim) const
243  {
244  int n = dimension+1;
245  int k = dimension-codim+1;
246 
247  // binomial: n over k
248  int binomial=1;
249  for (int i=n-k+1; i<=n; i++)
250  binomial *= i;
251  for (long i=2; i<=k; i++)
252  binomial /= i;
253 
254  return binomial;
255  }
256 
267  template< int codim >
268  typename Grid::template Codim< codim >::Entity subEntity ( int i ) const;
269 
275  AlbertaGridLeafIntersectionIterator ileafbegin () const;
276 
278  AlbertaGridLeafIntersectionIterator ileafend () const;
279 
281  {
282  if( grid().maxLevel() == 0 )
283  return ileafbegin();
284  else
285  {
286  DUNE_THROW( NotImplemented, "method ilevelbegin not implemented for AlbertaGrid." );
287  return ileafend();
288  }
289  }
290 
292  {
293  return ileafend();
294  }
295 
297  bool isLeaf () const;
298 
301  Entity father () const;
303  bool hasFather () const
304  {
305  return (this->level()>0);
306  }
307 
316  LocalGeometry geometryInFather () const;
317 
322  HierarchicIterator hbegin (int maxlevel) const;
323 
325  HierarchicIterator hend (int maxlevel) const;
326 
328  bool isNew () const;
329 
331  bool mightVanish () const;
332 
335  bool hasBoundaryIntersections () const ;
336 
339 
341  bool equals ( const This &i ) const;
342 
343  // needed for LevelIterator to compare
344  ALBERTA EL_INFO *getElInfo () const;
345 
346  const ElementInfo &elementInfo () const
347  {
348  return elementInfo_;
349  }
350 
351  void clearElement ();
352  void setElement ( const ElementInfo &elementInfo, int subEntity );
353 
354  // same as setElInfo just with a entity given
355  void setEntity ( const This &other );
356 
358  const Grid &grid () const
359  {
360  return *grid_;
361  }
362 
364  int subEntity () const
365  {
366  return 0;
367  }
368 
370  int twist () const
371  {
372  return elementInfo().template twist< codimension >( subEntity() );
373  }
374 
376  template< int codim >
377  int twist ( int i ) const
378  {
379  return elementInfo().template twist< codim >( grid().generic2alberta( codim, i ) );
380  }
381 
382  private:
384  int nChild () const;
385 
387  const Grid *grid_;
388 
389  // Alberta element info
390  ElementInfo elementInfo_;
391  };
392 
393 } // namespace Dune
394 
395 #endif // #if HAVE_ALBERTA
396 
397 #endif // #ifndef DUNE_ALBERTA_ENTITY_HH
elementinfo.hh
provides a wrapper for ALBERTA's el_info structure
Dune::AlbertaGridEntity
Definition: albertagrid/entity.hh:45
Dune::AlbertaGridEntity< 0, dim, Grid >::ilevelbegin
AlbertaGridLevelIntersectionIterator ilevelbegin() const
Definition: albertagrid/entity.hh:280
Dune::AlbertaGridHierarchicIterator
Definition: albertagrid/entity.hh:27
Dune
Include standard header files.
Definition: agrid.hh:59
Dune::AlbertaGridEntity::Codim::Entity
Grid::template Codim< cd >::Entity Entity
Definition: albertagrid/entity.hh:65
Dune::AlbertaGrid
[ provides Dune::Grid ]
Definition: agrid.hh:137
Dune::AlbertaGridEntity< 0, dim, Grid >::twist
int twist() const
obtain twist
Definition: albertagrid/entity.hh:370
Dune::AlbertaGridEntity< 0, dim, Grid >::hasFather
bool hasFather() const
returns true if father entity exists
Definition: albertagrid/entity.hh:303
Dune::AlbertaGridTreeIterator
Definition: albertagrid/entity.hh:24
Dune::AlbertaGridEntity< 0, dim, Grid >::subEntities
unsigned int subEntities(unsigned int codim) const
Obtain the number of subentities of a given codimension.
Definition: albertagrid/entity.hh:242
Dune::AlbertaGridEntity::setElement
void setElement(const ElementInfo &elementInfo, int subEntity)
Definition: entity.cc:76
Dune::Alberta::NumSubEntities
Definition: misc.hh:145
Dune::PartitionType
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
Dune::AlbertaGridEntity< 0, dim, Grid >::AlbertaGridLeafIntersectionIterator
Dune::AlbertaGridLeafIntersectionIterator< Grid > AlbertaGridLeafIntersectionIterator
Definition: albertagrid/entity.hh:194
Dune::AlbertaGridEntity::geometry
Geometry geometry() const
geometry of this entity
Definition: entity.cc:101
Dune::VTK::GeometryType
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Dune::AlbertaGridEntity< 0, dim, Grid >::twist
int twist(int i) const
obtain twist of a subentity
Definition: albertagrid/entity.hh:377
Dune::AlbertaGridEntity< 0, dim, Grid >::count
int count() const
Definition: albertagrid/entity.hh:229
Dune::Entity
Wrapper class for entities.
Definition: common/entity.hh:61
Dune::AlbertaGridEntity::Entity
Grid::template Codim< codim >::Entity Entity
Definition: albertagrid/entity.hh:68
Dune::AlbertaGridEntityPointer
EntityPointer implementation for AlbertaGrid.
Definition: albertagrid/entity.hh:21
Dune::AlbertaGridEntity< 0, dim, Grid >::Geometry
Grid::template Codim< 0 >::Geometry Geometry
Definition: albertagrid/entity.hh:188
Dune::AlbertaGridEntity< 0, dim, Grid >::Entity
Grid::template Codim< 0 >::Entity Entity
Definition: albertagrid/entity.hh:186
Dune::AlbertaGridEntity::mydimension
static const int mydimension
Definition: albertagrid/entity.hh:60
Dune::AlbertaGridEntity::twist
int twist() const
obtain twist
Definition: albertagrid/entity.hh:132
Dune::Alberta::ElementInfo< dimension >
Dune::AlbertaGridEntity::Geometry
Grid::template Codim< codim >::Geometry Geometry
Definition: albertagrid/entity.hh:70
Dune::AlbertaGridEntity< 0, dim, Grid >::subEntity
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:364
Dune::Grid
Grid abstract base class.
Definition: common/grid.hh:373
Dune::AlbertaGridEntity::seed
EntitySeed seed() const
obtain entity seed
Definition: albertagrid/entity.hh:99
entityseed.hh
Dune::AlbertaGridEntity::codimension
static const int codimension
Definition: albertagrid/entity.hh:59
Dune::AlbertaGridEntitySeed
Definition: albertagrid/entityseed.hh:16
Dune::AlbertaGridEntity::AlbertaGridEntity
AlbertaGridEntity()
Definition: entity.cc:30
Dune::AlbertaGridEntity::equals
bool equals(const This &other) const
equality of entities
Definition: entity.cc:46
Dune::AlbertaGridEntity::subEntity
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:126
Dune::AlbertaGridEntity::elementInfo
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:108
Dune::AlbertaGridEntity< 0, dim, Grid >::LocalGeometry
Grid::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: albertagrid/entity.hh:189
Dune::AlbertaGridEntity::ElementInfo
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/entity.hh:72
Dune::AlbertaGridEntity< 0, dim, Grid >::GeometryImpl
Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl
Definition: albertagrid/entity.hh:190
Dune::AlbertaGridEntity::getElInfo
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition: entity.cc:60
Dune::AlbertaGridEntity::type
GeometryType type() const
type of geometry of this entity
Definition: entity.cc:112
Dune::AlbertaGridEntity< 0, dim, Grid >::grid
const Grid & grid() const
obtain a reference to the grid
Definition: albertagrid/entity.hh:358
Dune::Grid::HierarchicIterator
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
Dune::AlbertaGridEntity< 0, dim, Grid >::ilevelend
AlbertaGridLevelIntersectionIterator ilevelend() const
Definition: albertagrid/entity.hh:291
Dune::AlbertaGridLeafIntersectionIterator
Definition: albertagrid/entity.hh:33
ALBERTA
#define ALBERTA
Definition: albertaheader.hh:27
Dune::AlbertaGridEntity::grid
const Grid & grid() const
obtain a reference to the grid
Definition: albertagrid/entity.hh:120
entity.hh
Dune::AlbertaGridEntity::dimension
static const int dimension
Definition: albertagrid/entity.hh:58
Dune::Grid::dimensionworld
The dimension of the world the grid lives in.
Definition: common/grid.hh:393
Dune::AlbertaGridEntity< 0, dim, Grid >::elementInfo
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:346
Dune::AlbertaGridEntity< 0, dim, Grid >::HierarchicIterator
Grid::HierarchicIterator HierarchicIterator
Definition: albertagrid/entity.hh:192
Dune::AlbertaGridEntity< 0, dim, Grid >::AlbertaGridLevelIntersectionIterator
AlbertaGridLeafIntersectionIterator AlbertaGridLevelIntersectionIterator
Definition: albertagrid/entity.hh:195
geometry.hh
Dune::AlbertaGridEntity< 0, dim, Grid >::ElementInfo
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/entity.hh:197
Dune::AlbertaGridEntity::setEntity
void setEntity(const This &other)
Definition: entity.cc:85
Dune::AlbertaGridEntity::Codim
Definition: albertagrid/entity.hh:63
Dune::AlbertaGridEntity::partitionType
PartitionType partitionType() const
return partition type of this entity
Definition: entity.cc:38
Dune::AlbertaGridEntity::clearElement
void clearElement()
Definition: entity.cc:68
Dune::AlbertaGridEntity< 0, dim, Grid >::seed
EntitySeed seed() const
obtain entity seed
Definition: albertagrid/entity.hh:220
Dune::AlbertaGridEntity::level
int level() const
level of this element
Definition: entity.cc:92
Dune::AlbertaGridLeafIntersection
Definition: albertagrid/entity.hh:30
Dune::AlbertaGridEntity< 0, dim, Grid >::Codim::Entity
Grid::template Codim< codim >::Entity Entity
Definition: albertagrid/entity.hh:183
Dune::AlbertaGridEntity::EntitySeed
Grid::template Codim< codim >::EntitySeed EntitySeed
Definition: albertagrid/entity.hh:69
Dune::AlbertaGridEntity< 0, dim, Grid >::EntitySeed
Grid::template Codim< 0 >::EntitySeed EntitySeed
Definition: albertagrid/entity.hh:187
Dune::AlbertaGridEntity< 0, dim, Grid >
Definition: albertagrid/entity.hh:161
Dune::EntityDefaultImplementation
Default Implementations for EntityImp.
Definition: common/entity.hh:543