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 >
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 >
257 static const int codimension = codim;
263 : indexStack_( getIndexStack< codimension >( dofVector ) ),
264 dofVector_( dofVector ),
265 dofAccess_( dofVector.dofSpace() )
273 const Patch &patch );
286 template<
int dim,
int dimworld >
287 template<
int codim >
291 static const int codimension = codim;
297 : indexStack_( getIndexStack< codimension >( dofVector ) ),
298 dofVector_( dofVector ),
299 dofAccess_( dofVector.dofSpace() )
307 const Patch &patch );
319 template<
int dim,
int dimworld >
321 :
public IndexSet< AlbertaGrid< dim, dimworld >, AlbertaGridIndexSet< dim, dimworld >, int >
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 >
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 >
514 :
public IdSet< AlbertaGrid< dim, dimworld >, AlbertaGridIdSet< dim, dimworld >, unsigned int >
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