3 #ifndef DUNE_ALBERTAGRIDINDEXSETS_HH 4 #define DUNE_ALBERTAGRIDINDEXSETS_HH 8 #include <dune/common/hybridutilities.hh> 9 #include <dune/common/stdstreams.hh> 10 #include <dune/common/std/utility.hh> 39 template<
int dim,
int dimworld >
41 :
public IndexSet< AlbertaGridFamily< dim, dimworld >, AlbertaGridHierarchicIndexSet< dim,dimworld >, int, std::array< GeometryType, 1 > >
56 static const int dimension = GridFamily::dimension;
69 struct CreateEntityNumbers;
72 struct RefineNumbering;
75 struct CoarsenNumbering;
83 template<
class Entity >
94 IndexType
index (
const typename Traits::template Codim< cc >::Entity &entity )
const 97 const EntityImp &entityImp = Grid::getRealImplementation( entity );
98 return subIndex( entityImp.elementInfo(), entityImp.subEntity(), cc );
103 IndexType
subIndex (
const typename Traits::template Codim< cc >::Entity &entity,
int i,
unsigned int codim )
const 106 const EntityImp &entityImp = Grid::getRealImplementation( entity );
111 auto refElement = ReferenceElements< Alberta::Real, dimension >::simplex();
112 k = refElement.subEntity( entityImp.subEntity(), cc, i, codim );
115 const int j = entityImp.grid().generic2alberta( codim, k );
116 return subIndex( entityImp.elementInfo(), j, codim );
122 return (type.isSimplex() ? size( dimension - type.dim() ) : 0);
126 IndexType
size (
int codim )
const 128 assert( (codim >= 0) && (codim <= dimension) );
129 return indexStack_[ codim ].size();
134 assert( (codim >= 0) && (codim <= dimension) );
135 return {{ GeometryTypes::simplex( dimension - codim ) }};
139 const std::vector< GeometryType > &
geomTypes(
int codim )
const 141 assert( (codim >= 0) && (codim <= dimension) );
142 return geomTypes_[ codim ];
145 IndexType
subIndex (
const ElementInfo &elementInfo,
int i,
unsigned int codim )
const 147 assert( !elementInfo ==
false );
148 return subIndex( elementInfo.
element(), i, codim );
159 IndexType *array = (IndexType *)entityNumbers_[ codim ];
160 const IndexType subIndex = array[ dofNumbering_( element, codim, i ) ];
161 assert( (subIndex >= 0) && (subIndex < size( codim )) );
168 if( !IndexVectorPointer::supportsAdaptationData )
178 if( !IndexVectorPointer::supportsAdaptationData )
183 void read (
const std::string &filename );
184 bool write (
const std::string &filename )
const;
188 for(
int i = 0; i <= dimension; ++i )
189 entityNumbers_[ i ].release();
193 template<
int codim >
194 static IndexStack &getIndexStack (
const IndexVectorPointer &dofVector )
196 IndexStack *indexStack;
197 if( IndexVectorPointer::supportsAdaptationData )
198 indexStack = dofVector.template getAdaptationData< IndexStack >();
201 assert( indexStack != 0 );
206 const DofNumbering &dofNumbering_;
209 IndexStack indexStack_[ dimension+1 ];
212 IndexVectorPointer entityNumbers_[ dimension+1 ];
215 std::vector< GeometryType > geomTypes_[ dimension+1 ];
223 template<
int dim,
int dimworld >
230 : indexStack_( indexStack )
233 void operator() (
int &dof )
235 dof = indexStack_.getIndex();
244 template<
int dim,
int dimworld >
245 template<
int codim >
253 static void apply (
const std::string &filename,
263 template<
int dim,
int dimworld >
264 template<
int codim >
267 static const int dimension = dim;
268 static const int codimension = codim;
274 : indexStack_( getIndexStack< codimension >( dofVector ) ),
275 dofVector_( dofVector ),
284 const Patch &patch );
289 DofAccess dofAccess_;
297 template<
int dim,
int dimworld >
298 template<
int codim >
301 static const int dimension = dim;
302 static const int codimension = codim;
308 : indexStack_( getIndexStack< codimension >( dofVector ) ),
309 dofVector_( dofVector ),
318 const Patch &patch );
322 DofAccess dofAccess_;
330 template<
int dim,
int dimworld >
332 :
public IndexSet< AlbertaGrid< dim, dimworld >, AlbertaGridIndexSet< dim, dimworld >, int, std::array< GeometryType, 1 > >
352 template<
int codim >
357 : dofNumbering_( dofNumbering )
359 for(
int codim = 0; codim <= dimension; ++codim )
361 indices_[ codim ] = 0;
362 geomTypes_[ codim ].push_back( GeometryTypes::simplex( dimension - codim ) );
368 for(
int codim = 0; codim <= dimension; ++codim )
369 delete[] indices_[ codim ];
372 template<
class Entity >
378 = Grid::getRealImplementation( entity );
381 const IndexType *
const array = indices_[ codim ];
382 const IndexType subIndex = array[ dofNumbering_( element, codim, entityImp.
subEntity() ) ];
384 return (subIndex >= 0);
388 using Base::subIndex;
392 IndexType
index (
const typename Traits::template Codim< cc >::Entity &entity )
const 395 const EntityImp &entityImp = Grid::getRealImplementation( entity );
396 return subIndex( entityImp.elementInfo(), entityImp.subEntity(), cc );
401 IndexType
subIndex (
const typename Traits::template Codim< cc >::Entity &entity,
int i,
unsigned int codim )
const 404 const EntityImp &entityImp = Grid::getRealImplementation( entity );
409 auto refElement = ReferenceElements< Alberta::Real, dimension >::simplex();
410 k = refElement.subEntity( entityImp.subEntity(), cc, i, codim );
413 const int j = entityImp.grid().generic2alberta( codim, k );
414 return subIndex( entityImp.elementInfo(), j, codim );
419 return (type.isSimplex() ? size( dimension - type.dim() ) : 0);
422 IndexType
size (
int codim )
const 424 assert( (codim >= 0) && (codim <= dimension) );
425 return size_[ codim ];
430 assert( (codim >= 0) && (codim <= dimension) );
431 return {{ GeometryTypes::simplex( dimension - codim ) }};
434 const std::vector< GeometryType > &
geomTypes(
int codim )
const 436 assert( (codim >= 0) && (codim <= dimension) );
437 return geomTypes_[ codim ];
440 template<
class Iterator >
441 void update (
const Iterator &begin,
const Iterator &end )
443 for(
int codim = 0; codim <= dimension; ++codim )
445 delete[] indices_[ codim ];
447 const unsigned int dofSize = dofNumbering_.size( codim );
448 indices_[ codim ] =
new IndexType[ dofSize ];
449 for(
unsigned int i = 0; i < dofSize; ++i )
450 indices_[ codim ][ i ] = -1;
455 for( Iterator it = begin; it != end; ++it )
458 = Grid::getRealImplementation( *it );
460 Hybrid::forEach( Std::make_index_sequence< dimension+1 >{},
461 [ & ](
auto i ){ Insert< i >::apply( element, *
this ); } );
466 IndexType subIndex (
const ElementInfo &elementInfo,
int i,
unsigned int codim )
const 468 assert( !elementInfo ==
false );
469 return subIndex( elementInfo.
element(), i, codim );
478 IndexType subIndex (
const Alberta::Element *element,
int i,
unsigned int codim )
const 480 const IndexType *
const array = indices_[ codim ];
481 const IndexType subIndex = array[ dofNumbering_( element, codim, i ) ];
482 assert( (subIndex >= 0) && (subIndex < size( codim )) );
487 const DofNumbering &dofNumbering_;
490 IndexType *indices_[ dimension+1 ];
493 IndexType size_[ dimension+1 ];
496 std::vector< GeometryType > geomTypes_[ dimension+1 ];
504 template<
int dim,
int dimworld >
505 template<
int codim >
511 int *
const array = indexSet.indices_[ codim ];
512 IndexType &size = indexSet.size_[ codim ];
514 for(
int i = 0; i < Alberta::NumSubEntities< dim, codim >::value; ++i )
516 int &index = array[ indexSet.dofNumbering_( element, codim, i ) ];
529 template<
int dim,
int dimworld >
531 :
public IdSet< AlbertaGrid< dim, dimworld >, AlbertaGridIdSet< dim, dimworld >, unsigned int >
551 : hIndexSet_( hIndexSet )
556 template<
class Entity >
560 return id< codim >( e );
564 template<
int codim >
565 IdType
id (
const typename Grid::template Codim< codim >::Entity &e )
const 567 assert( (codim >= 0) && (codim <= dimension) );
568 const IdType index = hIndexSet_.index( e );
569 return (index << 2) | IdType( codim );
573 IdType
subId (
const typename Grid::template Codim< 0 >::Entity &e,
int i,
unsigned int subcodim )
const 575 assert(
int( subcodim ) <= dimension );
576 const IdType index = hIndexSet_.subIndex( e, i, subcodim );
577 return (index << 2) | IdType( subcodim );
580 template<
int codim >
581 IdType
subId (
const typename Grid::template Codim< codim >::Entity &e,
int i,
unsigned int subcodim )
const 583 assert( (codim >= 0) && (codim <= dimension) && (
int( codim + subcodim ) <= dimension) );
584 const IdType index = hIndexSet_.subIndex( e, i, subcodim );
585 return (index << 2) | IdType( codim + subcodim );
588 template<
class Entity >
589 IdType
subId (
const Entity &e,
int i,
unsigned int subcodim )
const 591 return subId< Entity::codimension >( e, i, subcodim );
598 const HierarchicIndexSet &hIndexSet_;
603 #endif // #if HAVE_ALBERTA 605 #endif // #ifndef DUNE_ALBERTAGRIDINDEXSETS_HH Alberta::HierarchyDofNumbering< dimension > DofNumbering
Definition: albertagrid/indexsets.hh:59
Include standard header files.
Definition: agrid.hh:58
void postAdapt()
Definition: albertagrid/indexsets.hh:175
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
return hierarchic index of given entity
Definition: albertagrid/indexsets.hh:94
Provides an index stack that supplies indices for element numbering for a grid (i.e. AlbertaGrid and ALUGrid)
void preAdapt()
Definition: albertagrid/indexsets.hh:165
Index Set Interface base class.
Definition: common/grid.hh:346
AlbertaGridIndexSet(const DofNumbering &dofNumbering)
Definition: albertagrid/indexsets.hh:356
AlbertaGrid< dim, dimworld > Grid
Definition: albertagrid/indexsets.hh:49
IndexType size(const GeometryType &type) const
return size of set for given GeometryType
Definition: albertagrid/indexsets.hh:120
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &entity, int i, unsigned int codim) const
return subIndex of given enitiy's sub entity
Definition: albertagrid/indexsets.hh:103
IdType id(const Entity &e) const
Definition: albertagrid/indexsets.hh:557
Types types(int codim) const
Definition: albertagrid/indexsets.hh:132
Base::IndexType IndexType
Definition: albertagrid/indexsets.hh:340
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &entity, int i, unsigned int codim) const
return subIndex of given enitiy's sub entity
Definition: albertagrid/indexsets.hh:401
Base::IdType IdType
export type of id
Definition: albertagrid/indexsets.hh:540
Definition: refinement.hh:37
[ provides Dune::Grid ]
Definition: agrid.hh:136
Base::Types Types
Definition: albertagrid/indexsets.hh:342
IndexType subIndex(const Alberta::Element *element, int i, unsigned int codim) const
obtain hierarchic subindex
Definition: albertagrid/indexsets.hh:157
Definition: albertagrid/gridfamily.hh:50
Definition: albertagrid/indexsets.hh:224
AlbertaGrid< dim, dimworld > Grid
Definition: albertagrid/indexsets.hh:338
Wrapper class for entities.
Definition: common/entity.hh:63
provides a wrapper for ALBERTA's el_info structure
const Element * element() const
Definition: elementinfo.hh:719
void release()
Definition: albertagrid/indexsets.hh:186
const DofSpace * dofSpace() const
Definition: dofvector.hh:221
Definition: albertagrid/gridfamily.hh:80
std::array< GeometryType, 1 > Types
iterator range for geometry types in domain
Definition: indexidset.hh:93
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/indexsets.hh:58
Definition: albertagrid/gridfamily.hh:65
Definition: albertagrid/entity.hh:42
Alberta::IndexStack IndexStack
Definition: albertagrid/indexsets.hh:80
Definition: indexstack.hh:23
Base::IndexType IndexType
Definition: albertagrid/indexsets.hh:52
int IndexType
The type used for the indices.
Definition: indexidset.hh:90
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
bool contains(const Entity &entity) const
Definition: albertagrid/indexsets.hh:373
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:128
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:146
IndexType size(int codim) const
Definition: albertagrid/indexsets.hh:422
IdType subId(const Entity &e, int i, unsigned int subcodim) const
Definition: albertagrid/indexsets.hh:589
bool contains(const Entity &) const
return true if entity is contained in set
Definition: albertagrid/indexsets.hh:84
IdType subId(const typename Grid::template Codim< codim >::Entity &e, int i, unsigned int subcodim) const
Definition: albertagrid/indexsets.hh:581
hierarchic index set of AlbertaGrid
Definition: albertagrid/gridfamily.hh:62
Alberta::HierarchyDofNumbering< dimension > DofNumbering
Definition: albertagrid/indexsets.hh:347
Know your own codimension.
Definition: common/entity.hh:105
IdType subId(const typename Grid::template Codim< 0 >::Entity &e, int i, unsigned int subcodim) const
Get id of subentity i of co-dimension codim of a co-dimension 0 entity.
Definition: albertagrid/indexsets.hh:573
InitEntityNumber(IndexStack &indexStack)
Definition: albertagrid/indexsets.hh:229
Definition: albertagrid/gridfamily.hh:95
AlbertaGridFamily< dim, dimworld > GridFamily
Definition: albertagrid/indexsets.hh:50
IdType id(const typename Grid::template Codim< codim >::Entity &e) const
Get id of an entity of codim cc. Unhandy because template parameter must be supplied explicitly...
Definition: albertagrid/indexsets.hh:565
Types types(int codim) const
Definition: albertagrid/indexsets.hh:428
IndexType size(int codim) const
return size of set
Definition: albertagrid/indexsets.hh:126
ALBERTA EL Element
Definition: misc.hh:52
~AlbertaGridIndexSet()
Definition: albertagrid/indexsets.hh:366
Provides base classes for index and id sets.
void update(const Iterator &begin, const Iterator &end)
Definition: albertagrid/indexsets.hh:441
provides the GridFamily for AlbertaGrid
Different resources needed by all grid implementations.
The dimension of the grid.
Definition: common/grid.hh:387
Base::Types Types
Definition: albertagrid/indexsets.hh:54
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/indexsets.hh:346
Id Set Interface.
Definition: common/grid.hh:347
Dune::IndexStack< int, 100000 > IndexStack
Definition: albertagrid/indexsets.hh:29
IdTypeImp IdType
Type used to represent an id.
Definition: indexidset.hh:444
const std::vector< GeometryType > & geomTypes(int codim) const
return geometry types this set has indices for
Definition: albertagrid/indexsets.hh:139
IndexType size(const GeometryType &type) const
Definition: albertagrid/indexsets.hh:417
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
return hierarchic index of given entity
Definition: albertagrid/indexsets.hh:392
IndexType subIndex(const ElementInfo &elementInfo, int i, unsigned int codim) const
Definition: albertagrid/indexsets.hh:145
IndexStack * currentIndexStack
Definition: indexsets.cc:17
const std::vector< GeometryType > & geomTypes(int codim) const
Definition: albertagrid/indexsets.hh:434