1#ifndef DUNE_MULTIDOMAINGRID_MULTDIDOMAINMCMGMAPPER_HH
2#define DUNE_MULTIDOMAINGRID_MULTDIDOMAINMCMGMAPPER_HH
8#include <dune/grid/common/mcmgmapper.hh>
9#include <dune/geometry/referenceelements.hh>
23 template<
typename GV,
bool max_subomain_index_is_static>
24 struct MCMGMapperStorageProvider
29 typedef typename GV::IndexSet::IndexType IndexType;
31 void update(
const GV& gv) {}
33 std::array<std::vector<IndexType>,GV::Grid::maxSubDomainIndex()>
_offsets;
38 struct MCMGMapperStorageProvider<GV,false>
43 typedef typename GV::IndexSet::IndexType IndexType;
45 void update(
const GV& gv) {
46 _offsets.resize(gv.grid().maxSubDomainIndex());
49 std::vector<std::vector<IndexType> >
_offsets;
86 public MCMGMapperStorageProvider<GV,GV::Grid::maxSubDomainIndexIsStatic()>
90 typedef MultipleCodimMultipleGeomTypeMapper<GV> Base;
92 typedef MCMGMapperStorageProvider<GV,GV::Grid::maxSubDomainIndexIsStatic()> StorageProvider;
94 using StorageProvider::_offsets;
119 using Base::gridView;
126 template<
class EntityType>
129 return gridView().indexSet().index(subDomain,e) +
_offsets[subDomain][GlobalGeometryTypeIndex::index(e.type())];
139 int map (
SubDomainIndex subDomain,
const typename GV::template Codim<0>::Entity& e,
int i,
unsigned int codim)
const
142 ReferenceElements<double, GV::dimension>::general(e.type()).type(i,
144 return gridView().indexSet().subIndex(subDomain, e, i, codim) +
145 _offsets[subDomain][GlobalGeometryTypeIndex::index(gt)];
167 template<
class EntityType>
170 if (!gridView().indexSet().
contains(subDomain, e) ||
171 !Base::layout()(e.type(), GV::dimension)) {
175 result =
map(subDomain,e);
189 GeometryType gt = ReferenceElements<double,GV::dimension>::general(e.type()).type(i,cc);
191 if (!gridView().indexSet().
contains(subDomain, e) ||
192 !Base::layout()(gt, GV::dimension)) {
196 result = gridView().indexSet().subIndex(subDomain, e, i, cc) +
197 _offsets[subDomain][GlobalGeometryTypeIndex::index(gt)];
203 [[deprecated(
"Use update(gridView) instead! Will be removed after release 2.8.")]]
216 static_cast<Base*
>(
this)->
update(gv);
217 StorageProvider::update(gv);
219 subDomain < gridView().grid().maxSubDomainIndex(); ++subDomain) {
220 std::vector<IndexType>& offsets =
_offsets[subDomain];
221 offsets.resize(GlobalGeometryTypeIndex::size(GV::dimension) + 1);
222 std::fill(offsets.begin(),offsets.end(),0);
226 for (
int cc = 0; cc <= GV::dimension; ++cc)
228 for (
auto gt : gridView().indexSet().types(subDomain,cc))
229 offsets[GlobalGeometryTypeIndex::index(gt) + 1] =
230 gridView().indexSet().size(subDomain, gt);
233 std::partial_sum(offsets.begin(),offsets.end(),offsets.begin());
std::array< std::vector< IndexType >, GV::Grid::maxSubDomainIndex()> _offsets
Definition: multidomainmcmgmapper.hh:33
Definition: multidomaingrid.hh:8
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: multidomainmcmgmapper.hh:88
int size(SubDomainIndex subDomain) const
Return total number of entities in the entity set managed by the mapper.
Definition: multidomainmcmgmapper.hh:156
GV::Grid::SubDomainIndex SubDomainIndex
Definition: multidomainmcmgmapper.hh:99
void update(const GV &gv)
Recalculates indices after grid adaptation.
Definition: multidomainmcmgmapper.hh:214
bool contains(SubDomainIndex subDomain, const EntityType &e, IndexType &result) const
Returns true if the entity is contained in the index set.
Definition: multidomainmcmgmapper.hh:168
int map(SubDomainIndex subDomain, const typename GV::template Codim< 0 >::Entity &e, int i, unsigned int codim) const
Map subentity of codim 0 entity to array index.
Definition: multidomainmcmgmapper.hh:139
GV::IndexSet::IndexType IndexType
Definition: multidomainmcmgmapper.hh:98
int map(SubDomainIndex subDomain, const EntityType &e) const
Map entity to array index.
Definition: multidomainmcmgmapper.hh:127
MultiDomainMCMGMapper(const GV &gv, const MCMGLayout &layout)
Definition: multidomainmcmgmapper.hh:101
bool contains(SubDomainIndex subDomain, const typename GV::template Codim< 0 >::Entity &e, int i, IndexType &result) const
Returns true if the entity is contained in the index set.
Definition: multidomainmcmgmapper.hh:187
MultiDomainMCMGMapper(const GV &gv)
Construct mapper from grid and one of its index sets.
Definition: multidomainmcmgmapper.hh:113
void update()
Recalculates indices after grid adaptation.
Definition: multidomainmcmgmapper.hh:204