7#ifndef DUNE_FUNCTIONS_COMMON_MAPPERUTILITIES_HH
8#define DUNE_FUNCTIONS_COMMON_MAPPERUTILITIES_HH
34 class MapperElementSubIndices
41 using Element =
typename GridView::template Codim<0>::Entity;
43 MapperElementSubIndices(
const Mapper& mapper)
48 void bind(
const Element& element)
50 constexpr auto dimension = GridView::dimension;
52 auto referenceElement = Dune::referenceElement<double, dimension>(element.type());
53 for (
auto codim :
Dune::
range(dimension + 1)) {
57 std::size_t firstIndex = mapper_.subIndex(element, subEntity, codim);
58 for (
auto j :
Dune::
range(firstIndex, firstIndex + c)) {
59 indices_.push_back(j);
68 return indices_.begin();
73 return indices_.end();
78 IndexContainer indices_;
95 template<
class FieldType =
double,
class Mapper>
96 auto computeAverageSubEntityMeshSize(
const Mapper& mapper)
98 constexpr auto dimension = Mapper::GridView::dimension;
101 auto subIndices = Impl::MapperElementSubIndices(mapper);
102 for(
const auto& element :
Dune::
elements(mapper.gridView()))
104 auto A = element.geometry().volume();
105 subIndices.bind(element);
106 for(
auto i : subIndices)
108 subEntityMeshSize[i] += A;
109 ++(adjacentElements[i]);
113 subEntityMeshSize[i] =
std::
pow(subEntityMeshSize[i]/adjacentElements[i], 1./dimension);
114 return subEntityMeshSize;
128 template<
class ElementMapper>
131 constexpr int dim = 2;
132 static_assert(
dim == ElementMapper::GridView::dimension);
134 auto const& gridView = mapper.gridView();
136 orientations.
resize(gridView.size(0));
138 auto const& idSet = gridView.grid().globalIdSet();
140 for (
const auto &element :
elements(gridView))
143 auto elementIndex = mapper.index(element);
151 auto localV0 = refElement.subEntity(i,
dim - 1, 0,
dim);
152 auto localV1 = refElement.subEntity(i,
dim - 1, 1,
dim);
155 auto globalV0 = idSet.subId(element, localV0,
dim);
156 auto globalV1 = idSet.subId(element, localV1,
dim);
159 orientation[i] = globalV0 > globalV1;
unspecified value type referenceElement(T &&... t)
Definition monomialset.hh:19
static constexpr IntegralRange< std::decay_t< T > > range(T &&from, U &&to) noexcept
GridView(const Implementation &imp)
IteratorRange<... > elements(const GV &gv)
GV::IndexSet::IndexType Index