Go to the documentation of this file.
4 #ifndef DUNE_GRID_COMMON_MCMGMAPPER_HH
5 #define DUNE_GRID_COMMON_MCMGMAPPER_HH
10 #include <dune/common/deprecated.hh>
11 #include <dune/common/exceptions.hh>
12 #include <dune/common/rangeutilities.hh>
13 #include <dune/geometry/dimension.hh>
14 #include <dune/geometry/referenceelements.hh>
15 #include <dune/geometry/type.hh>
16 #include <dune/geometry/typeindex.hh>
84 struct MCMGFailLayout {
86 { DUNE_THROW(Exception,
"The default layout class cannot be used"); }
88 { DUNE_THROW(Exception,
"The default layout class cannot be used"); }
128 return dimgrid - gt.dim() == codim;
141 return gt.dim() == dim;
197 template <
typename GV,
template<
int>
class LayoutClass = Impl::MCMGFailLayout>
199 public Mapper<typename GV::Grid,MultipleCodimMultipleGeomTypeMapper<GV,LayoutClass>, typename GV::IndexSet::IndexType >
207 typedef typename GV::IndexSet::IndexType
Index;
240 , is(gridView_.indexSet())
253 template<
class EntityType>
257 assert(offset(gt) != invalidOffset);
258 return is.index(e)*blockSize(gt) + offset(gt);
268 Index subIndex (
const typename GV::template Codim<0>::Entity& e,
int i,
unsigned int codim)
const
272 GeometryTypes::none( GV::dimension - codim ) :
273 ReferenceElements<double,GV::dimension>::general(eType).type(i,codim) ;
275 assert(offset(gt) != invalidOffset);
276 return is.subIndex(e, i, codim)*blockSize(gt) + offset(gt);
295 return blockSize(gt);
299 const std::vector< GeometryType >&
types (
int codim )
const
301 return myTypes_[ codim ];
313 template<
class EntityType>
314 IntegralRange<Index>
indices (
const EntityType& e)
const
316 if(!is.contains(e) || offset(e.type()) == invalidOffset)
319 return {start, start+blockSize(e.type())};
333 IntegralRange<Index>
indices (
const typename GV::template Codim<0>::Entity& e,
int i,
int cc)
const
337 GeometryTypes::none(GV::dimension - cc) :
338 ReferenceElements<double,GV::dimension>::general(eType).type(i,cc) ;
339 if (offset(gt) == invalidOffset)
344 return {start, start+blockSize(gt)};
354 template<
class EntityType>
357 if(!is.contains(e) || offset(e.type()) == invalidOffset)
374 bool contains (
const typename GV::template Codim<0>::Entity& e,
int i,
int cc,
Index& result)
const
378 GeometryTypes::none( GV::dimension - cc ) :
379 ReferenceElements<double,GV::dimension>::general(eType).type(i,cc) ;
381 if (offset(gt) == invalidOffset)
383 result = is.subIndex(e, i, cc) + offset(gt);
393 std::fill(offsets.begin(),offsets.end(),
Index(0));
394 std::fill(blocks.begin(),blocks.end(),
Index(0));
396 for (
unsigned int codim = 0; codim <= GV::dimension; ++codim)
401 size_t block =
layout()(gt, GV::Grid::dimension);
407 n += is.size(gt) * block;
408 myTypes_[codim].push_back(gt);
411 offset = invalidOffset;
414 offsets[GlobalGeometryTypeIndex::index(gt)] = offset;
415 blocks[GlobalGeometryTypeIndex::index(gt)] = block;
425 {
return offsets[GlobalGeometryTypeIndex::index(gt)]; }
427 {
return blocks[GlobalGeometryTypeIndex::index(gt)]; }
429 static const Index invalidOffset = std::numeric_limits<Index>::max();
435 const typename GV::IndexSet& is;
437 std::array<
Index, GlobalGeometryTypeIndex::size(GV::dimension)> offsets;
438 std::array<
Index, GlobalGeometryTypeIndex::size(GV::dimension)> blocks;
440 std::vector<GeometryType> myTypes_[GV::dimension+1];
450 return layout.contains(gt);
470 template <
typename G,
template<
int>
class LayoutClass = Impl::MCMGFailLayout>
511 template <
typename G,
template<
int>
class LayoutClass = Impl::MCMGFailLayout>
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: mcmgmapper.hh:198
std::function< size_t(GeometryType, int)> MCMGLayout
layout function for MultipleCodimMultipleGeomTypeMapper
Definition: mcmgmapper.hh:117
const std::vector< GeometryType > & types(int codim) const
return the geometry types with entries
Definition: mcmgmapper.hh:299
const GridView & gridView() const
Definition: mcmgmapper.hh:421
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:792
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:374
size_type size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mcmgmapper.hh:287
static MCMGLayout wrapLayoutClass(const LayoutClass< GV::dimension > &layout)
wrap legacy layout classes
Definition: mcmgmapper.hh:446
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
MCMGLayout mcmgVertexLayout()
layout for vertices (dim-0 entities)
Definition: mcmgmapper.hh:160
Provides classes with basic mappers which are used to attach data to a grid.
GV::IndexSet::IndexType Index
Number type used for indices.
Definition: mcmgmapper.hh:207
Multiple codim and multiple geometry type mapper for entities of one level.
Definition: mcmgmapper.hh:512
MCMGLayout mcmgLayout(Codim< codim >)
layout for entities of codimension codim
Definition: mcmgmapper.hh:125
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:314
void update()
Recalculates map after mesh adaptation.
Definition: mcmgmapper.hh:389
LevelMultipleCodimMultipleGeomTypeMapper(const G &grid, int level, const LayoutClass< G::dimension > layout={}) DUNE_DEPRECATED_MSG("Use the const ructor taking a `MCMGLayout` functional instead")
The constructor.
Definition: mcmgmapper.hh:525
Index index(const EntityType &e) const
Map entity to starting index in array for dof block.
Definition: mcmgmapper.hh:254
MCMGLayout mcmgElementLayout()
layout for elements (codim-0 entities)
Definition: mcmgmapper.hh:150
Multiple codim and multiple geometry type mapper for leaf entities.
Definition: mcmgmapper.hh:471
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:213
MultipleCodimMultipleGeomTypeMapper(const GV &gridView, const LayoutClass< GV::dimension > layout={}) DUNE_DEPRECATED_MSG("Use the const ructor taking a `MCMGLayout` functional instead")
Construct mapper from grid and one of its index sets.
Definition: mcmgmapper.hh:222
size_type size(GeometryType gt) const
return number of entries for a given geometry type
Definition: mcmgmapper.hh:293
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:809
struct DUNE_DEPRECATED_MSG("The MCMG layout classes have been deprecated. Pass `mcmgElementLayout()` to the constructor instead") MCMGElementLayout
Layout template for elements.
Definition: mcmgmapper.hh:49
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:333
LevelMultipleCodimMultipleGeomTypeMapper(const G &grid, int level, const MCMGLayout &layout)
constructor
Definition: mcmgmapper.hh:537
GV GridView
Underlying GridView.
Definition: mcmgmapper.hh:204
const MCMGLayout & layout() const
Definition: mcmgmapper.hh:420
MultipleCodimMultipleGeomTypeMapper(const GV &gridView, const MCMGLayout &layout)
construct mapper from grid and layout description
Definition: mcmgmapper.hh:238
bool contains(const EntityType &e, Index &result) const
Returns true if the entity is contained in the index set.
Definition: mcmgmapper.hh:355
LeafMultipleCodimMultipleGeomTypeMapper(const G &grid, const MCMGLayout &layout)
constructor
Definition: mcmgmapper.hh:495
LeafMultipleCodimMultipleGeomTypeMapper(const G &grid, const LayoutClass< G::dimension > layout={}) DUNE_DEPRECATED_MSG("Use the const ructor taking a `MCMGLayout` functional instead")
The constructor.
Definition: mcmgmapper.hh:484
GV::IndexSet::IndexType Index
Number type used for indices.
Definition: mapper.hh:111
Mapper interface.
Definition: mapper.hh:107
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:268
Include standard header files.
Definition: agrid.hh:58