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 > >
69 struct CreateEntityNumbers;
72 struct RefineNumbering;
75 struct CoarsenNumbering;
85 template<
class Entity >
99 const EntityImp &entityImp = entity.impl();
100 return subIndex( entityImp.elementInfo(), entityImp.subEntity(), cc );
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 >
261 struct AlbertaGridHierarchicIndexSet< dim, dimworld >::RefineNumbering
264 static const int codimension = codim;
267 typedef Alberta::DofAccess< dimension, codimension > DofAccess;
269 explicit RefineNumbering (
const IndexVectorPointer &dofVector )
270 : indexStack_( getIndexStack< codimension >( dofVector ) ),
271 dofVector_( dofVector ),
272 dofAccess_( dofVector.dofSpace() )
278 typedef Alberta::Patch< dimension > Patch;
279 static void interpolateVector (
const IndexVectorPointer &dofVector,
280 const Patch &patch );
284 IndexVectorPointer dofVector_;
285 DofAccess dofAccess_;
293 template<
int dim,
int dimworld >
294 template<
int codim >
295 struct AlbertaGridHierarchicIndexSet< dim, dimworld >::CoarsenNumbering
298 static const int codimension = codim;
301 typedef Alberta::DofAccess< dimension, codimension > DofAccess;
303 explicit CoarsenNumbering (
const IndexVectorPointer &dofVector )
304 : indexStack_( getIndexStack< codimension >( dofVector ) ),
305 dofVector_( dofVector ),
306 dofAccess_( dofVector.dofSpace() )
312 typedef Alberta::Patch< dimension > Patch;
313 static void restrictVector (
const IndexVectorPointer &dofVector,
314 const Patch &patch );
317 IndexVectorPointer dofVector_;
318 DofAccess dofAccess_;
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 ];
390 const EntityImp &entityImp = entity.impl();
391 return subIndex( entityImp.elementInfo(), entityImp.subEntity(), cc );
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 >{},
450 [ & ](
auto i ){ Insert< i >::apply( element, *
this ); } );
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 >
492 struct AlbertaGridIndexSet< dim, dimworld >::Insert
495 AlbertaGridIndexSet< dim, dimworld > &indexSet )
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 >
546 return id< codim >( e );
550 template<
int codim >
553 assert( (codim >= 0) && (codim <= dimension) );
555 return (index << 2) |
IdType( codim );
561 assert(
int( subcodim ) <= dimension );
563 return (index << 2) |
IdType( subcodim );
566 template<
int codim >
569 assert( (codim >= 0) && (codim <= dimension) && (
int( codim + subcodim ) <= dimension) );
571 return (index << 2) |
IdType( codim + subcodim );
574 template<
class Entity >
577 return subId< Entity::codimension >( e, i, subcodim );
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 agrid.hh:109
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
const Element * element() const
Definition elementinfo.hh:721
Definition albertagrid/entity.hh:46
const ElementInfo & elementInfo() const
Definition albertagrid/entity.hh:130
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition albertagrid/entity.hh:148
Definition albertagrid/indexsets.hh:42
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
Base::IndexType IndexType
Definition albertagrid/indexsets.hh:52
void read(const std::string &filename)
Definition indexsets.cc:141
void release()
Definition albertagrid/indexsets.hh:182
Alberta::IndexStack IndexStack
Definition albertagrid/indexsets.hh:82
AlbertaGrid< dim, dimworld > Grid
Definition albertagrid/indexsets.hh:49
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
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
Base::Types Types
Definition albertagrid/indexsets.hh:54
bool write(const std::string &filename) const
Definition indexsets.cc:149
Alberta::ElementInfo< dimension > ElementInfo
Definition albertagrid/indexsets.hh:58
void postAdapt()
Definition albertagrid/indexsets.hh:171
IndexType subIndex(const ElementInfo &elementInfo, int i, unsigned int codim) const
Definition albertagrid/indexsets.hh:141
Alberta::HierarchyDofNumbering< dimension > DofNumbering
Definition albertagrid/indexsets.hh:59
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
AlbertaGridFamily< dim, dimworld > GridFamily
Definition albertagrid/indexsets.hh:50
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
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
Base::IdType IdType
export type of id
Definition albertagrid/indexsets.hh:526
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
Base::Types Types
Definition albertagrid/indexsets.hh:338
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
AlbertaGridIndexSet(const DofNumbering &dofNumbering)
Definition albertagrid/indexsets.hh:352
Alberta::HierarchyDofNumbering< dimension > DofNumbering
Definition albertagrid/indexsets.hh:343
bool contains(const Entity &entity) const
Definition albertagrid/indexsets.hh:368
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
Base::IndexType IndexType
Definition albertagrid/indexsets.hh:336
Types types(int codim) const
Definition albertagrid/indexsets.hh:423
~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
AlbertaGrid< dim, dimworld > Grid
Definition albertagrid/indexsets.hh:334
Definition albertagrid/gridfamily.hh:83
static const int dimension
Definition albertagrid/gridfamily.hh:88
Definition albertagrid/gridfamily.hh:98
Definition albertagrid/gridfamily.hh:117
Definition albertagrid/indexsets.hh:221
InitEntityNumber(IndexStack &indexStack)
Definition albertagrid/indexsets.hh:225
Definition indexstack.hh:26
int size() const
return maxIndex which is also the
Definition indexstack.hh:79
Wrapper class for entities.
Definition common/entity.hh:66
static constexpr int codimension
Know your own codimension.
Definition common/entity.hh:106
Implementation & impl()
access to the underlying implementation
Definition common/entity.hh:80
Index Set Interface base class.
Definition common/indexidset.hh:78
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
Map a subentity to an index.
Definition common/indexidset.hh:153
std::array< GeometryType, 1 > Types
iterator range for geometry types in domain
Definition common/indexidset.hh:95
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 common/indexidset.hh:113
int IndexType
The type used for the indices.
Definition common/indexidset.hh:92
Id Set Interface.
Definition common/indexidset.hh:447
A Traits struct that collects all associated types of one implementation.
Definition common/grid.hh:411
Export the type of the entity used as parameter in the id(...) method.
Definition common/indexidset.hh:457
provides the GridFamily for AlbertaGrid
Different resources needed by all grid implementations.
Provides base classes for index and id sets.