5#ifndef DUNE_ALBERTAGRIDINDEXSETS_HH
6#define DUNE_ALBERTAGRIDINDEXSETS_HH
11#include <dune/common/hybridutilities.hh>
12#include <dune/common/stdstreams.hh>
39 template<
int dim,
int dimworld >
41 :
public IndexSet< AlbertaGridFamily< dim, dimworld >, AlbertaGridHierarchicIndexSet< dim,dimworld >, int, std::array< GeometryType, 1 > >
85 template<
class Entity >
96 IndexType index (
const typename Traits::template Codim< cc >::Entity &entity )
const
99 const EntityImp &entityImp = entity.impl();
100 return subIndex( entityImp.elementInfo(), entityImp.subEntity(), cc );
105 IndexType subIndex (
const typename Traits::template Codim< cc >::Entity &entity,
int i,
unsigned int codim )
const
108 const EntityImp &entityImp = entity.impl();
113 auto refElement = ReferenceElements< Alberta::Real, dimension >::simplex();
114 k = refElement.subEntity( entityImp.subEntity(), cc, i, codim );
117 const int j = entityImp.grid().generic2alberta( codim, k );
118 return subIndex( entityImp.elementInfo(), j, codim );
122 std::size_t
size (
const GeometryType &type )
const
124 return (type.isSimplex() ?
size(
dimension - type.dim() ) : 0);
128 std::size_t
size (
int codim )
const
130 assert( (codim >= 0) && (codim <=
dimension) );
131 return indexStack_[ codim ].
size();
137 assert( (codim >= 0) && (codim <=
dimension) );
138 return {{ GeometryTypes::simplex(
dimension - codim ) }};
143 assert( !elementInfo ==
false );
166 assert( currentIndexStack ==
nullptr );
167 currentIndexStack = indexStack_;
175 currentIndexStack =
nullptr;
179 void read (
const std::string &filename );
180 bool write (
const std::string &filename )
const;
189 template<
int codim >
190 static IndexStack &getIndexStack (
const IndexVectorPointer &dofVector )
194 indexStack = dofVector.template getAdaptationData< IndexStack >();
196 indexStack = ¤tIndexStack[ codim ];
197 assert( indexStack != 0 );
208 IndexVectorPointer entityNumbers_[
dimension+1 ];
211 template<
int dim,
int dimworld >
212 Alberta::IndexStack* AlbertaGridHierarchicIndexSet<dim,dimworld>::currentIndexStack =
nullptr;
219 template<
int dim,
int dimworld >
226 : indexStack_( indexStack )
229 void operator() (
int &dof )
231 dof = indexStack_.getIndex();
240 template<
int dim,
int dimworld >
241 template<
int codim >
249 static void apply (
const std::string &filename,
259 template<
int dim,
int dimworld >
260 template<
int codim >
264 static const int codimension = codim;
270 : indexStack_( getIndexStack< codimension >( dofVector ) ),
271 dofVector_( dofVector ),
272 dofAccess_( dofVector.dofSpace() )
280 const Patch &patch );
293 template<
int dim,
int dimworld >
294 template<
int codim >
298 static const int codimension = codim;
304 : indexStack_( getIndexStack< codimension >( dofVector ) ),
305 dofVector_( dofVector ),
306 dofAccess_( dofVector.dofSpace() )
314 const Patch &patch );
326 template<
int dim,
int dimworld >
328 :
public IndexSet< AlbertaGrid< dim, dimworld >, AlbertaGridIndexSet< dim, dimworld >, int, std::array< GeometryType, 1 > >
348 template<
int codim >
353 : dofNumbering_( dofNumbering )
355 for(
int codim = 0; codim <=
dimension; ++codim )
357 indices_[ codim ] = 0;
363 for(
int codim = 0; codim <=
dimension; ++codim )
364 delete[] indices_[ codim ];
367 template<
class Entity >
376 const IndexType *
const array = indices_[ codim ];
387 IndexType index (
const typename Traits::template Codim< cc >::Entity &entity )
const
390 const EntityImp &entityImp = entity.impl();
391 return subIndex( entityImp.elementInfo(), entityImp.subEntity(), cc );
396 IndexType subIndex (
const typename Traits::template Codim< cc >::Entity &entity,
int i,
unsigned int codim )
const
399 const EntityImp &entityImp = entity.impl();
404 auto refElement = ReferenceElements< Alberta::Real, dimension >::simplex();
405 k = refElement.subEntity( entityImp.subEntity(), cc, i, codim );
408 const int j = entityImp.grid().generic2alberta( codim, k );
409 return subIndex( entityImp.elementInfo(), j, codim );
412 std::size_t
size (
const GeometryType &type )
const
414 return (type.isSimplex() ?
size(
dimension - type.dim() ) : 0);
417 std::size_t
size (
int codim )
const
419 assert( (codim >= 0) && (codim <=
dimension) );
420 return size_[ codim ];
425 assert( (codim >= 0) && (codim <=
dimension) );
426 return {{ GeometryTypes::simplex(
dimension - codim ) }};
429 template<
class Iterator >
430 void update (
const Iterator &begin,
const Iterator &end )
432 for(
int codim = 0; codim <=
dimension; ++codim )
434 delete[] indices_[ codim ];
436 const unsigned int dofSize = dofNumbering_.
size( codim );
437 indices_[ codim ] =
new IndexType[ dofSize ];
438 for(
unsigned int i = 0; i < dofSize; ++i )
439 indices_[ codim ][ i ] = -1;
444 for( Iterator it = begin; it != end; ++it )
449 Hybrid::forEach( std::make_index_sequence< dimension+1 >{},
457 assert( !elementInfo ==
false );
458 return subIndex( elementInfo.element(), i, codim );
469 const IndexType *
const array = indices_[ codim ];
490 template<
int dim,
int dimworld >
491 template<
int codim >
497 int *
const array = indexSet.indices_[ codim ];
500 for(
int i = 0; i < Alberta::NumSubEntities< dim, codim >::value; ++i )
502 int &
index = array[ indexSet.dofNumbering_( element, codim, i ) ];
515 template<
int dim,
int dimworld >
517 :
public IdSet< AlbertaGrid< dim, dimworld >, AlbertaGridIdSet< dim, dimworld >, unsigned int >
537 : hIndexSet_( hIndexSet )
542 template<
class Entity >
550 template<
int codim >
551 IdType id (
const typename Grid::template Codim< codim >::Entity &e )
const
553 assert( (codim >= 0) && (codim <= dimension) );
555 return (index << 2) |
IdType( codim );
559 IdType subId (
const typename Grid::template Codim< 0 >::Entity &e,
int i,
unsigned int subcodim )
const
561 assert(
int( subcodim ) <= dimension );
563 return (index << 2) |
IdType( subcodim );
566 template<
int codim >
567 IdType subId (
const typename Grid::template Codim< codim >::Entity &e,
int i,
unsigned int subcodim )
const
569 assert( (codim >= 0) && (codim <= dimension) && (
int( codim + subcodim ) <= dimension) );
571 return (index << 2) |
IdType( codim + subcodim );
574 template<
class Entity >
584 const HierarchicIndexSet &hIndexSet_;
Provides an index stack that supplies indices for element numbering for a grid (i....
provides a wrapper for ALBERTA's el_info structure
Include standard header files.
Definition agrid.hh:60
Dune::IndexStack< int, 100000 > IndexStack
Definition albertagrid/indexsets.hh:31
ALBERTA EL Element
Definition misc.hh:54
[ provides Dune::Grid ]
Definition albertagrid/structuredgridfactory.hh:34
static const int dimension
Definition agrid.hh:145
int size(int codim) const
Definition dofadmin.hh:163
static const bool supportsAdaptationData
Definition dofvector.hh:187
Element * el() const
Definition elementinfo.hh:737
const Element * element() const
Definition elementinfo.hh:721
Definition albertagrid/intersection.hh:23
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition albertagrid/entity.hh:148
const ElementInfo & elementInfo() const
Definition albertagrid/entity.hh:130
Definition albertagrid/indexsets.hh:42
Alberta::IndexStack IndexStack
Definition albertagrid/indexsets.hh:82
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:105
void read(const std::string &filename)
Definition indexsets.cc:141
void release()
Definition albertagrid/indexsets.hh:182
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
return hierarchic index of given entity
Definition albertagrid/indexsets.hh:96
std::size_t size(const GeometryType &type) const
return size of set for given GeometryType
Definition albertagrid/indexsets.hh:122
bool contains(const Entity &) const
return true if entity is contained in set
Definition albertagrid/indexsets.hh:86
AlbertaGridFamily< dim, dimworld > GridFamily
Definition albertagrid/indexsets.hh:50
Base::IndexType IndexType
Definition albertagrid/indexsets.hh:52
IndexType subIndex(const Alberta::Element *element, int i, unsigned int codim) const
obtain hierarchic subindex
Definition albertagrid/indexsets.hh:153
void create()
Definition indexsets.cc:133
Alberta::HierarchyDofNumbering< dimension > DofNumbering
Definition albertagrid/indexsets.hh:59
Alberta::ElementInfo< dimension > ElementInfo
Definition albertagrid/indexsets.hh:58
bool write(const std::string &filename) const
Definition indexsets.cc:149
void postAdapt()
Definition albertagrid/indexsets.hh:171
Base::Types Types
Definition albertagrid/indexsets.hh:54
IndexType subIndex(const ElementInfo &elementInfo, int i, unsigned int codim) const
Definition albertagrid/indexsets.hh:141
Types types(int codim) const
obtain all geometry types of entities in domain
Definition albertagrid/indexsets.hh:135
std::size_t size(int codim) const
return size of set
Definition albertagrid/indexsets.hh:128
AlbertaGrid< dim, dimworld > Grid
Definition albertagrid/indexsets.hh:49
static const int dimension
Definition albertagrid/indexsets.hh:56
void preAdapt()
Definition albertagrid/indexsets.hh:161
hierarchic index set of AlbertaGrid
Definition albertagrid/indexsets.hh:518
Base::IdType IdType
export type of id
Definition albertagrid/indexsets.hh:526
IdType id(const typename Grid::template Codim< codim >::Entity &e) const
Definition albertagrid/indexsets.hh:551
IdType id(const Entity &e) const
Definition albertagrid/indexsets.hh:543
IdType subId(const typename Grid::template Codim< 0 >::Entity &e, int i, unsigned int subcodim) const
Definition albertagrid/indexsets.hh:559
IdType subId(const typename Grid::template Codim< codim >::Entity &e, int i, unsigned int subcodim) const
Definition albertagrid/indexsets.hh:567
IdType subId(const Entity &e, int i, unsigned int subcodim) const
Definition albertagrid/indexsets.hh:575
Definition albertagrid/indexsets.hh:329
Alberta::ElementInfo< dimension > ElementInfo
Definition albertagrid/indexsets.hh:342
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
return hierarchic index of given entity
Definition albertagrid/indexsets.hh:387
AlbertaGrid< dim, dimworld > Grid
Definition albertagrid/indexsets.hh:334
AlbertaGridIndexSet(const DofNumbering &dofNumbering)
Definition albertagrid/indexsets.hh:352
bool contains(const Entity &entity) const
Definition albertagrid/indexsets.hh:368
Alberta::HierarchyDofNumbering< dimension > DofNumbering
Definition albertagrid/indexsets.hh:343
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:396
Types types(int codim) const
Definition albertagrid/indexsets.hh:423
Base::Types Types
Definition albertagrid/indexsets.hh:338
~AlbertaGridIndexSet()
Definition albertagrid/indexsets.hh:361
std::size_t size(int codim) const
Definition albertagrid/indexsets.hh:417
std::size_t size(const GeometryType &type) const
Definition albertagrid/indexsets.hh:412
void update(const Iterator &begin, const Iterator &end)
Definition albertagrid/indexsets.hh:430
static const int dimension
Definition albertagrid/indexsets.hh:340
Base::IndexType IndexType
Definition albertagrid/indexsets.hh:336
Definition albertagrid/gridfamily.hh:83
static const int dimension
Definition albertagrid/gridfamily.hh:88
Definition albertagrid/gridfamily.hh:98
Definition albertagrid/indexsets.hh:243
Definition albertagrid/indexsets.hh:262
Alberta::Patch< dimension > Patch
Definition albertagrid/indexsets.hh:278
Definition albertagrid/indexsets.hh:296
Alberta::Patch< dimension > Patch
Definition albertagrid/indexsets.hh:312
Definition albertagrid/indexsets.hh:221
InitEntityNumber(IndexStack &indexStack)
Definition albertagrid/indexsets.hh:225
Definition albertagrid/indexsets.hh:493
static void apply(const Alberta::Element *const element, AlbertaGridIndexSet< dim, dimworld > &indexSet)
Definition albertagrid/indexsets.hh:494
Definition indexstack.hh:26
int size() const
return maxIndex which is also the
Definition indexstack.hh:79
Definition refinement.hh:40
Wrapper class for entities.
Definition common/grid.hh:343
Implementation & impl()
access to the underlying implementation
Definition common/entity.hh:80
static constexpr int codimension
Know your own codimension.
Definition common/entity.hh:106
Index Set Interface base class.
Definition common/indexidset.hh:78
int IndexType
Definition common/indexidset.hh:92
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
Definition common/indexidset.hh:153
std::array< GeometryType, 1 > Types
Definition common/indexidset.hh:95
IndexType index(const typename Traits::template Codim< cc >::Entity &e) const
Definition common/indexidset.hh:113
Id Set Interface.
Definition common/indexidset.hh:447
IdTypeImp IdType
Type used to represent an id.
Definition common/indexidset.hh:453
provides the GridFamily for AlbertaGrid
Different resources needed by all grid implementations.
Provides base classes for index and id sets.