Dune Core Modules (2.4.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_ALU2DGRIDENTITY_HH
4 #define DUNE_ALU2DGRIDENTITY_HH
5 
6 // System includes
7 
8 // Dune includes
9 #include <dune/grid/common/entity.hh>
10 //#include <dune/grid/common/intersectioniteratorwrapper.hh>
11 
12 // Local includes
13 #include <dune/grid/alugrid/2d/intersection.hh>
14 #include <dune/grid/alugrid/2d/iterator.hh>
15 #include <dune/grid/alugrid/2d/entityseed.hh>
16 
17 namespace Dune {
18  // Forward declarations
19  template<int cd, int dim, class GridImp>
20  class ALU2dGridEntity;
21  template<int cd, PartitionIteratorType pitype, class GridImp >
22  class ALU2dGridLevelIterator;
23  template< int codim, class GridImp >
24  class ALU2dGridEntityPointer;
25  template<int mydim, int coorddim, class GridImp>
26  class ALU2dGridGeometry;
27  template<class GridImp>
28  class ALU2dGridHierarchicIterator;
29  template<class GridImp>
30  class ALU2dGridLevelIntersectionIterator;
31  template<class GridImp>
32  class ALU2dGridLeafIntersectionIterator;
33  template<class GridImp>
34  class ALU2dGridIntersectionIterator;
35  template<int codim, PartitionIteratorType, class GridImp>
36  class ALU2dGridLeafIterator;
37  template< int dim, int dimworld, ALU2DSPACE ElementType eltype >
38  class ALU2dGrid;
39 
40  //**********************************************************************
41  //
42  // --ALU2dGridEntity
43  // --Entity
44  //
45  //**********************************************************************
52  template<int cd, int dim, class GridImp>
54  public EntityDefaultImplementation <cd,dim,GridImp,ALU2dGridEntity>
55  {
56  static const int dimworld = GridImp::dimensionworld;
57  static const ALU2DSPACE ElementType eltype = GridImp::elementType;
58 
59  friend class ALU2dGrid< dim, dimworld, eltype >;
60  friend class ALU2dGridIntersectionIterator < GridImp >;
61  friend class ALU2dGridIntersectionIterator < const GridImp >;
62  friend class ALU2dGridLevelIntersectionIterator < GridImp >;
63  friend class ALU2dGridLevelIntersectionIterator < const GridImp >;
64  friend class ALU2dGridLeafIntersectionIterator < GridImp >;
65  friend class ALU2dGridLeafIntersectionIterator < const GridImp >;
66  friend class ALU2dGridHierarchicIterator < const GridImp >;
67  friend class ALU2dGridHierarchicIterator < GridImp >;
68  friend class ALU2dGridLevelIterator <0,All_Partition,GridImp>;
69  friend class ALU2dGridLevelIterator <1,All_Partition,GridImp>;
70  friend class ALU2dGridLevelIterator <2,All_Partition,GridImp>;
71  friend class ALU2dGridLeafIterator <0, All_Partition,GridImp>;
72  friend class ALU2dGridLeafIterator <1, All_Partition,GridImp>;
73  friend class ALU2dGridLeafIterator <2, All_Partition,GridImp>;
74  friend class ALU2dGridMakeableEntity<0,dim,GridImp>;
75 
76  friend class ALU2dGridHierarchicIndexSet<dim,dimworld,eltype>;
77 
78  typedef typename ALU2dImplTraits< dimworld, eltype >::HElementType HElementType ;
79 
80  typedef typename GridImp::Traits::template Codim< cd >::GeometryImpl GeometryImpl;
81 
82  public:
83  typedef typename GridImp :: GridObjectFactoryType FactoryType;
84 
85  typedef typename Dune::ALU2dImplTraits< dimworld, eltype >::template Codim<cd>::InterfaceType ElementType;
86  typedef typename Dune::ALU2dImplTraits< dimworld, eltype >::template Codim<2>::InterfaceType VertexType;
87 
89  typedef typename GridImp::template Codim<cd>::Entity Entity;
91  typedef typename GridImp::template Codim<cd>::Geometry Geometry;
92 
94  typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
95 
97  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
98 
100  int level () const;
101 
103  ALU2dGridEntity(const FactoryType& factory, int level);
104 
107 
109  Geometry geometry () const;
110 
112  GeometryType type() const ;
113 
116 
121  void setElement(const ElementType &element, int face=-1, int level = -1) const;
122  void setElement(const EntitySeed& seed ) const;
123  void setElement(const HElementType & el, const VertexType & vx);
124  void setElement(const ALU2dGridEntity & org) const
125  {
126  setElement(*(org.item_), org.face_);
127  }
128 
130  bool equals ( const ALU2dGridEntity<cd,dim,GridImp> & org ) const;
131 
135 
140  int boundaryId () const;
141 
147 
150 
152  const GridImp& grid() const { return factory_.grid(); }
153 
155  const FactoryType& factory() const { return factory_; }
156 
158  ElementType& getItem() const
159  {
160  assert( item_ );
161  return *item_;
162  }
163 
165  EntitySeed seed() const
166  {
167  return EntitySeed( getItem(), level(), getFace() );
168  }
169 
170  // return internal face
171  int getFace() const { return face_; }
172 
174  int getIndex () const;
175 
176  private:
178  const FactoryType& factory_;
179 
181  mutable ElementType * item_;
183 
184  mutable GeometryImpl geoObj_;
185 
186  mutable int level_;
187  mutable int face_;
188  };
189 
203  //***********************
204  //
205  // --ALU2dGridEntity
206  // --0Entity
207  //
208  //***********************
209  template<int dim, class GridImp>
210  class ALU2dGridEntity<0,dim,GridImp>
211  : public EntityDefaultImplementation<0,dim,GridImp,ALU2dGridEntity>
212  {
213  static const int dimworld = GridImp::dimensionworld;
214  static const ALU2DSPACE ElementType eltype = GridImp::elementType;
215 
216  friend class ALU2dGrid< dim, dimworld, eltype >;
217  friend class ALU2dGridIntersectionIterator < GridImp >;
218  friend class ALU2dGridIntersectionIterator < const GridImp >;
219  friend class ALU2dGridLevelIntersectionIterator < GridImp >;
220  friend class ALU2dGridLevelIntersectionIterator < const GridImp >;
221  friend class ALU2dGridLeafIntersectionIterator < GridImp >;
222  friend class ALU2dGridLeafIntersectionIterator < const GridImp >;
223  friend class ALU2dGridHierarchicIterator < const GridImp >;
224  friend class ALU2dGridHierarchicIterator < GridImp >;
225  friend class ALU2dGridLevelIterator <0,All_Partition,GridImp>;
226  friend class ALU2dGridLevelIterator <1,All_Partition,GridImp>;
227  friend class ALU2dGridLevelIterator <2,All_Partition,GridImp>;
228  friend class ALU2dGridLeafIterator <0, All_Partition,GridImp>;
229  friend class ALU2dGridLeafIterator <1, All_Partition,GridImp>;
230  friend class ALU2dGridLeafIterator <2, All_Partition,GridImp>;
231  friend class ALU2dGridMakeableEntity<0,dim,GridImp>;
232 
233  friend class ALU2dGridHierarchicIndexSet<dim,dimworld,eltype>;
234 
235  typedef typename ALU2dImplTraits< dimworld, eltype >::HElementType HElementType ;
236 
237  typedef typename GridImp::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
238  typedef typename GridImp::Traits::template Codim< 0 >::LocalGeometryImpl LocalGeometryImpl;
239 
240  public:
241  typedef typename GridImp :: GridObjectFactoryType FactoryType;
242 
244  typedef typename GridImp::template Codim<0>::Geometry Geometry;
246  typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
247 
249  typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
250 
255 
257  typedef typename GridImp::template Codim<0>::Entity Entity;
259  //typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
261 
262  template <int cd>
263  struct Codim
264  {
265  typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer;
266  };
267 
269  ALU2dGridEntity(const FactoryType& factory, int level);
270 
273 
275  int level () const ;
276 
278  Geometry geometry () const;
279 
281  GeometryType type() const ;
282 
286  template<int cc>
287  int count () const
288  {
289  assert( item_ );
290  return (cc==0) ? 1 : item_->numvertices();
291  }
292 
296  unsigned int subEntities (unsigned int codim) const
297  {
298  assert( item_ );
299  return (codim==0) ? 1 : item_->numvertices();
300  }
301 
306  int boundaryId () const {
307  // elements are always inside of our Domain
308  return 0;
309  }
310 
317  // As ibegin() and iend() are deprecated these methods will deliver a LeafIntersectionIterator
319  DUNE_DEPRECATED_MSG("Use ileafbegin() instead.")
320  {
321  return ileafbegin();
322  }
326  DUNE_DEPRECATED_MSG("Use ileafend() instead.")
327  {
328  return ileafend();
329  }
330 
331  ALU2dGridLevelIntersectionIteratorType ilevelbegin () const
332  {
333  return ALU2dGridLevelIntersectionIteratorType( *this, this->level(),false);
334  }
335  ALU2dGridLevelIntersectionIteratorType ilevelend () const
336  {
337  return ALU2dGridLevelIntersectionIteratorType( *this, this->level(),true);
338  }
339  ALU2dGridLeafIntersectionIteratorType ileafbegin () const
340  {
341  return ALU2dGridLeafIntersectionIteratorType( *this, this->level(), false);
342  }
343  ALU2dGridLeafIntersectionIteratorType ileafend () const
344  {
345  return ALU2dGridLeafIntersectionIteratorType( *this, this->level(),true);
346  }
347 
349  bool isLeaf () const;
350 
353  EntityPointer father () const;
354 
356  bool hasFather () const
357  {
358  return (this->level()>0);
359  }
360 
366  {
367  return ALU2dGridHierarchicIterator<GridImp> (factory(), *item_ , maxLevel,false);
368  }
369 
372  {
373  return ALU2dGridHierarchicIterator<GridImp> (factory(), *item_, maxLevel,true);
374  }
375 
378  template <int cc>
379  typename Codim<cc>::EntityPointer entity (int i) const;
380 
383  template< int codim >
384  typename Codim< codim >::EntityPointer subEntity ( int i ) const
385  {
386  int j = i;
387  // apply mapping for codim 1
388  // dune to alu
389  if( codim == 1 )
390  {
391  if( item_->numvertices() == 3 )
392  j = 2 - i;
393  else
394  switch (i) { case 0 : j=2;break;
395  case 1 : j=0;break;
396  case 2 : j=3;break;
397  case 3 : j=1;break;}
398  }
399  else if ( codim == 2 )
400  {
401  if( item_->numvertices() == 4 )
402  {
403  switch (i) { case 0 : j=0;break;
404  case 1 : j=1;break;
405  case 2 : j=3;break;
406  case 3 : j=2;break;}
407  }
408  }
409  return entity< codim >( j );
410  }
411 
414  {
415 #if ALU2DGRID_PARALLEL
416  return grid().rankManager().partitionType( item_->getIndex() );
417 #else
418  return InteriorEntity;
419 #endif
420  }
421 
428  template <int cc>
429  int subBoundaryId ( int i ) const;
430 
431 
443 
445  bool mightVanish () const
446  {
447  return ((item_->is(ALU2DSPACE Refco::crs))==1);
448  }
449 
450  bool isNew () const
451  {
452  return ((item_->wasRefined())==1);
453  }
454 
455  //***************************************************************
456  // Interface for Adaptation
457  //***************************************************************
458 
459  public:
463  bool mark(int refCount) const;
464 
466  int getMark() const;
467 
471  void setElement(const HElementType &element, int face=-1, int level = -1) const;
472  void setElement(const EntitySeed& seed ) const;
473 
474  void setElement(const ALU2dGridEntity & org) const {
475  setElement(*(org.item_));
476  }
477 
479  void reset ( int l );
480 
483 
485  bool equals ( const ALU2dGridEntity<0,dim,GridImp> & org ) const;
486 
487  // return reference to HElement (needed by IntersectionIterator)
488  HElementType & getItem() const
489  {
490  assert( item_ );
491  return *item_;
492  }
493 
495  EntitySeed seed() const
496  {
497  return EntitySeed( getItem() );
498  }
499 
501  const GridImp& grid() const { return factory_.grid(); }
502 
504  const FactoryType& factory() const { return factory_; }
505 
506  // return internal face
507  int getFace() const { return -1; }
508 
510  int getIndex () const;
511 
512  private:
514  int nChild () const;
515 
519  template<int cc> int getSubIndex (int i) const;
520 
521  int subIndex (int i, unsigned int codim) const;
522 
524  const FactoryType& factory_;
525 
527  mutable HElementType *item_;
528 
530  mutable GeometryImpl geoObj_;
531 
533  mutable bool isLeaf_;
534 
535  }; // end of ALU2dGridEntity codim = 0
536 
537 
538  //**********************************************************************
539  //
540  // --ALU2dGridEntityPointer
541  // --EntityPointer
542  // --EnPointer
543  //**********************************************************************
547  template< int codim, class GridImp >
549  {
550  // type of this class
552 
553  static const int dim = GridImp::dimension;
554  static const int dimworld = GridImp::dimensionworld;
555  static const ALU2DSPACE ElementType eltype = GridImp::elementType;
556 
557  typedef typename Dune::ALU2dImplTraits< dimworld, eltype >::template Codim<codim>::InterfaceType ElementType;
558 
559  public:
560  typedef typename GridImp :: GridObjectFactoryType FactoryType;
561 
562  enum { codimension = codim };
563 
565  typedef typename GridImp::template Codim<codimension>::Entity Entity;
566 
568  typedef typename GridImp::template Codim<codimension>::EntitySeed EntitySeed;
572 
574 
576  ALU2dGridEntityPointer ( const FactoryType& factory,
577  const ElementType &item,
578  int face = -1,
579  int level = -1
580  );
581 
583  ALU2dGridEntityPointer(const FactoryType& factory, const EntitySeed& seed) ;
584 
587 
589  ALU2dGridEntityPointer(const FactoryType& factory) ;
590 
593 
596 
598  // this may have to be changed!
599  bool equals (const ThisType & i) const;
600 
602  Entity & dereference() const ;
603 
605  int level () const;
606 
608  ThisType & operator = (const ThisType & org);
609 
611  const GridImp& grid() const { return factory_.grid(); }
612 
613  protected:
614  EntityImp & entityImp();
615  const EntityImp & entityImp() const;
616 
618  void done ();
619 
621  void updateEntityPointer( ElementType * item, int face=-1, int level=-1 );
622 
624  const FactoryType& factory_;
625 
628 
630  mutable EntityObj * entity_;
631  };
632 
633 } // end namespace Dune
634 
635 #include "entity_imp.cc"
636 #endif
const GridImp & grid() const
return reference top grid
Definition: entity.hh:611
void updateEntityPointer(ElementType *item, int face=-1, int level=-1)
update underlying item pointer and set entity
ThisType & operator=(const ThisType &org)
assigment operator
Entity & dereference() const
dereferencing
ALU2dGridEntity< codimension, dim, GridImp > EntityImp
tpye of stored entity (implementation)
Definition: entity.hh:570
void done()
has to be called when iterator is finished
ALU2dGridEntityPointer(const EntityImp &entity)
Constructor for EntityPointer init of Level- and LeafIterator.
int level() const
ask for level of entities
GridImp::template Codim< codimension >::EntitySeed EntitySeed
type of the seed
Definition: entity.hh:568
GridImp::template Codim< codimension >::Entity Entity
type of stored entity (interface)
Definition: entity.hh:565
ALU2dGridEntityPointer(const FactoryType &factory, const ElementType &item, int face=-1, int level=-1)
Constructor for EntityPointer that points to an element.
EntityObj * entity_
entity that this EntityPointer points to
Definition: entity.hh:630
const FactoryType & factory_
reference to entity factory
Definition: entity.hh:624
~ALU2dGridEntityPointer()
Destructor.
bool equals(const ThisType &i) const
equality
ALU2dGridEntityPointer(const FactoryType &factory, const EntitySeed &seed)
Constructor for EntityPointer init of Level- and LeafIterator.
ALU2dGridEntityPointer(const ThisType &org)
Copy Constructor.
ALU2dGridEntityPointer(const FactoryType &factory)
Constructor for EntityPointer init of Level- and LeafIterator.
EntitySeed seed_
the essential information
Definition: entity.hh:627
EntitySeed seed() const
return seed of entity
Definition: entity.hh:495
ALU2dGridEntityPointer< 0, GridImp > EntityPointer
tpye of entitypointer interface
Definition: entity.hh:260
int subBoundaryId(int i) const
The boundaryId of the i-th subentity of codimension cc
void setElement(const HElementType &element, int face=-1, int level=-1) const
void reset(int l)
set actual walk level
int level() const
level of this element
Geometry geometry() const
geometry of this entity
int getIndex() const
index is unique within the grid hierachie and per codim
Codim< codim >::EntityPointer subEntity(int i) const
Definition: entity.hh:384
GridImp::template Codim< 0 >::Entity Entity
type of entity interface
Definition: entity.hh:257
int getMark() const
return current adaptation mark of element
ALU2dGridIntersectionIteratorType iend() const
Definition: entity.hh:325
PartitionType partitionType() const
return partition type of this entity ( see grid.hh )
Definition: entity.hh:413
bool mightVanish() const
The former state() method has been replaced by:
Definition: entity.hh:445
bool hasFather() const
returns true if father entity exists
Definition: entity.hh:356
ALU2dGridEntity(const FactoryType &factory, int level)
Constructor creating empty Entity.
ALU2dGridEntity(const ALU2dGridEntity &org)
Constructor creating empty Entity.
GridImp::template Codim< 0 >::LocalGeometry LocalGeometry
type of corresponding interface local geometry
Definition: entity.hh:246
GeometryType type() const
return type of geometry
int boundaryId() const
Id of the boundary which is associated with the entity, returns 0 for inner entities,...
Definition: entity.hh:306
GridImp::template Codim< 0 >::Geometry Geometry
type of our Geometry interface
Definition: entity.hh:244
int count() const
Definition: entity.hh:287
ALU2dGridHierarchicIterator< GridImp > hbegin(int maxLevel) const
Definition: entity.hh:365
const FactoryType & factory() const
return reference to factory
Definition: entity.hh:504
LeafIntersectionIteratorWrapper< GridImp > ALU2dGridLeafIntersectionIteratorType
tpye of intersection iterator
Definition: entity.hh:252
const GridImp & grid() const
return reference to grid
Definition: entity.hh:501
Codim< cc >::EntityPointer entity(int i) const
bool isLeaf() const
returns true if Entity is leaf (i.e. has no children)
ALU2dGridHierarchicIterator< GridImp > hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: entity.hh:371
GridImp::template Codim< 0 >::EntitySeed EntitySeed
typedef of my type
Definition: entity.hh:249
bool equals(const ALU2dGridEntity< 0, dim, GridImp > &org) const
compare 2 entities, which means compare the item pointers
void removeElement()
set item pointer to NULL
unsigned int subEntities(unsigned int codim) const
Definition: entity.hh:296
ALU2dGridIntersectionIteratorType ibegin() const
Definition: entity.hh:318
Definition: entity.hh:55
Geometry geometry() const
geometry of this entity
GridImp::template Codim< cd >::Geometry Geometry
type of corresponding interface geometry
Definition: entity.hh:91
void removeElement()
set item pointer to NULL
int boundaryId() const
Id of the boundary which is associated with the entity, returns 0 for inner entities,...
void setElement(const ElementType &element, int face=-1, int level=-1) const
set element as normal entity
GridImp::template Codim< cd >::Entity Entity
type of our interface entity
Definition: entity.hh:89
ALU2dGridEntity(const ALU2dGridEntity &org)
Copy Constructor.
GeometryType type() const
return type of geometry
const FactoryType & factory() const
return reference to factory
Definition: entity.hh:155
GridImp::template Codim< cd >::EntitySeed EntitySeed
typedef of my type
Definition: entity.hh:94
GridImp::template Codim< 0 >::EntityPointer EntityPointer
tpye of EntityPointer
Definition: entity.hh:97
EntitySeed seed() const
return seed of entity
Definition: entity.hh:165
ALU2dGridEntity(const FactoryType &factory, int level)
Constructor.
int level() const
level of this element
PartitionType partitionType() const
Definition: entity.hh:134
FieldVector< alu2d_ctype, dim > & positionInOwnersFather() const
my position in local coordinates of the owners father
bool equals(const ALU2dGridEntity< cd, dim, GridImp > &org) const
compare 2 elements
EntityPointer ownersFather() const
int getIndex() const
index is unique within the grid hierachie and per codim
const GridImp & grid() const
return reference to grid
Definition: entity.hh:152
ElementType & getItem() const
return reference to current item
Definition: entity.hh:158
hierarchic index set of ALU2dGrid
Definition: indexsets.hh:42
Hierarchic Iterator of ALU2dGrid.
Definition: iterator.hh:416
[ provides Dune::Grid ]
Definition: grid.hh:212
Default Implementations for EntityImp.
Definition: entity.hh:740
vector space out of a tensor product of fields.
Definition: fvector.hh:94
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:233
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:328
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
@ All_Partition
all entities
Definition: gridenums.hh:139
@ InteriorEntity
all interior entities
Definition: gridenums.hh:29
Dune namespace.
Definition: alignment.hh:10
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)