Go to the documentation of this file.
3 #ifndef DUNE_ALBERTAGRIDINDEXSETS_HH
4 #define DUNE_ALBERTAGRIDINDEXSETS_HH
8 #include <dune/common/stdstreams.hh>
37 template<
int dim,
int dimworld >
39 :
public IndexSet< AlbertaGridFamily< dim, dimworld >, AlbertaGridHierarchicIndexSet< dim,dimworld >, int, std::array< GeometryType, 1 > >
67 struct CreateEntityNumbers;
70 struct RefineNumbering;
73 struct CoarsenNumbering;
81 template<
class Entity >
92 IndexType index (
const typename Traits::template Codim< cc >::Entity &entity )
const
96 return subIndex( entityImp.elementInfo(), entityImp.subEntity(), cc );
101 IndexType subIndex (
const typename Traits::template Codim< cc >::Entity &entity,
int i,
unsigned int codim )
const
109 const ReferenceElement< Alberta::Real, dimension > &refElement
110 = ReferenceElements< Alberta::Real, dimension >::simplex();
111 k = refElement.subEntity( entityImp.subEntity(), cc, i, codim );
114 const int j = entityImp.grid().generic2alberta( codim, k );
115 return subIndex( entityImp.elementInfo(), j, codim );
121 return (type.isSimplex() ?
size(
dimension - type.dim() ) : 0);
127 assert( (codim >= 0) && (codim <=
dimension) );
128 return indexStack_[ codim ].
size();
133 assert( (codim >= 0) && (codim <=
dimension) );
134 std::array< GeometryType, 1 >
types;
140 const std::vector< GeometryType > &
geomTypes(
int codim )
const
142 assert( (codim >= 0) && (codim <=
dimension) );
143 return geomTypes_[ codim ];
148 assert( !elementInfo ==
false );
184 void read (
const std::string &filename );
185 bool write (
const std::string &filename )
const;
194 template<
int codim >
195 static IndexStack &getIndexStack (
const IndexVectorPointer &dofVector )
199 indexStack = dofVector.template getAdaptationData< IndexStack >();
202 assert( indexStack != 0 );
213 IndexVectorPointer entityNumbers_[
dimension+1 ];
216 std::vector< GeometryType > geomTypes_[
dimension+1 ];
224 template<
int dim,
int dimworld >
231 : indexStack_( indexStack )
234 void operator() (
int &dof )
236 dof = indexStack_.getIndex();
245 template<
int dim,
int dimworld >
246 template<
int codim >
254 static void apply (
const std::string &filename,
264 template<
int dim,
int dimworld >
265 template<
int codim >
266 struct AlbertaGridHierarchicIndexSet< dim, dimworld >::RefineNumbering
269 static const int codimension = codim;
272 typedef Alberta::DofAccess< dimension, codimension > DofAccess;
274 explicit RefineNumbering (
const IndexVectorPointer &dofVector )
275 : indexStack_( getIndexStack< codimension >( dofVector ) ),
276 dofVector_( dofVector ),
277 dofAccess_( dofVector.dofSpace() )
283 typedef Alberta::Patch< dimension > Patch;
284 static void interpolateVector (
const IndexVectorPointer &dofVector,
285 const Patch &patch );
289 IndexVectorPointer dofVector_;
290 DofAccess dofAccess_;
298 template<
int dim,
int dimworld >
299 template<
int codim >
300 struct AlbertaGridHierarchicIndexSet< dim, dimworld >::CoarsenNumbering
303 static const int codimension = codim;
306 typedef Alberta::DofAccess< dimension, codimension > DofAccess;
308 explicit CoarsenNumbering (
const IndexVectorPointer &dofVector )
309 : indexStack_( getIndexStack< codimension >( dofVector ) ),
310 dofVector_( dofVector ),
311 dofAccess_( dofVector.dofSpace() )
317 typedef Alberta::Patch< dimension > Patch;
318 static void restrictVector (
const IndexVectorPointer &dofVector,
319 const Patch &patch );
322 IndexVectorPointer dofVector_;
323 DofAccess dofAccess_;
331 template<
int dim,
int dimworld >
332 class AlbertaGridIndexSet
333 :
public IndexSet< AlbertaGrid< dim, dimworld >, AlbertaGridIndexSet< dim, dimworld >, int, std::array< GeometryType, 1 > >
335 typedef AlbertaGridIndexSet< dim, dimworld > This;
336 typedef IndexSet< AlbertaGrid< dim, dimworld >, AlbertaGridIndexSet< dim, dimworld >, int, std::array< GeometryType, 1 > > Base;
353 template<
int codim >
358 : dofNumbering_( dofNumbering )
360 for(
int codim = 0; codim <=
dimension; ++codim )
362 indices_[ codim ] = 0;
365 geomTypes_[ codim ].push_back( type );
371 for(
int codim = 0; codim <=
dimension; ++codim )
372 delete[] indices_[ codim ];
375 template<
class Entity >
384 const IndexType *
const array = indices_[ codim ];
395 IndexType index (
const typename Traits::template Codim< cc >::Entity &entity )
const
399 return subIndex( entityImp.elementInfo(), entityImp.subEntity(), cc );
404 IndexType subIndex (
const typename Traits::template Codim< cc >::Entity &entity,
int i,
unsigned int codim )
const
412 const ReferenceElement< Alberta::Real, dimension > &refElement
413 = ReferenceElements< Alberta::Real, dimension >::simplex();
414 k = refElement.subEntity( entityImp.subEntity(), cc, i, codim );
417 const int j = entityImp.grid().generic2alberta( codim, k );
418 return subIndex( entityImp.elementInfo(), j, codim );
423 return (type.isSimplex() ?
size(
dimension - type.dim() ) : 0);
428 assert( (codim >= 0) && (codim <=
dimension) );
429 return size_[ codim ];
434 assert( (codim >= 0) && (codim <=
dimension) );
435 std::array< GeometryType, 1 >
types;
440 const std::vector< GeometryType > &
geomTypes(
int codim )
const
442 assert( (codim >= 0) && (codim <=
dimension) );
443 return geomTypes_[ codim ];
446 template<
class Iterator >
447 void update (
const Iterator &begin,
const Iterator &end )
449 for(
int codim = 0; codim <=
dimension; ++codim )
451 delete[] indices_[ codim ];
453 const unsigned int dofSize = dofNumbering_.
size( codim );
454 indices_[ codim ] =
new IndexType[ dofSize ];
455 for(
unsigned int i = 0; i < dofSize; ++i )
456 indices_[ codim ][ i ] = -1;
461 for( Iterator it = begin; it != end; ++it )
466 ForLoop< Insert, 0, dimension >::apply( element, *
this );
473 assert( !elementInfo ==
false );
474 return subIndex( elementInfo.element(), i, codim );
485 const IndexType *
const array = indices_[ codim ];
501 std::vector< GeometryType > geomTypes_[
dimension+1 ];
509 template<
int dim,
int dimworld >
510 template<
int codim >
511 struct AlbertaGridIndexSet< dim, dimworld >::Insert
514 AlbertaGridIndexSet< dim, dimworld > &indexSet )
516 int *
const array = indexSet.indices_[ codim ];
519 for(
int i = 0; i < Alberta::NumSubEntities< dim, codim >::value; ++i )
521 int &
index = array[ indexSet.dofNumbering_( element, codim, i ) ];
534 template<
int dim,
int dimworld >
535 class AlbertaGridIdSet
536 :
public IdSet< AlbertaGrid< dim, dimworld >, AlbertaGridIdSet< dim, dimworld >, unsigned int >
538 typedef AlbertaGridIdSet< dim, dimworld > This;
539 typedef IdSet< AlbertaGrid< dim, dimworld >, This,
unsigned int > Base;
556 : hIndexSet_( hIndexSet )
561 template<
class Entity >
565 return id< codim >( e );
569 template<
int codim >
570 IdType id (
const typename Grid::template Codim< codim >::Entity &e )
const
572 assert( (codim >= 0) && (codim <= dimension) );
574 return (index << 2) |
IdType( codim );
578 IdType subId (
const typename Grid::template Codim< 0 >::Entity &e,
int i,
unsigned int subcodim )
const
580 assert(
int( subcodim ) <= dimension );
582 return (index << 2) |
IdType( subcodim );
585 template<
int codim >
586 IdType subId (
const typename Grid::template Codim< codim >::Entity &e,
int i,
unsigned int subcodim )
const
588 assert( (codim >= 0) && (codim <= dimension) && (
int( codim + subcodim ) <= dimension) );
590 return (index << 2) |
IdType( codim + subcodim );
593 template<
class Entity >
596 return subId< Entity::codimension >( e, i, subcodim );
603 const HierarchicIndexSet &hIndexSet_;
608 #endif // #if HAVE_ALBERTA
610 #endif // #ifndef DUNE_ALBERTAGRIDINDEXSETS_HH
Different resources needed by all grid implementations.
AlbertaGridIndexSet(const DofNumbering &dofNumbering)
Definition: albertagrid/indexsets.hh:357
provides a wrapper for ALBERTA's el_info structure
Alberta::HierarchyDofNumbering< dimension > DofNumbering
Definition: albertagrid/indexsets.hh:57
Definition: albertagrid/entity.hh:45
Definition: albertagrid/gridfamily.hh:51
Alberta::IndexStack IndexStack
Definition: albertagrid/indexsets.hh:78
Include standard header files.
Definition: agrid.hh:59
bool contains(const Entity &) const
return true if entity is contained in set
Definition: albertagrid/indexsets.hh:82
void read(const std::string &filename)
Definition: indexsets.cc:153
Provides an index stack that supplies indices for element numbering for a grid (i....
[ provides Dune::Grid ]
Definition: agrid.hh:137
Know your own codimension.
Definition: common/entity.hh:104
const Element * element() const
Definition: elementinfo.hh:719
Alberta::HierarchyDofNumbering< dimension > DofNumbering
Definition: albertagrid/indexsets.hh:348
IndexType subIndex(const Alberta::Element *element, int i, unsigned int codim) const
obtain hierarchic subindex
Definition: albertagrid/indexsets.hh:158
Definition: indexstack.hh:23
Element * el() const
Definition: elementinfo.hh:735
bool contains(const Entity &entity) const
Definition: albertagrid/indexsets.hh:376
static const int dimension
Definition: albertagrid/indexsets.hh:345
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
return hierarchic index of given entity
Definition: albertagrid/indexsets.hh:92
static const int dimension
Definition: albertagrid/gridfamily.hh:87
Types types(int codim) const
Definition: albertagrid/indexsets.hh:432
Types types(int codim) const
Definition: albertagrid/indexsets.hh:131
Base::IndexType IndexType
Definition: albertagrid/indexsets.hh:50
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
Map a subentity to an index.
Definition: indexidset.hh:149
Wrapper class for entities.
Definition: common/entity.hh:61
ALBERTA EL Element
Definition: misc.hh:51
int size() const
return maxIndex which is also the
Definition: indexstack.hh:77
AlbertaGrid< dim, dimworld > Grid
Definition: albertagrid/indexsets.hh:47
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:101
IdTypeImp IdType
Type used to represent an id.
Definition: indexidset.hh:400
Provides base classes for index and id sets.
IndexType size(int codim) const
return size of set
Definition: albertagrid/indexsets.hh:125
void postAdapt()
Definition: albertagrid/indexsets.hh:176
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 explicitely.
Definition: albertagrid/indexsets.hh:570
AlbertaGridFamily< dim, dimworld > GridFamily
Definition: albertagrid/indexsets.hh:48
AlbertaGrid< dim, dimworld > Grid
Definition: albertagrid/indexsets.hh:339
IndexType size(int codim) const
Definition: albertagrid/indexsets.hh:426
void preAdapt()
Definition: albertagrid/indexsets.hh:166
void update(const Iterator &begin, const Iterator &end)
Definition: albertagrid/indexsets.hh:447
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
return hierarchic index of given entity
Definition: albertagrid/indexsets.hh:395
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:126
IndexType size(const GeometryType &type) const
return size of set for given GeometryType
Definition: albertagrid/indexsets.hh:119
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:108
IdType subId(const Entity &e, int i, unsigned int subcodim) const
Definition: albertagrid/indexsets.hh:594
Index Set Interface base class.
Definition: common/grid.hh:346
Base::Types Types
Definition: albertagrid/indexsets.hh:52
IndexType index(const typename Traits::template Codim< cc >::Entity &e) const
Map entity to index. The result of calling this method with an entity that is not in the index set is...
Definition: indexidset.hh:111
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/indexsets.hh:56
static std::conditional< std::is_reference< InterfaceType >::value, typename std::add_lvalue_reference< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type, typename std::remove_const< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: common/grid.hh:1119
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:404
std::array< GeometryType, 1 > Types
iterator range for geometry types in domain
Definition: indexidset.hh:93
IndexType subIndex(const ElementInfo &elementInfo, int i, unsigned int codim) const
Definition: albertagrid/indexsets.hh:146
int size(int codim) const
Definition: dofadmin.hh:157
provides the GridFamily for AlbertaGrid
Dune::IndexStack< int, 100000 > IndexStack
Definition: albertagrid/indexsets.hh:27
~AlbertaGridIndexSet()
Definition: albertagrid/indexsets.hh:369
IdType subId(const typename Grid::template Codim< codim >::Entity &e, int i, unsigned int subcodim) const
Definition: albertagrid/indexsets.hh:586
const std::vector< GeometryType > & geomTypes(int codim) const
Definition: albertagrid/indexsets.hh:440
InitEntityNumber(IndexStack &indexStack)
Definition: albertagrid/indexsets.hh:230
void create()
Definition: indexsets.cc:146
IndexStack * currentIndexStack
Definition: indexsets.cc:17
Base::IndexType IndexType
Definition: albertagrid/indexsets.hh:341
static const bool supportsAdaptationData
Definition: dofvector.hh:185
Definition: albertagrid/gridfamily.hh:96
IdType id(const Entity &e) const
Definition: albertagrid/indexsets.hh:562
Base::IdType IdType
export type of id
Definition: albertagrid/indexsets.hh:545
Base::Types Types
Definition: albertagrid/indexsets.hh:343
static const int dimension
Definition: agrid.hh:177
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/indexsets.hh:347
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:578
static const int dimension
Definition: albertagrid/indexsets.hh:54
hierarchic index set of AlbertaGrid
Definition: albertagrid/gridfamily.hh:63
const std::vector< GeometryType > & geomTypes(int codim) const
return geometry types this set has indices for
Definition: albertagrid/indexsets.hh:140
bool write(const std::string &filename) const
Definition: indexsets.cc:160
void release()
Definition: albertagrid/indexsets.hh:187
Definition: albertagrid/indexsets.hh:225
Definition: albertagrid/gridfamily.hh:81
IndexType size(const GeometryType &type) const
Definition: albertagrid/indexsets.hh:421
int IndexType
The type used for the indices.
Definition: indexidset.hh:90