5#ifndef __DUNE_ACFEM_SUBENTITYMAPPER_HH__
6#define __DUNE_ACFEM_SUBENTITYMAPPER_HH__
8#include <dune/geometry/referenceelements.hh>
9#include <dune/grid/common/intersection.hh>
11#include <unordered_map>
29 template<
class DofMapper,
int coDimension>
30 struct MapEntityHierarchyHelper
32 typedef DofMapper DofMapperType;
33 typedef typename DofMapperType::GridPartType GridPartType;
34 typedef typename GridPartType::ctype FieldType;
35 typedef typename DofMapperType::ElementType ElementType;
36 typedef typename DofMapperType::GlobalKeyType GlobalKeyType;
37 typedef ReferenceElements<FieldType, ElementType::dimension> ReferenceElementsType;
38 typedef ReferenceElement<FieldType, ElementType::dimension> ReferenceElementType;
42 struct SubSubEntityFunctor
45 subCoDimension = codim,
46 gridDimension = GridPartType::dimension,
47 subSubEntityDimension = gridDimension-subCoDimension
49 template<
class RefElem,
class Functor>
50 static void apply(
const DofMapperType& mapper,
const ElementType& element,
const RefElem& refElem,
int subIndex, Functor f,
51 const std::unordered_map<GlobalKeyType, unsigned>& globalToLocal)
53 const int numSubSubEntities = refElem.size(subIndex, coDimension, subCoDimension);
55 for (
int i = 0; i < numSubSubEntities; ++i) {
56 const unsigned subSubEntityIndex = refElem.subEntity(subIndex, coDimension, i, subCoDimension);
57 const auto subSubEntity = element.template subEntity<subCoDimension>(subSubEntityIndex);
59 mapper.mapEachEntityDof(subSubEntity, [f, globalToLocal] (
unsigned localIndex,
const GlobalKeyType& globalIndex) {
60 f(globalToLocal.at(globalIndex), globalIndex);
90 template<
class DofMapper,
int coDimension,
class Functor>
92 const typename DofMapper::ElementType& element,
94 const std::integral_constant<int, coDimension>& dummy,
97 typedef DofMapper DofMapperType;
98 typedef MapEntityHierarchyHelper<DofMapperType, coDimension> HelperType;
99 typedef typename HelperType::GridPartType GridPartType;
100 typedef typename HelperType::FieldType FieldType;
101 typedef typename HelperType::ElementType ElementType;
102 typedef typename HelperType::GlobalKeyType GlobalKeyType;
103 typedef typename HelperType::ReferenceElementType ReferenceElementType;
104 typedef typename HelperType::ReferenceElementsType ReferenceElementsType;
106 enum { dimension = GridPartType::dimension };
109 std::unordered_map<GlobalKeyType, unsigned> globalToLocal;
110 mapper.mapEach(element, [&globalToLocal] (
unsigned local,
const GlobalKeyType& global) {
111 globalToLocal[global] = local;
115 const auto& refElem = ReferenceElementsType::general(element.type());
119#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 5)
120 Hybrid::forEach(Std::make_index_sequence<dimension-coDimension+1>{},
122 HelperType::template SubSubEntityFunctor<i+coDimension>::apply(mapper, element, refElem, subIndex, f, globalToLocal);
125 ForLoop<HelperType::template SubSubEntityFunctor, coDimension, dimension>::apply(mapper, element, refElem, subIndex, f, globalToLocal);
148 template<
class DofMapper,
class Intersection,
class Functor>
150 const Intersection& intersection,
154 std::integral_constant<int, 1>(), f);
178 template<
class DofMapper,
class Intersection,
class LocalIndices,
class GlobalIndices>
179 unsigned mapFaceDofs(
const DofMapper& mapper,
const Intersection& intersection,
180 LocalIndices& localIndices, GlobalIndices& globalIndices)
182 typedef typename DofMapper::GlobalKeyType GlobalKeyType;
186 [&localIndices, &globalIndices, &count] (
unsigned localIndex, GlobalKeyType globalIndex) {
187 localIndices[count] = localIndex;
188 globalIndices[count] = globalIndex;
void mapEachFaceDof(const DofMapper &mapper, const Intersection &intersection, Functor f)
Iterate over the codim-1 sub-entity hierarchy linked to the given intersection and call the dof-mappe...
Definition: subentitymapper.hh:149
void mapEntityHierarchy(const DofMapper &mapper, const typename DofMapper::ElementType &element, int subIndex, const std::integral_constant< int, coDimension > &dummy, Functor f)
Iterate over the entire sub-entity hierarchy below one given sub-entity (including the given one) and...
Definition: subentitymapper.hh:91
unsigned mapFaceDofs(const DofMapper &mapper, const Intersection &intersection, LocalIndices &localIndices, GlobalIndices &globalIndices)
Fetch all global DoFs of the codim-1 entity intersection belongs to.
Definition: subentitymapper.hh:179