13#ifndef DUMUX_DISCRETIZATION_FE_DOF_HELPER_HH
14#define DUMUX_DISCRETIZATION_FE_DOF_HELPER_HH
18#include <dune/geometry/type.hh>
19#include <dune/geometry/referenceelements.hh>
32template <
class Gr
idView>
35 using Scalar =
typename GridView::ctype;
36 using GlobalPosition =
typename Dune::FieldVector<Scalar, GridView::dimensionworld>;
40 using Element =
typename GridView::template Codim<0>::Entity;
42 static constexpr auto dim = GridView::dimension;
47 template<
class LocalKey>
50 const auto& refElement = Dune::referenceElement<Scalar, dim>(type);
51 const auto numEntitiesIntersection = refElement.size(iIdx, 1, localKey.codim());
52 for (std::size_t idx = 0; idx < numEntitiesIntersection; idx++)
53 if (localKey.subEntity() == refElement.subEntity(iIdx, 1, idx, localKey.codim()))
62 template<
class ElemDisc>
65 return Dune::transformedRangeView(
66 Dune::range(elemDisc.numLocalDofs()),
68 return CVFE::LocalDof{
69 static_cast<LocalIndexType>(i),
70 static_cast<GridIndexType>(dofIndex(
71 elemDisc.gridDiscretization().dofMapper(),
73 elemDisc.feLocalCoefficients().localKey(i))),
74 static_cast<GridIndexType>(elemDisc.elementIndex())
86 template<
class ElemDisc,
class BoundaryFace>
89 const auto& gridDisc = [&]() ->
const auto& {
90 if constexpr (
requires { elemDisc.gridDiscretization(); })
91 return elemDisc.gridDiscretization();
93 return elemDisc.gridGeometry();
99 return std::views::iota(std::size_t(0), elemDisc.numLocalDofs())
100 | std::views::filter([&](std::size_t i) {
102 elemDisc.element().type(),
104 elemDisc.feLocalCoefficients().localKey(i));
106 | std::views::transform([&](std::size_t i) {
108 static_cast<LocalIndexType
>(i),
109 static_cast<GridIndexType
>(
dofIndex(
110 gridDisc.dofMapper(),
112 elemDisc.feLocalCoefficients().localKey(i))),
113 static_cast<GridIndexType
>(elemDisc.elementIndex())
119 template<
class DofMapper,
class LocalKey>
120 static auto dofIndex(
const DofMapper& dofMapper,
const Element& element,
const LocalKey& localKey)
122 return dofMapper.subIndex(element, localKey.subEntity(), localKey.codim()) + localKey.index();
126 template<
class Geometry,
class LocalKey>
127 static GlobalPosition
dofPosition(
const Geometry& geo,
const LocalKey& localKey)
129 if (localKey.codim() == dim)
130 return geo.corner(localKey.subEntity());
131 else if (localKey.codim() == 0)
138 template<
class LocalKey>
139 static typename Element::Geometry::LocalCoordinate
localDofPosition(Dune::GeometryType type,
const LocalKey& localKey)
141 return Dune::referenceElement<Scalar, dim>(type).position(localKey.subEntity(), localKey.codim());
A local degree of freedom from an element perspective.
Definition localdof.hh:27
Class for a boundary face related to primary grid elements (dune intersections).
Definition boundaryface.hh:69
LocalIndexType intersectionIndex() const
The index of the intersection this face corresponds to (intersection.indexInInside()).
Definition boundaryface.hh:122
Default Dof helper for finite-element discretizations providing dof-related utility functions....
Definition fedofhelper.hh:34
static auto localDofs(const ElemDisc &elemDisc)
Iterator range over all local dofs on an element.
Definition fedofhelper.hh:63
static auto dofIndex(const DofMapper &dofMapper, const Element &element, const LocalKey &localKey)
global index of dof
Definition fedofhelper.hh:120
static GlobalPosition dofPosition(const Geometry &geo, const LocalKey &localKey)
global dof position
Definition fedofhelper.hh:127
static auto localDofOnIntersection(Dune::GeometryType type, unsigned int iIdx, const LocalKey &localKey)
Returns true if the local dof with a given local key is on the intersection with index iIdx.
Definition fedofhelper.hh:48
static Element::Geometry::LocalCoordinate localDofPosition(Dune::GeometryType type, const LocalKey &localKey)
local dof position
Definition fedofhelper.hh:139
static auto localDofsOnBoundaryFace(const ElemDisc &elemDisc, const BoundaryFace &boundaryFace)
Iterator range over all local dofs on a given boundary face. Uses a filter over all local dofs via lo...
Definition fedofhelper.hh:87
Class representing dofs on elements for control-volume finite element schemes.
Definition assembly/assembler.hh:44
typename GridView::IndexSet::IndexType GridIndex
Definition indextraits.hh:27
unsigned int LocalIndex
Definition indextraits.hh:28