3#ifndef ALU3DGRID_ENTITYKEY_HH
4#define ALU3DGRID_ENTITYKEY_HH
9 template<
int cd,
class Gr
idImp>
10 class ALU3dGridEntitySeed ;
17 template<
int codim,
class Gr
idImp >
18 class ALU3dGridEntitySeedBase
21 typedef ALU3dGridEntitySeedBase< codim, GridImp > ThisType;
22 enum { dim = GridImp::dimension };
23 enum { dimworld = GridImp::dimensionworld };
26 typedef typename GridImp::MPICommunicatorType Comm;
28 friend class ALU3dGridEntity<codim,dim,GridImp>;
29 friend class ALU3dGridEntity< 0,dim,GridImp>;
30 friend class ALU3dGrid < GridImp::elementType, Comm >;
32 typedef ALU3dImplTraits<GridImp::elementType, Comm > ImplTraits;
33 typedef typename ImplTraits::template Codim<codim>::ImplementationType ImplementationType;
34 typedef typename ImplTraits::template Codim<codim>
::InterfaceType HElementType;
35 typedef typename ImplTraits::template Codim<codim>::EntitySeedType KeyType ;
37 typedef typename ImplTraits::BNDFaceType BNDFaceType;
38 typedef typename ImplTraits::HBndSegType HBndSegType;
40 template <int cd, class Key>
43 static Key* toKey(
const HBndSegType*)
47 static HElementType* getItem(KeyType* key)
49 return static_cast< HElementType*
> ( key );
51 static bool isGhost(KeyType*) {
return false; }
52 static BNDFaceType*
ghost( KeyType* ) {
return ( BNDFaceType* ) 0; }
57 static Key* toKey(
const HBndSegType* ghostFace)
59 return static_cast< KeyType*
> (
const_cast< BNDFaceType*
>(
static_cast<const BNDFaceType*
> (ghostFace)));
61 static HElementType* getItem(KeyType* key)
65 if( key->isboundary() )
67 return ((
static_cast< BNDFaceType*
> ( key ))->getGhost().first);
73 return static_cast< HElementType *
> (
static_cast< ImplementationType*
> (key));
77 return static_cast< HElementType *
> (0) ;
79 static bool isGhost(KeyType* key) { assert( key );
return key->isboundary(); }
80 static BNDFaceType*
ghost( KeyType* key ) { assert( key );
return (
static_cast< BNDFaceType*
> ( key )); }
83 static const int defaultValue = -1 ;
84 static const int defaultTwist = 0 ;
86 enum { codimension = codim };
89 typedef typename GridImp::template Codim<codimension>::Entity Entity;
91 typedef MakeableInterfaceObject<Entity> EntityObject;
92 typedef typename EntityObject :: ImplementationType EntityImp;
95 typedef ThisType ALU3dGridEntitySeedType;
98 typedef ALU3dGridEntitySeed<codimension,GridImp> EntitySeedImp;
101 ~ALU3dGridEntitySeedBase()
110 ALU3dGridEntitySeedBase();
113 ALU3dGridEntitySeedBase(
const HElementType& item);
116 ALU3dGridEntitySeedBase(
const HElementType* item,
const HBndSegType* ghostFace );
119 ALU3dGridEntitySeedBase(
const HBndSegType& ghostFace );
127 ALU3dGridEntitySeedBase(
const ALU3dGridEntitySeedType & org);
130 bool operator == (
const ALU3dGridEntitySeedType& i)
const
136 bool operator != (
const ALU3dGridEntitySeedType& i)
const
138 return ! equals( i );
142 ThisType & operator = (
const ThisType & org);
145 bool isValid ()
const
156 bool equals (
const ALU3dGridEntitySeedType& i)
const;
165 HElementType* item()
const {
return Bnd<codim,KeyType>::getItem( item_ ); }
170 assert( ! isGhost() );
171 return static_cast< HElementType *
> (
static_cast< ImplementationType*
> (item_));
175 bool isGhost()
const {
return Bnd<codim,KeyType>::isGhost( item_ ); }
176 BNDFaceType*
ghost()
const
179 return Bnd<codim,KeyType>::ghost( item_ );
182 KeyType* toKey(
const HElementType* item)
184 return static_cast< KeyType*
> (
const_cast< ImplementationType*
> (
static_cast<const ImplementationType*
> (item)));
187 void set(
const HElementType& item)
189 item_ = toKey( &item );
192 KeyType* toKey(
const HBndSegType* ghostFace )
194 return Bnd<codim,KeyType>::toKey( ghostFace );
197 void set(
const HBndSegType& ghostFace)
199 item_ = toKey( &ghostFace );
202 int level ()
const {
return defaultValue; }
203 int twist ()
const {
return defaultTwist; }
204 int face ()
const {
return defaultValue; }
208 mutable KeyType* item_;
211 template<
int cd,
class Gr
idImp>
212 class ALU3dGridEntitySeed :
213 public ALU3dGridEntitySeedBase<cd,GridImp>
215 typedef ALU3dGridEntitySeedBase<cd,GridImp> BaseType;
217 typedef ALU3dGridEntitySeed <cd,GridImp> ThisType;
218 enum { dim = GridImp::dimension };
219 enum { dimworld = GridImp::dimensionworld };
221 typedef typename GridImp::MPICommunicatorType Comm;
223 friend class ALU3dGridEntity<cd,dim,GridImp>;
224 friend class ALU3dGridEntity< 0,dim,GridImp>;
225 friend class ALU3dGrid < GridImp::elementType, Comm >;
227 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
228 typedef typename ImplTraits::template Codim<cd>::ImplementationType ImplementationType;
229 typedef typename ImplTraits::template Codim<cd>
::InterfaceType HElementType;
231 typedef typename ImplTraits::BNDFaceType BNDFaceType;
232 typedef ALU3dGridEntity<cd,dim,GridImp> ALU3dGridEntityType;
235 using BaseType :: defaultValue ;
236 using BaseType :: defaultTwist ;
239 typedef typename GridImp::template Codim<cd>::Entity Entity;
242 typedef ALU3dGridEntitySeed<cd,GridImp> ALU3dGridEntitySeedType;
245 ALU3dGridEntitySeed(const ImplementationType & item)
253 ALU3dGridEntitySeed(
const HElementType & item,
255 const int twist = defaultTwist,
256 const int duneFace = defaultValue
260 ALU3dGridEntitySeed()
261 : BaseType(), level_(defaultValue), twist_(defaultTwist), face_(defaultValue) {}
264 ALU3dGridEntitySeed(
const ALU3dGridEntityType& entity)
265 : ALU3dGridEntitySeedBase<cd,GridImp> (entity.getItem()),
266 level_(entity.level()), twist_(defaultTwist), face_(defaultValue)
270 ALU3dGridEntitySeed(
const ALU3dGridEntitySeedType & org);
273 ThisType & operator = (
const ThisType & org);
279 void set(
const HElementType & item,
const int level )
281 BaseType :: set( item );
286 int level ()
const {
return level_ ; }
288 int twist ()
const {
return twist_ ; }
290 int face ()
const {
return face_ ; }
292 using BaseType :: set ;
294 bool operator == (
const ALU3dGridEntitySeedType& i)
const
299 bool operator != (
const ALU3dGridEntitySeedType& i)
const
301 return ! equals( i );
305 bool equals (
const ALU3dGridEntitySeedType& key)
const
308 return BaseType :: equals( key ) && (level() == key.level());
323 template<
class Gr
idImp>
324 class ALU3dGridEntitySeed<0,GridImp> :
325 public ALU3dGridEntitySeedBase<0,GridImp>
328 typedef ALU3dGridEntitySeedBase<0,GridImp> BaseType;
331 typedef ALU3dGridEntitySeed <cd,GridImp> ThisType;
332 enum { dim = GridImp::dimension };
333 enum { dimworld = GridImp::dimensionworld };
335 typedef typename GridImp::MPICommunicatorType Comm;
339 friend class ALU3dGrid < GridImp::elementType, Comm >;
341 typedef ALU3dImplTraits<GridImp::elementType, Comm > ImplTraits;
342 typedef typename ImplTraits::template
Codim<cd>::ImplementationType ImplementationType;
345 typedef typename ImplTraits::BNDFaceType BNDFaceType;
346 typedef typename ImplTraits::HBndSegType HBndSegType;
351 using BaseType :: defaultValue ;
352 using BaseType :: defaultTwist ;
355 typedef typename GridImp::template
Codim<cd>::Entity Entity;
358 typedef ThisType ALU3dGridEntitySeedType;
361 ALU3dGridEntitySeed() : BaseType() {}
365 : ALU3dGridEntitySeedBase<cd,GridImp> (item) {}
369 : ALU3dGridEntitySeedBase<cd,GridImp> (item) {}
373 : ALU3dGridEntitySeedBase<cd,GridImp> ( ghostFace ) {}
377 : ALU3dGridEntitySeedBase<cd,GridImp> (org)
383 template <
int cd,
class Gr
idImp>
385 const ALU3dGridEntitySeed<cd,GridImp>& key)
387 out << key.item() <<
" " << key.level() <<
" " << key.twist() <<
" " << key.face();
397 template<
int codim,
class Gr
idImp >
398 inline ALU3dGridEntitySeedBase<codim,GridImp> ::
399 ALU3dGridEntitySeedBase()
403 template<
int codim,
class Gr
idImp >
404 inline ALU3dGridEntitySeedBase<codim,GridImp> ::
405 ALU3dGridEntitySeedBase(
const HElementType &item)
406 : item_( toKey(&item) )
409 template<
int codim,
class Gr
idImp >
410 inline ALU3dGridEntitySeedBase<codim,GridImp> ::
411 ALU3dGridEntitySeedBase(
const HBndSegType& ghostFace )
412 : item_( toKey(&ghostFace) )
415 template<
int codim,
class Gr
idImp >
416 inline ALU3dGridEntitySeedBase<codim,GridImp> ::
417 ALU3dGridEntitySeedBase(
const ALU3dGridEntitySeedType & org)
421 template<
int codim,
class Gr
idImp >
422 inline ALU3dGridEntitySeedBase<codim,GridImp> &
423 ALU3dGridEntitySeedBase<codim,GridImp> ::
424 operator = (
const ALU3dGridEntitySeedType & org)
430 template<
int codim,
class Gr
idImp >
431 inline bool ALU3dGridEntitySeedBase<codim,GridImp>::
432 equals (
const ALU3dGridEntitySeedBase<codim,GridImp>& i)
const
435 return (item_ == i.item_);
444 template<
int codim,
class Gr
idImp >
445 inline ALU3dGridEntitySeed<codim,GridImp> ::
446 ALU3dGridEntitySeed(
const HElementType &item,
450 : ALU3dGridEntitySeedBase<codim,GridImp> (item)
456 template<
int codim,
class Gr
idImp >
457 inline ALU3dGridEntitySeed<codim,GridImp> ::
458 ALU3dGridEntitySeed(
const ALU3dGridEntitySeedType & org)
459 : ALU3dGridEntitySeedBase<codim,GridImp>(org)
465 template<
int codim,
class Gr
idImp >
466 inline ALU3dGridEntitySeed<codim,GridImp> &
467 ALU3dGridEntitySeed<codim,GridImp>::
468 operator = (
const ALU3dGridEntitySeedType & org)
471 BaseType :: operator = ( org );
480 template<
int codim,
class Gr
idImp >
482 ALU3dGridEntitySeed<codim,GridImp>::clear ()
485 level_ = defaultValue ;
486 twist_ = defaultTwist ;
487 face_ = defaultValue ;
ALU3dGridEntitySeed(const HElementType &item, int, int, int)
Constructor for EntitySeed that points to an interior element.
Definition: entityseed.hh:368
ALU3dGridEntitySeed(const HElementType &item)
Constructor for EntitySeed that points to an interior element.
Definition: entityseed.hh:364
ALU3dGridEntitySeed(const HBndSegType &ghostFace)
Constructor for EntitySeed that points to an ghost.
Definition: entityseed.hh:372
ALU3dGridEntitySeed(const ALU3dGridEntitySeedType &org)
copy constructor
Definition: entityseed.hh:376
Definition: entity.hh:204
[ provides Dune::Grid ]
Definition: grid.hh:406
std::ostream & operator<<(std::ostream &s, const array< T, N > &e)
Output operator for array.
Definition: array.hh:26
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:230
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:252
Interior interior
PartitionSet for the interior partition.
Definition: partitionset.hh:226
Ghost ghost
PartitionSet for the ghost partition.
Definition: partitionset.hh:238
Dune namespace.
Definition: alignment.hh:10
Static tag representing a codimension.
Definition: dimension.hh:22