- Home
- About DUNE
- Download
- Documentation
- Community
- Development
00001 #ifndef DUNE_ALU2DGRIDENTITY_HH 00002 #define DUNE_ALU2DGRIDENTITY_HH 00003 00004 // System includes 00005 00006 // Dune includes 00007 #include <dune/grid/common/entity.hh> 00008 //#include <dune/grid/common/intersectioniteratorwrapper.hh> 00009 00010 // Local includes 00011 #include <dune/grid/alugrid/2d/intersection.hh> 00012 #include <dune/grid/alugrid/2d/iterator.hh> 00013 00014 namespace Dune { 00015 // Forward declarations 00016 template<int cd, int dim, class GridImp> 00017 class ALU2dGridEntity; 00018 template<int cd, PartitionIteratorType pitype, class GridImp > 00019 class ALU2dGridLevelIterator; 00020 template< int codim, class GridImp > 00021 class ALU2dGridEntityPointer; 00022 template<int mydim, int coorddim, class GridImp> 00023 class ALU2dGridGeometry; 00024 template<class GridImp> 00025 class ALU2dGridHierarchicIterator; 00026 template<class GridImp> 00027 class ALU2dGridLevelIntersectionIterator; 00028 template<class GridImp> 00029 class ALU2dGridLeafIntersectionIterator; 00030 template<class GridImp> 00031 class ALU2dGridIntersectionIterator; 00032 template<int codim, PartitionIteratorType, class GridImp> 00033 class ALU2dGridLeafIterator; 00034 template< int dim, int dimworld, ALU2DSPACE ElementType eltype > 00035 class ALU2dGrid; 00036 00037 //********************************************************************** 00038 // 00039 // --ALU2dGridEntity 00040 // --Entity 00041 // 00042 //********************************************************************** 00049 template<int cd, int dim, class GridImp> 00050 class ALU2dGridEntity : 00051 public EntityDefaultImplementation <cd,dim,GridImp,ALU2dGridEntity> 00052 { 00053 static const int dimworld = GridImp::dimensionworld; 00054 static const ALU2DSPACE ElementType eltype = GridImp::elementType; 00055 00056 friend class ALU2dGrid< dim, dimworld, eltype >; 00057 friend class ALU2dGridIntersectionIterator < GridImp >; 00058 friend class ALU2dGridIntersectionIterator < const GridImp >; 00059 friend class ALU2dGridLevelIntersectionIterator < GridImp >; 00060 friend class ALU2dGridLevelIntersectionIterator < const GridImp >; 00061 friend class ALU2dGridLeafIntersectionIterator < GridImp >; 00062 friend class ALU2dGridLeafIntersectionIterator < const GridImp >; 00063 friend class ALU2dGridHierarchicIterator < const GridImp >; 00064 friend class ALU2dGridHierarchicIterator < GridImp >; 00065 friend class ALU2dGridLevelIterator <0,All_Partition,GridImp>; 00066 friend class ALU2dGridLevelIterator <1,All_Partition,GridImp>; 00067 friend class ALU2dGridLevelIterator <2,All_Partition,GridImp>; 00068 friend class ALU2dGridLeafIterator <0, All_Partition,GridImp>; 00069 friend class ALU2dGridLeafIterator <1, All_Partition,GridImp>; 00070 friend class ALU2dGridLeafIterator <2, All_Partition,GridImp>; 00071 friend class ALU2dGridMakeableEntity<0,dim,GridImp>; 00072 00073 friend class ALU2dGridHierarchicIndexSet<dim,dimworld,eltype>; 00074 00075 typedef typename ALU2dImplTraits< dimworld, eltype >::HElementType HElementType ; 00076 00077 public: 00078 typedef typename GridImp :: GridObjectFactoryType FactoryType; 00079 00080 typedef typename Dune::ALU2dImplTraits< dimworld, eltype >::template Codim<cd>::InterfaceType ElementType; 00081 typedef typename Dune::ALU2dImplTraits< dimworld, eltype >::template Codim<2>::InterfaceType VertexType; 00082 00084 typedef typename GridImp::template Codim<cd>::Entity Entity; 00086 typedef typename GridImp::template Codim<cd>::Geometry Geometry; 00088 typedef MakeableInterfaceObject<Geometry> GeometryObj; 00089 typedef ALU2dGridGeometry<dim-cd,dimworld, const GridImp> GeometryImp; 00090 00092 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer; 00093 00095 int level () const; 00096 00098 ALU2dGridEntity(const FactoryType& factory, int level); 00099 00101 ALU2dGridEntity(const ALU2dGridEntity & org); 00102 00104 const Geometry & geometry () const; 00105 00107 GeometryType type() const ; 00108 00110 void removeElement(); 00111 00115 00116 void setElement(const ElementType &element, int face=-1, int level = -1) const; 00117 void setElement(const HElementType & el, const VertexType & vx); 00118 void setElement(const ALU2dGridEntity & org) const { 00119 setElement(*(org.item_), org.face_); 00120 } 00121 00123 bool equals ( const ALU2dGridEntity<cd,dim,GridImp> & org ) const; 00124 00127 PartitionType partitionType() const{ return InteriorEntity; } 00128 00133 int boundaryId () const; 00134 00139 EntityPointer ownersFather () const; 00140 00142 FieldVector<alu2d_ctype, dim>& positionInOwnersFather () const; 00143 00145 const GridImp& grid() const { return factory_.grid(); } 00146 00148 const FactoryType& factory() const { return factory_; } 00149 00151 ElementType& getItem() const 00152 { 00153 assert( item_ ); 00154 return *item_; 00155 } 00156 00157 // return internal face 00158 int getFace() const { return face_; } 00159 00161 int getIndex () const; 00162 00163 private: 00165 GeometryImp& geoImpl() const { return GridImp :: getRealImplementation(geoObj_); } 00166 00168 const FactoryType& factory_; 00169 00171 mutable ElementType * item_; 00173 00174 mutable GeometryObj geoObj_; 00175 00176 mutable int level_; 00177 mutable int face_; 00178 }; 00179 00193 //*********************** 00194 // 00195 // --ALU2dGridEntity 00196 // --0Entity 00197 // 00198 //*********************** 00199 template<int dim, class GridImp> 00200 class ALU2dGridEntity<0,dim,GridImp> 00201 : public EntityDefaultImplementation<0,dim,GridImp,ALU2dGridEntity> 00202 { 00203 static const int dimworld = GridImp::dimensionworld; 00204 static const ALU2DSPACE ElementType eltype = GridImp::elementType; 00205 00206 friend class ALU2dGrid< dim, dimworld, eltype >; 00207 friend class ALU2dGridIntersectionIterator < GridImp >; 00208 friend class ALU2dGridIntersectionIterator < const GridImp >; 00209 friend class ALU2dGridLevelIntersectionIterator < GridImp >; 00210 friend class ALU2dGridLevelIntersectionIterator < const GridImp >; 00211 friend class ALU2dGridLeafIntersectionIterator < GridImp >; 00212 friend class ALU2dGridLeafIntersectionIterator < const GridImp >; 00213 friend class ALU2dGridHierarchicIterator < const GridImp >; 00214 friend class ALU2dGridHierarchicIterator < GridImp >; 00215 friend class ALU2dGridLevelIterator <0,All_Partition,GridImp>; 00216 friend class ALU2dGridLevelIterator <1,All_Partition,GridImp>; 00217 friend class ALU2dGridLevelIterator <2,All_Partition,GridImp>; 00218 friend class ALU2dGridLeafIterator <0, All_Partition,GridImp>; 00219 friend class ALU2dGridLeafIterator <1, All_Partition,GridImp>; 00220 friend class ALU2dGridLeafIterator <2, All_Partition,GridImp>; 00221 friend class ALU2dGridMakeableEntity<0,dim,GridImp>; 00222 00223 friend class ALU2dGridHierarchicIndexSet<dim,dimworld,eltype>; 00224 00225 typedef typename ALU2dImplTraits< dimworld, eltype >::HElementType HElementType ; 00226 00227 public: 00228 typedef typename GridImp :: GridObjectFactoryType FactoryType; 00229 00231 typedef typename GridImp::template Codim<0>::Geometry Geometry; 00233 typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry; 00235 typedef MakeableInterfaceObject<Geometry> GeometryObj; 00236 typedef ALU2dGridGeometry<dim,dimworld, const GridImp> GeometryImp; 00237 00239 typedef LeafIntersectionIteratorWrapper< GridImp > ALU2dGridLeafIntersectionIteratorType; 00240 typedef LevelIntersectionIteratorWrapper< GridImp > ALU2dGridLevelIntersectionIteratorType; 00241 typedef ALU2dGridLeafIntersectionIteratorType ALU2dGridIntersectionIteratorType; 00242 00244 typedef typename GridImp::template Codim<0>::Entity Entity; 00246 //typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer; 00247 typedef ALU2dGridEntityPointer<0,GridImp> EntityPointer; 00248 00249 template <int cd> 00250 struct Codim 00251 { 00252 typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer; 00253 }; 00254 00256 ALU2dGridEntity(const FactoryType& factory, int level); 00257 00259 ALU2dGridEntity(const ALU2dGridEntity & org); 00260 00262 int level () const ; 00263 00265 const Geometry & geometry () const; 00266 00268 GeometryType type() const ; 00269 00273 template<int cc> 00274 int count () const { 00275 #ifdef ALUGRID_SURFACE_2D 00276 assert( item_ ); 00277 return (cc==0)?1 : item_->numvertices(); 00278 #else 00279 enum {c = (cc==0)?1 : dim+1}; 00280 return c; 00281 #endif 00282 } 00283 00288 int boundaryId () const { 00289 // elements are always inside of our Domain 00290 return 0; 00291 } 00292 00299 // As ibegin() and iend() are deprecated these methods will deliver a LeafIntersectionIterator 00300 ALU2dGridIntersectionIteratorType ibegin () const 00301 { 00302 return ileafbegin(); 00303 } 00305 ALU2dGridIntersectionIteratorType iend () const 00306 { 00307 return ileafend(); 00308 } 00309 00310 ALU2dGridLevelIntersectionIteratorType ilevelbegin () const 00311 { 00312 return ALU2dGridLevelIntersectionIteratorType( *this, this->level(),false); 00313 } 00314 ALU2dGridLevelIntersectionIteratorType ilevelend () const 00315 { 00316 return ALU2dGridLevelIntersectionIteratorType( *this, this->level(),true); 00317 } 00318 ALU2dGridLeafIntersectionIteratorType ileafbegin () const 00319 { 00320 return ALU2dGridLeafIntersectionIteratorType( *this, this->level(), false); 00321 } 00322 ALU2dGridLeafIntersectionIteratorType ileafend () const 00323 { 00324 return ALU2dGridLeafIntersectionIteratorType( *this, this->level(),true); 00325 } 00326 00328 bool isLeaf () const; 00329 00332 EntityPointer father () const; 00333 00335 bool hasFather () const 00336 { 00337 return (this->level()>0); 00338 } 00339 00344 ALU2dGridHierarchicIterator<GridImp> hbegin (int maxLevel) const 00345 { 00346 return ALU2dGridHierarchicIterator<GridImp> (factory(), *item_ , maxLevel,false); 00347 } 00348 00350 ALU2dGridHierarchicIterator<GridImp> hend (int maxLevel) const 00351 { 00352 return ALU2dGridHierarchicIterator<GridImp> (factory(), *item_, maxLevel,true); 00353 } 00354 00357 template <int cc> 00358 typename Codim<cc>::EntityPointer entity (int i) const; 00359 00362 template< int codim > 00363 typename Codim< codim >::EntityPointer subEntity ( int i ) const 00364 { 00365 int j = i; 00366 // apply mapping for codim 1 00367 // dune to alu 00368 switch (codim) 00369 { 00370 case 1: 00371 if( item_->numvertices() == 3 ) 00372 j = 2 - i; 00373 else 00374 switch (i) { case 0: j=2;break; 00375 case 1: j=0;break; 00376 case 2: j=3;break; 00377 case 3: j=1;break; 00378 } 00379 break; 00380 case 2: 00381 if( item_->numvertices() == 4 ) 00382 switch (i) { case 0: j=0;break; 00383 case 1: j=1;break; 00384 case 2: j=3;break; 00385 case 3: j=2;break; 00386 } 00387 break; 00388 } 00389 return entity< codim >( j ); 00390 } 00391 00393 PartitionType partitionType() const 00394 { 00395 #if ALU2DGRID_PARALLEL 00396 return grid().rankManager().partitionType( item_->getIndex() ); 00397 #else 00398 return InteriorEntity; 00399 #endif 00400 } 00401 00408 template <int cc> 00409 int subBoundaryId ( int i ) const; 00410 00411 00422 const LocalGeometry & geometryInFather () const; 00423 00425 bool mightVanish () const 00426 { 00427 return ((item_->is(ALU2DSPACE Refco::crs))==1); 00428 } 00429 00430 bool isNew () const 00431 { 00432 return ((item_->wasRefined())==1); 00433 } 00434 00435 //*************************************************************** 00436 // Interface for Adaptation 00437 //*************************************************************** 00438 00439 public: 00443 bool mark(int refCount) const; 00444 00446 int getMark() const; 00447 00451 void setElement(const HElementType &element, int face=-1, int level = -1) const; 00452 00453 void setElement(const ALU2dGridEntity & org) const { 00454 setElement(*(org.item_)); 00455 } 00456 00458 void reset ( int l ); 00459 00461 void removeElement(); 00462 00464 bool equals ( const ALU2dGridEntity<0,dim,GridImp> & org ) const; 00465 00466 // return reference to HElement (needed by IntersectionIterator) 00467 HElementType & getItem() const 00468 { 00469 assert( item_ ); 00470 return *item_; 00471 } 00472 00474 const GridImp& grid() const { return factory_.grid(); } 00475 00477 const FactoryType& factory() const { return factory_; } 00478 00479 // return internal face 00480 int getFace() const { return -1; } 00481 00483 int getIndex () const; 00484 00485 private: 00487 int nChild () const; 00488 00490 GeometryImp& geoImpl() const { return GridImp :: getRealImplementation(geoObj_); } 00491 00495 template<int cc> int getSubIndex (int i) const; 00496 00497 int subIndex (int i, unsigned int codim) const; 00498 00500 const FactoryType& factory_; 00501 00503 mutable HElementType *item_; 00504 00506 mutable GeometryObj geoObj_; 00507 00509 mutable bool isLeaf_; 00510 00511 }; // end of ALU2dGridEntity codim = 0 00512 00513 00514 //********************************************************************** 00515 // 00516 // --ALU2dGridEntityPointer 00517 // --EntityPointer 00518 // --EnPointer 00519 //********************************************************************** 00523 template< int codim, class GridImp > 00524 class ALU2dGridEntityPointer 00525 { 00526 // type of this class 00527 typedef ALU2dGridEntityPointer< codim, GridImp > ThisType; 00528 00529 static const int dim = GridImp::dimension; 00530 static const int dimworld = GridImp::dimensionworld; 00531 static const ALU2DSPACE ElementType eltype = GridImp::elementType; 00532 00533 typedef typename Dune::ALU2dImplTraits< dimworld, eltype >::template Codim<codim>::InterfaceType ElementType; 00534 00535 public: 00536 typedef typename GridImp :: GridObjectFactoryType FactoryType; 00537 00538 enum { codimension = codim }; 00539 00541 typedef typename GridImp::template Codim<codimension>::Entity Entity; 00543 typedef ALU2dGridEntity<codimension,dim,GridImp> EntityImp; 00544 typedef MakeableInterfaceObject<Entity> EntityObj; 00545 00546 typedef ALU2dGridEntityPointer<codimension,GridImp> EntityPointerImp; 00547 00549 ALU2dGridEntityPointer ( const FactoryType& factory, 00550 const ElementType &item, 00551 int face = -1, 00552 int level = -1 00553 ); 00554 00556 ALU2dGridEntityPointer(const EntityImp& entity) ; 00557 00559 ALU2dGridEntityPointer(const FactoryType& factory) ; 00560 00562 ALU2dGridEntityPointer(const ThisType & org) ; 00563 00565 ~ALU2dGridEntityPointer(); 00566 00568 // this may have to be changed! 00569 bool equals (const ThisType & i) const; 00570 00572 Entity & dereference() const ; 00573 00575 void compactify(); 00576 00578 int level () const; 00579 00581 ThisType & operator = (const ThisType & org); 00582 00584 const GridImp& grid() const { return factory_.grid(); } 00585 00586 protected: 00587 EntityImp & entityImp(); 00588 const EntityImp & entityImp() const; 00589 00591 void done (); 00592 00594 void updateEntityPointer( ElementType * item, int face=-1, int level=-1 ); 00595 00597 const FactoryType& factory_; 00598 00600 mutable ElementType * item_; 00602 mutable EntityObj * entity_; 00603 00604 mutable int level_; 00605 int face_; 00606 }; 00607 00608 } // end namespace Dune 00609 00610 #include "entity_imp.cc" 00611 #endif
Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].