1#ifndef ALU3DGRID_ENTITYKEY_HH
2#define ALU3DGRID_ENTITYKEY_HH
4#include "alu3dinclude.hh"
10template<
int cd,
class Gr
idImp>
11class ALU3dGridEntitySeed ;
13template<
int cd,
int dim,
class Gr
idImp>
21template<
int codim,
class Gr
idImp >
22class ALU3dGridEntitySeedBase
25 typedef ALU3dGridEntitySeedBase< codim, GridImp > ThisType;
26 enum { dim = GridImp::dimension };
27 enum { dimworld = GridImp::dimensionworld };
29 typedef typename GridImp::MPICommunicatorType Comm;
31 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
32 typedef typename ImplTraits::template Codim<dim, codim>::ImplementationType ImplementationType;
34 typedef typename ImplTraits::template Codim<dim, codim>::EntitySeedType KeyType ;
36 typedef typename ImplTraits::BNDFaceType BNDFaceType;
37 typedef typename ImplTraits::HBndSegType HBndSegType;
39 template <
int cd,
class Key>
42 static Key* toKey(
const HBndSegType*)
46 static HElementType* getItem(KeyType* key)
48 return static_cast< HElementType*
> ( key );
50 static bool isGhost(KeyType*) {
return false; }
51 static BNDFaceType*
ghost( KeyType* ) {
return nullptr; }
56 static Key* toKey(
const HBndSegType* ghostFace)
58 return static_cast< KeyType*
> (
const_cast< BNDFaceType*
>(
static_cast<const BNDFaceType*
> (ghostFace)));
60 static HElementType* getItem(KeyType* key)
64 if( key->isboundary() )
66 return ((
static_cast< BNDFaceType*
> ( key ))->getGhost().first);
72 return static_cast< HElementType *
> (
static_cast< ImplementationType*
> (key));
78 static bool isGhost(KeyType* key) { alugrid_assert ( key );
return key->isboundary(); }
79 static BNDFaceType*
ghost( KeyType* key ) { alugrid_assert ( key );
return (
static_cast< BNDFaceType*
> ( key )); }
82 static const int defaultValue = -1 ;
83 static const int defaultTwist = 0 ;
85 enum { codimension = codim };
88 typedef typename GridImp::template Codim<codimension>::Entity Entity;
90 typedef typename GridImp::template Codim<codimension>::EntityImp EntityImp;
93 typedef ThisType ALU3dGridEntitySeedType;
96 typedef ALU3dGridEntitySeed<codimension,GridImp> EntitySeedImp;
99 ~ALU3dGridEntitySeedBase()
108 ALU3dGridEntitySeedBase();
111 ALU3dGridEntitySeedBase(
const HElementType& item);
114 ALU3dGridEntitySeedBase(
const HElementType* item,
const HBndSegType* ghostFace );
117 ALU3dGridEntitySeedBase(
const HBndSegType& ghostFace );
125 ALU3dGridEntitySeedBase(
const ALU3dGridEntitySeedType & org);
127 bool isValid ()
const {
return bool( item_ ); }
130 bool operator == (
const ALU3dGridEntitySeedType& i)
const
136 bool operator != (
const ALU3dGridEntitySeedType& i)
const
142 ThisType & operator = (
const ThisType & org);
150 bool equals (
const ALU3dGridEntitySeedType& i)
const;
159 HElementType* item()
const {
return Bnd<codim,KeyType>::getItem( item_ ); }
164 alugrid_assert ( ! isGhost() );
165 return static_cast< HElementType *
> (
static_cast< ImplementationType*
> (item_));
169 bool isGhost()
const {
return Bnd<codim,KeyType>::isGhost( item_ ); }
170 BNDFaceType*
ghost()
const
172 alugrid_assert ( isGhost() );
173 return Bnd<codim,KeyType>::ghost( item_ );
176 KeyType* toKey(
const HElementType* item)
178 return static_cast< KeyType*
> (
const_cast< ImplementationType*
> (
static_cast<const ImplementationType*
> (item)));
181 void set(
const HElementType& item)
183 item_ = toKey( &item );
186 KeyType* toKey(
const HBndSegType* ghostFace )
188 return Bnd<codim,KeyType>::toKey( ghostFace );
191 void set(
const HBndSegType& ghostFace)
193 item_ = toKey( &ghostFace );
198 alugrid_assert( isValid() );
199 return item()->level();
202 int twist ()
const {
return defaultTwist; }
206 mutable KeyType* item_;
209template<
int cd,
class Gr
idImp>
210class ALU3dGridEntitySeed :
211public ALU3dGridEntitySeedBase<cd,GridImp>
213 typedef ALU3dGridEntitySeedBase<cd,GridImp> BaseType;
215 typedef ALU3dGridEntitySeed <cd,GridImp> ThisType;
216 enum { dim = GridImp::dimension };
217 enum { dimworld = GridImp::dimensionworld };
219 typedef typename GridImp::MPICommunicatorType Comm;
221 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
222 typedef typename ImplTraits::template Codim<dim, cd>::ImplementationType ImplementationType;
225 typedef typename ImplTraits::BNDFaceType BNDFaceType;
226 typedef ALU3dGridEntity<cd,dim,GridImp> ALU3dGridEntityType;
229 using BaseType :: defaultValue ;
230 using BaseType :: defaultTwist ;
233 typedef typename GridImp::template Codim<cd>::Entity Entity;
236 typedef ALU3dGridEntitySeed<cd,GridImp> ALU3dGridEntitySeedType;
240 ALU3dGridEntitySeed(
const ImplementationType & item) =
delete;
243 ALU3dGridEntitySeed(
const HElementType & item,
245 const int twist = defaultTwist
249 ALU3dGridEntitySeed()
250 : BaseType(), level_(defaultValue), twist_(defaultTwist)
254 ALU3dGridEntitySeed(
const ALU3dGridEntityType& entity)
255 : ALU3dGridEntitySeedBase<cd,GridImp> (entity.getItem()),
256 level_(entity.level()),
261 ALU3dGridEntitySeed(
const ALU3dGridEntitySeedType & org);
264 ThisType & operator = (
const ThisType & org);
270 void set(
const HElementType & item,
const int level )
272 BaseType :: set( item );
277 int level ()
const {
return level_ ; }
279 int twist ()
const {
return twist_ ; }
281 using BaseType :: set ;
283 bool operator == (
const ALU3dGridEntitySeedType& i)
const
288 bool operator != (
const ALU3dGridEntitySeedType& i)
const
294 bool equals (
const ALU3dGridEntitySeedType& key)
const
310template<
class Gr
idImp>
311class ALU3dGridEntitySeed<0,GridImp> :
312public ALU3dGridEntitySeedBase<0,GridImp>
315 typedef ALU3dGridEntitySeedBase<0,GridImp> BaseType;
318 typedef ALU3dGridEntitySeed <cd,GridImp> ThisType;
319 enum { dim = GridImp::dimension };
320 enum { dimworld = GridImp::dimensionworld };
322 typedef typename GridImp::MPICommunicatorType Comm;
324 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
328 typedef typename ImplTraits::BNDFaceType BNDFaceType;
329 typedef typename ImplTraits::HBndSegType HBndSegType;
334 using BaseType :: defaultValue ;
335 using BaseType :: defaultTwist ;
348 : ALU3dGridEntitySeedBase<cd,GridImp> (item) {}
352 : ALU3dGridEntitySeedBase<cd,GridImp> (item) {}
356 : ALU3dGridEntitySeedBase<cd,GridImp> ( ghostFace ) {}
360 : ALU3dGridEntitySeedBase<cd,GridImp> (org)
365 ThisType & operator = (
const ThisType & org)
367 BaseType :: operator = (org);
374template <
int cd,
class Gr
idImp>
375inline std :: ostream &operator<< ( std :: ostream &out,
376 const ALU3dGridEntitySeed<cd,GridImp>& key)
378 out << key.item() <<
" " << key.level() <<
" " << key.twist() <<
" " << key.face();
388template<
int codim,
class Gr
idImp >
389inline ALU3dGridEntitySeedBase<codim,GridImp> ::
390ALU3dGridEntitySeedBase()
395template<
int codim,
class Gr
idImp >
396inline ALU3dGridEntitySeedBase<codim,GridImp> ::
397ALU3dGridEntitySeedBase(
const HElementType &item)
398 : item_( toKey(&item) )
402template<
int codim,
class Gr
idImp >
403inline ALU3dGridEntitySeedBase<codim,GridImp> ::
404ALU3dGridEntitySeedBase(
const HBndSegType& ghostFace )
405 : item_( toKey(&ghostFace) )
409template<
int codim,
class Gr
idImp >
410inline ALU3dGridEntitySeedBase<codim,GridImp> ::
411ALU3dGridEntitySeedBase(
const ALU3dGridEntitySeedType & org)
416template<
int codim,
class Gr
idImp >
417inline ALU3dGridEntitySeedBase<codim,GridImp> &
418ALU3dGridEntitySeedBase<codim,GridImp> ::
419operator = (
const ALU3dGridEntitySeedType & org)
425template<
int codim,
class Gr
idImp >
427equals (
const ALU3dGridEntitySeedBase<codim,GridImp>& i)
const
430 return (item_ == i.item_);
439template<
int codim,
class Gr
idImp >
440inline ALU3dGridEntitySeed<codim,GridImp> ::
441ALU3dGridEntitySeed(
const HElementType &item,
444 : ALU3dGridEntitySeedBase<codim,GridImp> (item)
450template<
int codim,
class Gr
idImp >
451inline ALU3dGridEntitySeed<codim,GridImp> ::
452ALU3dGridEntitySeed(
const ALU3dGridEntitySeedType & org)
453 : ALU3dGridEntitySeedBase<codim,GridImp>(org)
459template<
int codim,
class Gr
idImp >
460inline ALU3dGridEntitySeed<codim,GridImp> &
461ALU3dGridEntitySeed<codim,GridImp>::
462operator = (
const ALU3dGridEntitySeedType & org)
465 BaseType :: operator = ( org );
473template<
int codim,
class Gr
idImp >
475ALU3dGridEntitySeed<codim,GridImp>::clear ()
478 level_ = defaultValue ;
479 twist_ = defaultTwist ;
ALU3dGridEntitySeed(const HElementType &item, int, int)
Constructor for EntitySeed that points to an interior element.
Definition: entityseed.hh:351
ALU3dGridEntitySeed(const HElementType &item)
Constructor for EntitySeed that points to an interior element.
Definition: entityseed.hh:347
ALU3dGridEntitySeed(const HBndSegType &ghostFace)
Constructor for EntitySeed that points to an ghost.
Definition: entityseed.hh:355
ALU3dGridEntitySeed(const ALU3dGridEntitySeedType &org)
copy constructor
Definition: entityseed.hh:359
ALU3dGridEntitySeed()
Constructor for EntitySeed that points to an element.
Definition: entityseed.hh:344
GridImp::template Codim< cd >::Entity Entity
type of Entity
Definition: entityseed.hh:338
ThisType ALU3dGridEntitySeedType
typedef of my type
Definition: entityseed.hh:341
Definition: entity.hh:192
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition: hybridutilities.hh:402
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:237
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:259
constexpr Ghost ghost
PartitionSet for the ghost partition.
Definition: partitionset.hh:284
constexpr Interior interior
PartitionSet for the interior partition.
Definition: partitionset.hh:272
Dune namespace.
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24