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>
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;
142 using size_type =
decltype(std::declval<typename GV::IndexSet>().size(0));
157 , indexSet_(&gridView_.indexSet())
170 template<
class EntityType>
174 assert(offset(gt) != invalidOffset);
175 return indexSet_->index(e)*blockSize(gt) + offset(gt);
185 Index subIndex (
const typename GV::template Codim<0>::Entity& e,
int i,
unsigned int codim)
const
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())};
250 IntegralRange<Index>
indices (
const typename GV::template Codim<0>::Entity& e,
int i,
int cc)
const
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)
291 bool contains (
const typename GV::template Codim<0>::Entity& e,
int i,
int cc,
Index& result)
const
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();
329 [[deprecated(
"Use update(gridView) instead! Will be removed after release 2.8.")]]
343 std::fill(offsets.begin(),offsets.end(),
Index(0));
344 std::fill(blocks.begin(),blocks.end(),
Index(0));
346 for (
unsigned int codim = 0; codim <= GV::dimension; ++codim)
349 for (
const GeometryType& gt : indexSet_->types(codim)) {
351 size_t block =
layout()(gt, GV::Grid::dimension);
357 n += indexSet_->size(gt) * block;
358 myTypes_[codim].push_back(gt);
361 offset = invalidOffset;
364 offsets[GlobalGeometryTypeIndex::index(gt)] = offset;
365 blocks[GlobalGeometryTypeIndex::index(gt)] = block;
371 {
return offsets[GlobalGeometryTypeIndex::index(gt)]; }
373 {
return blocks[GlobalGeometryTypeIndex::index(gt)]; }
381 const typename GV::IndexSet* indexSet_;
383 std::array<
Index, GlobalGeometryTypeIndex::size(GV::dimension)> offsets;
384 std::array<
Index, GlobalGeometryTypeIndex::size(GV::dimension)> blocks;
386 std::vector<GeometryType> myTypes_[GV::dimension+1];
400 template <
typename G>
426 Base::update(gridPtr_->leafGridView());
440 template <
typename G>
467 Base::update(gridPtr_->levelGridView(level_));
Provides classes with basic mappers which are used to attach data to a grid.
Grid< dim, dimworld, ct, GridFamily >::LeafGridView leafGridView(const Grid< dim, dimworld, ct, GridFamily > &grid)
leaf grid view for the given grid
Definition: common/grid.hh:819
Grid< dim, dimworld, ct, GridFamily >::LevelGridView levelGridView(const Grid< dim, dimworld, ct, GridFamily > &grid, int level)
level grid view for the given grid and level.
Definition: common/grid.hh:802
MCMGLayout mcmgLayout(Codim< codim >)
layout for entities of codimension codim
Definition: mcmgmapper.hh:72
MCMGLayout mcmgElementLayout()
layout for elements (codim-0 entities)
Definition: mcmgmapper.hh:97
std::function< size_t(GeometryType, int)> MCMGLayout
layout function for MultipleCodimMultipleGeomTypeMapper
Definition: mcmgmapper.hh:64
MCMGLayout mcmgVertexLayout()
layout for vertices (dim-0 entities)
Definition: mcmgmapper.hh:107
Include standard header files.
Definition: agrid.hh:60
int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:337
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Mapper interface.
Definition: mapper.hh:110
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: mcmgmapper.hh:129
bool contains(const EntityType &e, Index &result) const
Returns true if the entity is contained in the index set.
Definition: mcmgmapper.hh:272
size_type size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mcmgmapper.hh:204
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
MultipleCodimMultipleGeomTypeMapper(const GV &gridView, const MCMGLayout &layout)
construct mapper from grid and layout description
Definition: mcmgmapper.hh:155
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
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
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
Index index(const EntityType &e) const
Map entity to starting index in array for dof block.
Definition: mcmgmapper.hh:171
const GridView & gridView() const
Definition: mcmgmapper.hh:336
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
size_type size(GeometryType gt) const
return number of entries for a given geometry type
Definition: mcmgmapper.hh:210
const MCMGLayout & layout() const
Definition: mcmgmapper.hh:335
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
void update()
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:330
GV GridView
Underlying GridView.
Definition: mcmgmapper.hh:133
const std::vector< GeometryType > & types(int codim) const
return the geometry types with entries
Definition: mcmgmapper.hh:216
void update(GV &&gridView)
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:320
Multiple codim and multiple geometry type mapper for leaf entities.
Definition: mcmgmapper.hh:404
void update()
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:424
LeafMultipleCodimMultipleGeomTypeMapper(const G &grid, const MCMGLayout &layout)
constructor
Definition: mcmgmapper.hh:414
Multiple codim and multiple geometry type mapper for entities of one level.
Definition: mcmgmapper.hh:443
void update()
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:465
LevelMultipleCodimMultipleGeomTypeMapper(const G &grid, int level, const MCMGLayout &layout)
constructor
Definition: mcmgmapper.hh:454