3 #ifndef DUNE_ALBERTAGRIDINDEXSETS_HH
4 #define DUNE_ALBERTAGRIDINDEXSETS_HH
6 #include <dune/common/stdstreams.hh>
35 template<
int dim,
int dimworld >
37 :
public IndexSet< AlbertaGridFamily< dim, dimworld >, AlbertaGridHierarchicIndexSet< dim,dimworld >, int >
63 struct CreateEntityNumbers;
66 struct RefineNumbering;
69 struct CoarsenNumbering;
77 template<
class Entity >
88 IndexType index (
const typename Traits::template Codim< cc >::Entity &entity )
const
92 return subIndex( entityImp.elementInfo(), entityImp.subEntity(), cc );
97 IndexType subIndex (
const typename Traits::template Codim< cc >::Entity &entity,
int i,
unsigned int codim )
const
105 const ReferenceElement< Alberta::Real, dimension > &refElement
107 k = refElement.subEntity( entityImp.subEntity(), cc, i, codim );
110 const int j = entityImp.grid().generic2alberta( codim, k );
111 return subIndex( entityImp.elementInfo(), j, codim );
117 return (type.isSimplex() ?
size(
dimension - type.dim() ) : 0);
123 assert( (codim >= 0) && (codim <=
dimension) );
124 return indexStack_[ codim ].
size();
128 const std::vector< GeometryType > &
geomTypes(
int codim )
const
130 assert( (codim >= 0) && (codim <=
dimension) );
131 return geomTypes_[ codim ];
136 assert( !elementInfo ==
false );
150 assert( (subIndex >= 0) && (subIndex <
size( codim )) );
172 void read (
const std::string &filename );
173 bool write (
const std::string &filename )
const;
182 template<
int codim >
183 static IndexStack &getIndexStack (
const IndexVectorPointer &dofVector )
187 indexStack = dofVector.template getAdaptationData< IndexStack >();
190 assert( indexStack != 0 );
201 IndexVectorPointer entityNumbers_[
dimension+1 ];
204 std::vector< GeometryType > geomTypes_[
dimension+1 ];
212 template<
int dim,
int dimworld >
219 : indexStack_( indexStack )
222 void operator() (
int &dof )
233 template<
int dim,
int dimworld >
234 template<
int codim >
242 static void apply (
const std::string &filename,
252 template<
int dim,
int dimworld >
253 template<
int codim >
254 struct AlbertaGridHierarchicIndexSet< dim, dimworld >::RefineNumbering
257 static const int codimension = codim;
260 typedef Alberta::DofAccess< dimension, codimension > DofAccess;
262 explicit RefineNumbering (
const IndexVectorPointer &dofVector )
263 : indexStack_( getIndexStack< codimension >( dofVector ) ),
264 dofVector_( dofVector ),
265 dofAccess_( dofVector.dofSpace() )
271 typedef Alberta::Patch< dimension > Patch;
272 static void interpolateVector (
const IndexVectorPointer &dofVector,
273 const Patch &patch );
277 IndexVectorPointer dofVector_;
278 DofAccess dofAccess_;
286 template<
int dim,
int dimworld >
287 template<
int codim >
288 struct AlbertaGridHierarchicIndexSet< dim, dimworld >::CoarsenNumbering
291 static const int codimension = codim;
294 typedef Alberta::DofAccess< dimension, codimension > DofAccess;
296 explicit CoarsenNumbering (
const IndexVectorPointer &dofVector )
297 : indexStack_( getIndexStack< codimension >( dofVector ) ),
298 dofVector_( dofVector ),
299 dofAccess_( dofVector.dofSpace() )
305 typedef Alberta::Patch< dimension > Patch;
306 static void restrictVector (
const IndexVectorPointer &dofVector,
307 const Patch &patch );
310 IndexVectorPointer dofVector_;
311 DofAccess dofAccess_;
319 template<
int dim,
int dimworld >
320 class AlbertaGridIndexSet
321 :
public IndexSet< AlbertaGrid< dim, dimworld >, AlbertaGridIndexSet< dim, dimworld >, int >
323 typedef AlbertaGridIndexSet< dim, dimworld > This;
324 typedef IndexSet< AlbertaGrid< dim, dimworld >, This,
int > Base;
339 template<
int codim >
344 : dofNumbering_( dofNumbering )
346 for(
int codim = 0; codim <=
dimension; ++codim )
348 indices_[ codim ] = 0;
351 geomTypes_[ codim ].push_back( type );
357 for(
int codim = 0; codim <=
dimension; ++codim )
358 delete[] indices_[ codim ];
361 template<
class Entity >
370 const IndexType *
const array = indices_[ codim ];
373 return (subIndex >= 0);
381 IndexType index (
const typename Traits::template Codim< cc >::Entity &entity )
const
385 return subIndex( entityImp.elementInfo(), entityImp.subEntity(), cc );
390 IndexType subIndex (
const typename Traits::template Codim< cc >::Entity &entity,
int i,
unsigned int codim )
const
398 const ReferenceElement< Alberta::Real, dimension > &refElement
400 k = refElement.subEntity( entityImp.subEntity(), cc, i, codim );
403 const int j = entityImp.grid().generic2alberta( codim, k );
404 return subIndex( entityImp.elementInfo(), j, codim );
409 return (type.isSimplex() ?
size(
dimension - type.dim() ) : 0);
414 assert( (codim >= 0) && (codim <=
dimension) );
415 return size_[ codim ];
418 const std::vector< GeometryType > &
geomTypes(
int codim )
const
420 assert( (codim >= 0) && (codim <=
dimension) );
421 return geomTypes_[ codim ];
424 template<
class Iterator >
425 void update (
const Iterator &begin,
const Iterator &end )
427 for(
int codim = 0; codim <=
dimension; ++codim )
429 delete[] indices_[ codim ];
431 const unsigned int dofSize = dofNumbering_.
size( codim );
432 indices_[ codim ] =
new IndexType[ dofSize ];
433 for(
unsigned int i = 0; i < dofSize; ++i )
434 indices_[ codim ][ i ] = -1;
439 for( Iterator it = begin; it != end; ++it )
444 ForLoop< Insert, 0, dimension >::apply( element, *
this );
451 assert( !elementInfo ==
false );
452 return subIndex( elementInfo.element(), i, codim );
463 const IndexType *
const array = indices_[ codim ];
465 assert( (subIndex >= 0) && (subIndex <
size( codim )) );
479 std::vector< GeometryType > geomTypes_[
dimension+1 ];
487 template<
int dim,
int dimworld >
488 template<
int codim >
489 struct AlbertaGridIndexSet< dim, dimworld >::Insert
492 AlbertaGridIndexSet< dim, dimworld > &indexSet )
494 int *
const array = indexSet.indices_[ codim ];
497 for(
int i = 0; i < Alberta::NumSubEntities< dim, codim >::value; ++i )
499 int &
index = array[ indexSet.dofNumbering_( element, codim, i ) ];
512 template<
int dim,
int dimworld >
513 class AlbertaGridIdSet
514 :
public IdSet< AlbertaGrid< dim, dimworld >, AlbertaGridIdSet< dim, dimworld >, unsigned int >
516 typedef AlbertaGridIdSet< dim, dimworld > This;
517 typedef IdSet< AlbertaGrid< dim, dimworld >, This,
unsigned int > Base;
534 : hIndexSet_( hIndexSet )
539 template<
class Entity >
543 return id< codim >( e );
547 template<
int codim >
548 IdType id (
const typename Grid::template Codim< codim >::Entity &e )
const
550 assert( (codim >= 0) && (codim <= dimension) );
552 return (index << 2) |
IdType( codim );
556 IdType subId (
const typename Grid::template Codim< 0 >::Entity &e,
int i,
unsigned int subcodim )
const
558 assert(
int( subcodim ) <= dimension );
560 return (index << 2) |
IdType( subcodim );
563 template<
int codim >
564 IdType subId (
const typename Grid::template Codim< codim >::Entity &e,
int i,
unsigned int subcodim )
const
566 assert( (codim >= 0) && (codim <= dimension) && (
int( codim + subcodim ) <= dimension) );
568 return (index << 2) |
IdType( codim + subcodim );
571 template<
class Entity >
574 return subId< Entity::codimension >( e, i, subcodim );
581 const HierarchicIndexSet &hIndexSet_;
586 #endif // #if HAVE_ALBERTA
588 #endif // #ifndef DUNE_ALBERTAGRIDINDEXSETS_HH
Base::IdType IdType
export type of id
Definition: albertagrid/indexsets.hh:523
Know your own codimension.
Definition: common/entity.hh:99
IndexType size(const GeometryType &type) const
return size of set for given GeometryType
Definition: albertagrid/indexsets.hh:115
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:556
Definition: albertagrid/gridfamily.hh:81
IndexType size(const GeometryType &type) const
Definition: albertagrid/indexsets.hh:407
Dune::IndexStack< int, 100000 > IndexStack
Definition: albertagrid/indexsets.hh:25
int size(int codim) const
Definition: dofadmin.hh:157
static ReturnImplementationType< InterfaceType >::ImplementationType & getRealImplementation(InterfaceType &i)
return real implementation of interface class
Definition: common/grid.hh:1223
IndexType size(int codim) const
return size of set
Definition: albertagrid/indexsets.hh:121
Wrapper class for entities.
Definition: common/entity.hh:56
void preAdapt()
Definition: albertagrid/indexsets.hh:154
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
void update(const Iterator &begin, const Iterator &end)
Definition: albertagrid/indexsets.hh:425
Index Set Interface base class.
Definition: common/grid.hh:359
IndexType subIndex(const ElementInfo &elementInfo, int i, unsigned int codim) const
Definition: albertagrid/indexsets.hh:134
const std::vector< GeometryType > & geomTypes(int codim) const
Definition: albertagrid/indexsets.hh:418
bool contains(const Entity &entity) const
Definition: albertagrid/indexsets.hh:362
Provides an index stack that supplies indices for element numbering for a grid (i.e. AlbertaGrid and ALUGrid)
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:97
Alberta::HierarchyDofNumbering< dimension > DofNumbering
Definition: albertagrid/indexsets.hh:53
IdTypeImp IdType
Type used to represent an id.
Definition: indexidset.hh:406
const Element * element() const
Definition: elementinfo.hh:781
~AlbertaGridIndexSet()
Definition: albertagrid/indexsets.hh:355
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/indexsets.hh:333
IdType subId(const typename Grid::template Codim< codim >::Entity &e, int i, unsigned int subcodim) const
Definition: albertagrid/indexsets.hh:564
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:390
IndexStack * currentIndexStack
Definition: indexsets.cc:17
IndexTypeImp IndexType
The type used for the indices.
Definition: indexidset.hh:85
Provides base classes for index and id sets.
Base::IndexType IndexType
Definition: albertagrid/indexsets.hh:329
InitEntityNumber(IndexStack &indexStack)
Definition: albertagrid/indexsets.hh:218
AlbertaGrid< dim, dimworld > Grid
Definition: albertagrid/indexsets.hh:45
IndexType size(int codim) const
Definition: albertagrid/indexsets.hh:412
AlbertaGridFamily< dim, dimworld > GridFamily
Definition: albertagrid/indexsets.hh:46
IdType subId(const Entity &e, int i, unsigned int subcodim) const
Definition: albertagrid/indexsets.hh:572
void create()
Definition: indexsets.cc:146
Definition: albertagrid/gridfamily.hh:51
Definition: albertagrid/indexsets.hh:213
provides the GridFamily for AlbertaGrid
int size() const
return maxIndex which is also the
Definition: indexstack.hh:77
AlbertaGridIndexSet(const DofNumbering &dofNumbering)
Definition: albertagrid/indexsets.hh:343
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:548
[ provides Dune::Grid ]
Definition: agrid.hh:137
static const int dimension
Definition: albertagrid/indexsets.hh:50
static const int dimension
Definition: albertagrid/gridfamily.hh:87
IndexType index(const typename remove_const< GridImp >::type::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:107
Alberta::HierarchyDofNumbering< dimension > DofNumbering
Definition: albertagrid/indexsets.hh:334
Alberta::ElementInfo< dimension > ElementInfo
Definition: albertagrid/indexsets.hh:52
provides a wrapper for ALBERTA's el_info structure
static const int dimension
Definition: albertagrid/indexsets.hh:331
Definition: albertagrid/gridfamily.hh:96
IndexType subIndex(const Alberta::Element *element, int i, unsigned int codim) const
obtain hierarchic subindex
Definition: albertagrid/indexsets.hh:146
Alberta::IndexStack IndexStack
Definition: albertagrid/indexsets.hh:74
static const int dimension
Definition: agrid.hh:177
AlbertaGrid< dim, dimworld > Grid
Definition: albertagrid/indexsets.hh:327
ALBERTA EL Element
Definition: misc.hh:61
static const bool supportsAdaptationData
Definition: dofvector.hh:185
const std::vector< GeometryType > & geomTypes(int codim) const
return geometry types this set has indices for
Definition: albertagrid/indexsets.hh:128
void postAdapt()
Definition: albertagrid/indexsets.hh:164
bool contains(const Entity &) const
return true if entity is contained in set
Definition: albertagrid/indexsets.hh:78
void release()
Definition: albertagrid/indexsets.hh:175
Different resources needed by all grid implementations.
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
return hierarchic index of given entity
Definition: albertagrid/indexsets.hh:88
Definition: alugrid/common/declaration.hh:18
T getIndex()
restore index from stack or create new index
Definition: indexstack.hh:137
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:146
bool write(const std::string &filename) const
Definition: indexsets.cc:160
Base::IndexType IndexType
Definition: albertagrid/indexsets.hh:48
void read(const std::string &filename)
Definition: indexsets.cc:153
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
return hierarchic index of given entity
Definition: albertagrid/indexsets.hh:381
IdType id(const Entity &e) const
Get id of an entity. This method is simpler to use than the one below.
Definition: albertagrid/indexsets.hh:540
hierarchic index set of AlbertaGrid
Definition: albertagrid/gridfamily.hh:63
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition: albertagrid/entity.hh:124
Definition: albertagrid/entity.hh:45
Definition: indexstack.hh:23
Element * el() const
Definition: elementinfo.hh:797
const ElementInfo & elementInfo() const
Definition: albertagrid/entity.hh:106