4#ifndef DUNE_GRID_COMMON_MCMGMAPPER_HH
5#define DUNE_GRID_COMMON_MCMGMAPPER_HH
9#include <dune/geometry/referenceelements.hh>
10#include <dune/geometry/type.hh>
11#include <dune/geometry/typeindex.hh>
45 bool contains (Dune::GeometryType gt) {
return gt.dim()==dimgrid; }
59 bool contains (Dune::GeometryType gt) {
return gt.dim()==0; }
100 template <
typename GV,
template<
int>
class Layout>
102 public Mapper<typename GV::Grid,MultipleCodimMultipleGeomTypeMapper<GV,Layout>, typename GV::IndexSet::IndexType >
107 typedef typename GV::IndexSet::IndexType
Index;
118 : gridView(gridView_),
119 is(gridView.indexSet()),
120 offset(GlobalGeometryTypeIndex::
size(GV::dimension)),
131 : gridView(gridView_),
132 is(gridView.indexSet()),
133 offset(GlobalGeometryTypeIndex::
size(GV::dimension))
145 template<
class EntityType>
148 const GeometryType gt = e.type();
149 assert(layout.contains(gt));
150 return is.index(e) + offset[GlobalGeometryTypeIndex::index(gt)];
160 Index subIndex (
const typename GV::template Codim<0>::Entity& e,
int i,
unsigned int codim)
const
162 GeometryType gt=ReferenceElements<double,GV::dimension>::general(e.type()).type(i,codim);
163 assert(layout.contains(gt));
164 return is.subIndex(e, i, codim) + offset[GlobalGeometryTypeIndex::index(gt)];
186 template<
class EntityType>
189 if(!is.contains(e) || !layout.contains(e.type()))
206 bool contains (
const typename GV::template Codim<0>::Entity& e,
int i,
int cc,
Index& result)
const
208 GeometryType gt=ReferenceElements<double,GV::dimension>::general(e.type()).type(i,cc);
209 if (not layout.contains(gt))
211 result = is.subIndex(e, i, cc) + offset[GlobalGeometryTypeIndex::index(gt)];
221 for (
unsigned int codim = 0; codim <= GV::dimension; ++codim)
224 typedef typename GV::IndexSet::Types GTV;
225 GTV gtv = is.types(codim);
226 for (
typename GTV::const_iterator it = gtv.begin(); it != gtv.end(); ++it)
229 if (layout.contains(*it))
231 offset[GlobalGeometryTypeIndex::index(*it)] = n;
243 const typename GV::IndexSet& is;
245 std::vector<int> offset;
246 mutable Layout<GV::dimension> layout;
264 template <
typename G,
template<
int>
class Layout>
303 template <
typename G,
template<
int>
class Layout>
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:878
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:861
Include standard header files.
Definition agrid.hh:60
Mapper interface.
Definition mapper.hh:107
Layout template for elements.
Definition mcmgmapper.hh:42
bool contains(Dune::GeometryType gt)
Definition mcmgmapper.hh:45
Layout template for vertices.
Definition mcmgmapper.hh:56
bool contains(Dune::GeometryType gt)
Definition mcmgmapper.hh:59
Implementation class for a multiple codim and multiple geometry type mapper.
Definition mcmgmapper.hh:103
MultipleCodimMultipleGeomTypeMapper(const GV &gridView_)
Construct mapper from grid and one of its index sets.
Definition mcmgmapper.hh:130
void update()
Recalculates map after mesh adaptation.
Definition mcmgmapper.hh:217
bool contains(const EntityType &e, Index &result) const
Returns true if the entity is contained in the index set.
Definition mcmgmapper.hh:187
Index index(const EntityType &e) const
Map entity to array index.
Definition mcmgmapper.hh:146
GV::IndexSet::IndexType Index
Number type used for indices.
Definition mcmgmapper.hh:107
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:206
Index subIndex(const typename GV::template Codim< 0 >::Entity &e, int i, unsigned int codim) const
Map subentity of codim 0 entity to array index.
Definition mcmgmapper.hh:160
MultipleCodimMultipleGeomTypeMapper(const GV &gridView_, const Layout< GV::dimension > layout)
Construct mapper from grid and one of its index sets.
Definition mcmgmapper.hh:117
int size() const
Return total number of entities in the entity set managed by the mapper.
Definition mcmgmapper.hh:175
Multiple codim and multiple geometry type mapper for leaf entities.
Definition mcmgmapper.hh:267
LeafMultipleCodimMultipleGeomTypeMapper(const G &grid, const Layout< G::dimension > layout)
The constructor.
Definition mcmgmapper.hh:286
LeafMultipleCodimMultipleGeomTypeMapper(const G &grid)
The constructor.
Definition mcmgmapper.hh:274
Multiple codim and multiple geometry type mapper for entities of one level.
Definition mcmgmapper.hh:305
LevelMultipleCodimMultipleGeomTypeMapper(const G &grid, int level)
The constructor.
Definition mcmgmapper.hh:313
LevelMultipleCodimMultipleGeomTypeMapper(const G &grid, int level, const Layout< G::dimension > layout)
The constructor.
Definition mcmgmapper.hh:326