4 #ifndef DUNE_GRID_COMMON_MCMGMAPPER_HH
5 #define DUNE_GRID_COMMON_MCMGMAPPER_HH
10 #include <dune/common/exceptions.hh>
11 #include <dune/common/rangeutilities.hh>
12 #include <dune/geometry/dimension.hh>
13 #include <dune/geometry/referenceelements.hh>
14 #include <dune/geometry/type.hh>
15 #include <dune/geometry/typeindex.hh>
73 return dimgrid - gt.dim() == codim;
86 return gt.dim() == dim;
124 template <
typename GV>
126 public Mapper<typename GV::Grid,MultipleCodimMultipleGeomTypeMapper<GV>, typename GV::IndexSet::IndexType >
134 typedef typename GV::IndexSet::IndexType
Index;
155 , indexSet_(&gridView_.indexSet())
168 template<
class EntityType>
172 assert(offset(gt) != invalidOffset);
173 return indexSet_->index(e)*blockSize(gt) + offset(gt);
183 Index subIndex (
const typename GV::template Codim<0>::Entity& e,
int i,
unsigned int codim)
const
187 GeometryTypes::none( GV::dimension - codim ) :
188 ReferenceElements<double,GV::dimension>::general(eType).type(i,codim) ;
190 assert(offset(gt) != invalidOffset);
191 return indexSet_->subIndex(e, i, codim)*blockSize(gt) + offset(gt);
210 return blockSize(gt);
214 const std::vector< GeometryType >&
types (
int codim )
const
216 return myTypes_[ codim ];
228 template<
class EntityType>
229 IntegralRange<Index>
indices (
const EntityType& e)
const
231 if(!indexSet_->contains(e) || offset(e.type()) == invalidOffset)
234 return {start, start+blockSize(e.type())};
248 IntegralRange<Index>
indices (
const typename GV::template Codim<0>::Entity& e,
int i,
int cc)
const
252 GeometryTypes::none(GV::dimension - cc) :
253 ReferenceElements<double,GV::dimension>::general(eType).type(i,cc) ;
254 if (offset(gt) == invalidOffset)
259 return {start, start+blockSize(gt)};
269 template<
class EntityType>
272 if(!indexSet_->contains(e) || offset(e.type()) == invalidOffset)
289 bool contains (
const typename GV::template Codim<0>::Entity& e,
int i,
int cc,
Index& result)
const
293 GeometryTypes::none( GV::dimension - cc ) :
294 ReferenceElements<double,GV::dimension>::general(eType).type(i,cc) ;
295 if (offset(gt) == invalidOffset)
297 result = indexSet_->subIndex(e, i, cc)*blockSize(gt) + offset(gt);
309 indexSet_ = &gridView_.indexSet();
321 indexSet_ = &gridView_.indexSet();
327 [[deprecated(
"Use update(gridView) instead! Will be removed after release 2.8.")]]
341 std::fill(offsets.begin(),offsets.end(),
Index(0));
342 std::fill(blocks.begin(),blocks.end(),
Index(0));
344 for (
unsigned int codim = 0; codim <= GV::dimension; ++codim)
347 for (
const GeometryType& gt : indexSet_->types(codim)) {
349 size_t block =
layout()(gt, GV::Grid::dimension);
355 n += indexSet_->size(gt) * block;
356 myTypes_[codim].push_back(gt);
359 offset = invalidOffset;
362 offsets[GlobalGeometryTypeIndex::index(gt)] = offset;
363 blocks[GlobalGeometryTypeIndex::index(gt)] = block;
369 {
return offsets[GlobalGeometryTypeIndex::index(gt)]; }
371 {
return blocks[GlobalGeometryTypeIndex::index(gt)]; }
379 const typename GV::IndexSet* indexSet_;
381 std::array<
Index, GlobalGeometryTypeIndex::size(GV::dimension)> offsets;
382 std::array<
Index, GlobalGeometryTypeIndex::size(GV::dimension)> blocks;
384 std::vector<GeometryType> myTypes_[GV::dimension+1];
398 template <
typename G>
424 Base::update(gridPtr_->leafGridView());
438 template <
typename G>
465 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:808
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:791
MCMGLayout mcmgLayout(Codim< codim >)
layout for entities of codimension codim
Definition: mcmgmapper.hh:70
MCMGLayout mcmgElementLayout()
layout for elements (codim-0 entities)
Definition: mcmgmapper.hh:95
std::function< size_t(GeometryType, int)> MCMGLayout
layout function for MultipleCodimMultipleGeomTypeMapper
Definition: mcmgmapper.hh:62
MCMGLayout mcmgVertexLayout()
layout for vertices (dim-0 entities)
Definition: mcmgmapper.hh:105
Include standard header files.
Definition: agrid.hh:58
int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:335
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:130
Mapper interface.
Definition: mapper.hh:108
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: mcmgmapper.hh:127
const GridView & gridView() const
Definition: mcmgmapper.hh:334
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:248
bool contains(const EntityType &e, Index &result) const
Returns true if the entity is contained in the index set.
Definition: mcmgmapper.hh:270
size_type size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mcmgmapper.hh:202
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:183
MultipleCodimMultipleGeomTypeMapper(const GV &gridView, const MCMGLayout &layout)
construct mapper from grid and layout description
Definition: mcmgmapper.hh:153
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:289
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:140
Index index(const EntityType &e) const
Map entity to starting index in array for dof block.
Definition: mcmgmapper.hh:169
void update(const GV &gridView)
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:306
const std::vector< GeometryType > & types(int codim) const
return the geometry types with entries
Definition: mcmgmapper.hh:214
GV::IndexSet::IndexType Index
Number type used for indices.
Definition: mcmgmapper.hh:134
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:229
size_type size(GeometryType gt) const
return number of entries for a given geometry type
Definition: mcmgmapper.hh:208
const MCMGLayout & layout() const
Definition: mcmgmapper.hh:333
void update()
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:328
GV GridView
Underlying GridView.
Definition: mcmgmapper.hh:131
void update(GV &&gridView)
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:318
Multiple codim and multiple geometry type mapper for leaf entities.
Definition: mcmgmapper.hh:402
void update()
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:422
LeafMultipleCodimMultipleGeomTypeMapper(const G &grid, const MCMGLayout &layout)
constructor
Definition: mcmgmapper.hh:412
Multiple codim and multiple geometry type mapper for entities of one level.
Definition: mcmgmapper.hh:441
void update()
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:463
LevelMultipleCodimMultipleGeomTypeMapper(const G &grid, int level, const MCMGLayout &layout)
constructor
Definition: mcmgmapper.hh:452