Dune Core Modules (2.3.1)

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
17namespace 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
110
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
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
279
282
286 template<int cc>
287 int count () const
288 {
289 assert( item_ );
290 return (cc==0) ? 1 : item_->numvertices();
291 }
292
297 int boundaryId () const {
298 // elements are always inside of our Domain
299 return 0;
300 }
301
308 // As ibegin() and iend() are deprecated these methods will deliver a LeafIntersectionIterator
310 DUNE_DEPRECATED_MSG("Use ileafbegin() instead.")
311 {
312 return ileafbegin();
313 }
317 DUNE_DEPRECATED_MSG("Use ileafend() instead.")
318 {
319 return ileafend();
320 }
321
322 ALU2dGridLevelIntersectionIteratorType ilevelbegin () const
323 {
324 return ALU2dGridLevelIntersectionIteratorType( *this, this->level(),false);
325 }
326 ALU2dGridLevelIntersectionIteratorType ilevelend () const
327 {
328 return ALU2dGridLevelIntersectionIteratorType( *this, this->level(),true);
329 }
330 ALU2dGridLeafIntersectionIteratorType ileafbegin () const
331 {
332 return ALU2dGridLeafIntersectionIteratorType( *this, this->level(), false);
333 }
334 ALU2dGridLeafIntersectionIteratorType ileafend () const
335 {
336 return ALU2dGridLeafIntersectionIteratorType( *this, this->level(),true);
337 }
338
340 bool isLeaf () const;
341
344 EntityPointer father () const;
345
347 bool hasFather () const
348 {
349 return (this->level()>0);
350 }
351
357 {
358 return ALU2dGridHierarchicIterator<GridImp> (factory(), *item_ , maxLevel,false);
359 }
360
363 {
364 return ALU2dGridHierarchicIterator<GridImp> (factory(), *item_, maxLevel,true);
365 }
366
369 template <int cc>
370 typename Codim<cc>::EntityPointer entity (int i) const;
371
374 template< int codim >
375 typename Codim< codim >::EntityPointer subEntity ( int i ) const
376 {
377 int j = i;
378 // apply mapping for codim 1
379 // dune to alu
380 if( codim == 1 )
381 {
382 if( item_->numvertices() == 3 )
383 j = 2 - i;
384 else
385 switch (i) { case 0 : j=2;break;
386 case 1 : j=0;break;
387 case 2 : j=3;break;
388 case 3 : j=1;break;}
389 }
390 else if ( codim == 2 )
391 {
392 if( item_->numvertices() == 4 )
393 {
394 switch (i) { case 0 : j=0;break;
395 case 1 : j=1;break;
396 case 2 : j=3;break;
397 case 3 : j=2;break;}
398 }
399 }
400 return entity< codim >( j );
401 }
402
405 {
406#if ALU2DGRID_PARALLEL
407 return grid().rankManager().partitionType( item_->getIndex() );
408#else
409 return InteriorEntity;
410#endif
411 }
412
419 template <int cc>
420 int subBoundaryId ( int i ) const;
421
422
434
436 bool mightVanish () const
437 {
438 return ((item_->is(ALU2DSPACE Refco::crs))==1);
439 }
440
441 bool isNew () const
442 {
443 return ((item_->wasRefined())==1);
444 }
445
446 //***************************************************************
447 // Interface for Adaptation
448 //***************************************************************
449
450 public:
454 bool mark(int refCount) const;
455
457 int getMark() const;
458
462 void setElement(const HElementType &element, int face=-1, int level = -1) const;
463 void setElement(const EntitySeed& seed ) const;
464
465 void setElement(const ALU2dGridEntity & org) const {
466 setElement(*(org.item_));
467 }
468
470 void reset ( int l );
471
474
476 bool equals ( const ALU2dGridEntity<0,dim,GridImp> & org ) const;
477
478 // return reference to HElement (needed by IntersectionIterator)
479 HElementType & getItem() const
480 {
481 assert( item_ );
482 return *item_;
483 }
484
487 {
488 return EntitySeed( getItem() );
489 }
490
492 const GridImp& grid() const { return factory_.grid(); }
493
495 const FactoryType& factory() const { return factory_; }
496
497 // return internal face
498 int getFace() const { return -1; }
499
501 int getIndex () const;
502
503 private:
505 int nChild () const;
506
510 template<int cc> int getSubIndex (int i) const;
511
512 int subIndex (int i, unsigned int codim) const;
513
515 const FactoryType& factory_;
516
518 mutable HElementType *item_;
519
521 mutable GeometryImpl geoObj_;
522
524 mutable bool isLeaf_;
525
526 }; // end of ALU2dGridEntity codim = 0
527
528
529 //**********************************************************************
530 //
531 // --ALU2dGridEntityPointer
532 // --EntityPointer
533 // --EnPointer
534 //**********************************************************************
538 template< int codim, class GridImp >
540 {
541 // type of this class
543
544 static const int dim = GridImp::dimension;
545 static const int dimworld = GridImp::dimensionworld;
546 static const ALU2DSPACE ElementType eltype = GridImp::elementType;
547
548 typedef typename Dune::ALU2dImplTraits< dimworld, eltype >::template Codim<codim>::InterfaceType ElementType;
549
550 public:
551 typedef typename GridImp :: GridObjectFactoryType FactoryType;
552
553 enum { codimension = codim };
554
556 typedef typename GridImp::template Codim<codimension>::Entity Entity;
557
559 typedef typename GridImp::template Codim<codimension>::EntitySeed EntitySeed;
563
565
567 ALU2dGridEntityPointer ( const FactoryType& factory,
568 const ElementType &item,
569 int face = -1,
570 int level = -1
571 );
572
574 ALU2dGridEntityPointer(const FactoryType& factory, const EntitySeed& seed) ;
575
578
580 ALU2dGridEntityPointer(const FactoryType& factory) ;
581
584
587
589 // this may have to be changed!
590 bool equals (const ThisType & i) const;
591
593 Entity & dereference() const ;
594
596 int level () const;
597
600
602 const GridImp& grid() const { return factory_.grid(); }
603
604 protected:
605 EntityImp & entityImp();
606 const EntityImp & entityImp() const;
607
609 void done ();
610
612 void updateEntityPointer( ElementType * item, int face=-1, int level=-1 );
613
615 const FactoryType& factory_;
616
619
622 };
623
624} // end namespace Dune
625
626#include "entity_imp.cc"
627#endif
void updateEntityPointer(ElementType *item, int face=-1, int level=-1)
update underlying item pointer and set entity
Entity & dereference() const
dereferencing
ALU2dGridEntity< codimension, dim, GridImp > EntityImp
tpye of stored entity (implementation)
Definition: entity.hh:561
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:559
GridImp::template Codim< codimension >::Entity Entity
type of stored entity (interface)
Definition: entity.hh:556
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:621
const FactoryType & factory_
reference to entity factory
Definition: entity.hh:615
ThisType & operator=(const ThisType &org)
assigment operator
~ALU2dGridEntityPointer()
Destructor.
bool equals(const ThisType &i) const
equality
ALU2dGridEntityPointer(const FactoryType &factory, const EntitySeed &seed)
Constructor for EntityPointer init of Level- and LeafIterator.
const GridImp & grid() const
return reference top grid
Definition: entity.hh:602
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:618
EntitySeed seed() const
return seed of entity
Definition: entity.hh:486
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:375
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:316
PartitionType partitionType() const
return partition type of this entity ( see grid.hh )
Definition: entity.hh:404
bool mightVanish() const
The former state() method has been replaced by:
Definition: entity.hh:436
bool hasFather() const
returns true if father entity exists
Definition: entity.hh:347
ALU2dGridEntity(const FactoryType &factory, int level)
Constructor creating empty Entity.
const GridImp & grid() const
return reference to grid
Definition: entity.hh:492
ALU2dGridEntity(const ALU2dGridEntity &org)
Constructor creating empty Entity.
Codim< cc >::EntityPointer entity(int i) const
GridImp::template Codim< 0 >::LocalGeometry LocalGeometry
type of corresponding interface local geometry
Definition: entity.hh:246
GeometryType type() const
return type of geometry
ALU2dGridHierarchicIterator< GridImp > hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: entity.hh:362
int boundaryId() const
Id of the boundary which is associated with the entity, returns 0 for inner entities,...
Definition: entity.hh:297
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:356
LeafIntersectionIteratorWrapper< GridImp > ALU2dGridLeafIntersectionIteratorType
tpye of intersection iterator
Definition: entity.hh:252
const FactoryType & factory() const
return reference to factory
Definition: entity.hh:495
bool isLeaf() const
returns true if Entity is leaf (i.e. has no children)
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
ALU2dGridIntersectionIteratorType ibegin() const
Definition: entity.hh:309
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
ElementType & getItem() const
return reference to current item
Definition: entity.hh:158
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.
FieldVector< alu2d_ctype, dim > & positionInOwnersFather() const
my position in local coordinates of the owners father
GeometryType type() const
return type of geometry
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
const GridImp & grid() const
return reference to grid
Definition: entity.hh:152
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
bool equals(const ALU2dGridEntity< cd, dim, GridImp > &org) const
compare 2 elements
const FactoryType & factory() const
return reference to factory
Definition: entity.hh:155
EntityPointer ownersFather() const
int getIndex() const
index is unique within the grid hierachie and per codim
hierarchic index set of ALU2dGrid
Definition: indexsets.hh:42
Hierarchic Iterator of ALU2dGrid.
Definition: iterator.hh:416
[ provides Dune::Grid ]
Definition: grid.hh:213
Default Implementations for EntityImp.
Definition: entity.hh:553
GridImp::ctype ctype DUNE_DEPRECATED_MSG("Use Geometry::ctype instead!")
define type used for coordinates in grid module
Definition: entity.hh:568
vector space out of a tensor product of fields.
Definition: fvector.hh:92
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:239
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:334
Dune namespace.
Definition: alignment.hh:14
@ All_Partition
all entities
Definition: gridenums.hh:135
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:24
@ InteriorEntity
all interior entities
Definition: gridenums.hh:25
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)