6 #ifndef DUNE_GRID_COMMON_MCMGMAPPER_HH 7 #define DUNE_GRID_COMMON_MCMGMAPPER_HH 12 #include <dune/common/exceptions.hh> 13 #include <dune/common/rangeutilities.hh> 14 #include <dune/geometry/dimension.hh> 15 #include <dune/geometry/referenceelements.hh> 16 #include <dune/geometry/type.hh> 17 #include <dune/geometry/typeindex.hh> 64 using MCMGLayout = std::function<size_t(GeometryType, int)>;
75 return dimgrid - gt.dim() == codim;
88 return gt.dim() == dim;
126 template <
typename GV>
128 public Mapper<typename GV::Grid,MultipleCodimMultipleGeomTypeMapper<GV>, typename GV::IndexSet::IndexType >
136 typedef typename GV::IndexSet::IndexType
Index;
157 , indexSet_(&gridView_.indexSet())
170 template<
class EntityType>
174 assert(offset(gt) != invalidOffset);
175 return indexSet_->index(e)*blockSize(gt) + offset(gt);
189 GeometryTypes::none( GV::dimension - codim ) :
190 ReferenceElements<double,GV::dimension>::general(eType).type(i,codim) ;
192 assert(offset(gt) != invalidOffset);
193 return indexSet_->subIndex(e, i, codim)*blockSize(gt) + offset(gt);
212 return blockSize(gt);
216 const std::vector< GeometryType >&
types (
int codim )
const 218 return myTypes_[ codim ];
230 template<
class EntityType>
231 IntegralRange<Index>
indices (
const EntityType& e)
const 233 if(!indexSet_->contains(e) || offset(e.type()) == invalidOffset)
236 return {start, start+blockSize(e.type())};
254 GeometryTypes::none(GV::dimension - cc) :
255 ReferenceElements<double,GV::dimension>::general(eType).type(i,cc) ;
256 if (offset(gt) == invalidOffset)
261 return {start, start+blockSize(gt)};
271 template<
class EntityType>
274 if(!indexSet_->contains(e) || offset(e.type()) == invalidOffset)
295 GeometryTypes::none( GV::dimension - cc ) :
296 ReferenceElements<double,GV::dimension>::general(eType).type(i,cc) ;
297 if (offset(gt) == invalidOffset)
299 result = indexSet_->subIndex(e, i, cc)*blockSize(gt) + offset(gt);
311 indexSet_ = &gridView_.indexSet();
323 indexSet_ = &gridView_.indexSet();
335 std::fill(offsets.begin(),offsets.end(),
Index(0));
336 std::fill(blocks.begin(),blocks.end(),
Index(0));
338 for (
unsigned int codim = 0; codim <= GV::dimension; ++codim)
341 for (
const GeometryType& gt : indexSet_->types(codim)) {
343 size_t block =
layout()(gt, GV::Grid::dimension);
349 n += indexSet_->size(gt) * block;
350 myTypes_[codim].push_back(gt);
353 offset = invalidOffset;
356 offsets[GlobalGeometryTypeIndex::index(gt)] = offset;
357 blocks[GlobalGeometryTypeIndex::index(gt)] = block;
363 {
return offsets[GlobalGeometryTypeIndex::index(gt)]; }
365 {
return blocks[GlobalGeometryTypeIndex::index(gt)]; }
375 std::array<Index, GlobalGeometryTypeIndex::size(GV::dimension)> offsets;
376 std::array<Index, GlobalGeometryTypeIndex::size(GV::dimension)> blocks;
378 std::vector<GeometryType> myTypes_[GV::dimension+1];
concept Entity
Model of a grid entity.
Definition: concepts/entity.hh:119
const std::vector< GeometryType > & types(int codim) const
return the geometry types with entries
Definition: mcmgmapper.hh:216
int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:337
IntegralRange< Index > indices(const typename GV::template Codim< 0 >::Entity &e, int i, int cc) const
Returns a pair with the starting point in the dof vector and the number of degrees of freedom if the ...
Definition: mcmgmapper.hh:250
std::function< size_t(GeometryType, int)> MCMGLayout
layout function for MultipleCodimMultipleGeomTypeMapper
Definition: mcmgmapper.hh:64
size_type size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mcmgmapper.hh:204
bool contains(const EntityType &e, Index &result) const
Returns true if the entity is contained in the index set.
Definition: mcmgmapper.hh:272
MCMGLayout mcmgLayout(Codim< codim >)
layout for entities of codimension codim
Definition: mcmgmapper.hh:72
Provides classes with basic mappers which are used to attach data to a grid.
bool contains(const typename GV::template Codim< 0 >::Entity &e, int i, int cc, Index &result) const
Returns true if the entity is contained in the index set.
Definition: mcmgmapper.hh:291
void update(const GV &gridView)
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:308
GV::IndexSet::IndexType Index
Number type used for indices.
Definition: mcmgmapper.hh:136
const GridView & gridView() const
Definition: mcmgmapper.hh:328
MCMGLayout mcmgElementLayout()
layout for elements (codim-0 entities)
Definition: mcmgmapper.hh:97
GV GridView
Underlying GridView.
Definition: mcmgmapper.hh:133
Include standard header files.
Definition: agrid.hh:59
const MCMGLayout & layout() const
Definition: mcmgmapper.hh:327
Index index(const EntityType &e) const
Map entity to starting index in array for dof block.
Definition: mcmgmapper.hh:171
MultipleCodimMultipleGeomTypeMapper(const GV &gridView, const MCMGLayout &layout)
construct mapper from grid and layout description
Definition: mcmgmapper.hh:155
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: mcmgmapper.hh:127
decltype(std::declval< typename GV::IndexSet >().size(0)) size_type
Number type used for the overall size (the return value of the 'size' method)
Definition: mcmgmapper.hh:142
MCMGLayout mcmgVertexLayout()
layout for vertices (dim-0 entities)
Definition: mcmgmapper.hh:107
void update(GV &&gridView)
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:320
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
size_type size(GeometryType gt) const
return number of entries for a given geometry type
Definition: mcmgmapper.hh:210
IntegralRange< Index > indices(const EntityType &e) const
Returns a pair with the starting point in the dof vector and the number of degrees of freedom if the ...
Definition: mcmgmapper.hh:231
Index subIndex(const typename GV::template Codim< 0 >::Entity &e, int i, unsigned int codim) const
Map subentity of codim 0 entity to starting index in array for dof block.
Definition: mcmgmapper.hh:185
concept IndexSet
Model of an index set.
Definition: concepts/indexidset.hh:55
Mapper interface.
Definition: mapper.hh:109