DUNE PDELab (git)

leafprebasismappermixin.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LEAFPREBASISMAPPERMIXIN_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LEAFPREBASISMAPPERMIXIN_HH
5
7
8#include <dune/functions/functionspacebases/leafprebasismixin.hh>
9
10#include <dune/geometry/referenceelements.hh>
11
13
14
15
16namespace Dune::Functions {
17
18
19
20// Helper function returning a random access range
21// of global indices associated to the element. The ordering
22// is derived from the LocalCoefficients object.
23// Having this as a member of MCMGMapper would be nice.
24// But this would introduce the LocalCoefficient in dune-grid.
25// This would introduce at least a weak 'conceptual' dependency problem.
26template<class GridView, class LocalCoefficients>
27auto subIndexRange(const Dune::MultipleCodimMultipleGeomTypeMapper<GridView>& mapper, const typename GridView::template Codim<0>::Entity& element, const LocalCoefficients& localCoefficients)
28{
29 // Here we make use of the 'hidden' (poorly documented) MCMGMapper feature to support
30 // multiple DOFs per subentity. However, we do not take care for any reordering.
31 return Dune::transformedRangeView(Dune::range(localCoefficients.size()), [&](auto localIndex) {
32 auto localKey = localCoefficients.localKey(localIndex);
33 return mapper.subIndex(element, localKey.subEntity(), localKey.codim()) + localKey.index();
34 });
35}
36
37
38
55template<typename GV>
57 : public LeafPreBasisMixin<LeafPreBasisMapperMixin<GV>>
58{
59 static const int gridDim = GV::dimension;
60
61public:
62
64 using GridView = GV;
65
67 using size_type = std::size_t;
68
71 gridView_(gv),
72 mapper_(gridView_, std::move(layout))
73 {}
74
77 {
78 // Determine upper bound for node size by traversing
79 // the layout for all element types in the grid
80 maxNodeSize_ = 0;
81 for(const GeometryType& elementType : gridView_.indexSet().types(0))
82 {
83 auto referenceElement = Dune::referenceElement<double, gridDim>(elementType);
84 for(auto codim : Dune::range(gridDim+1))
85 for(auto i : Dune::range(referenceElement.size(codim)))
86 maxNodeSize_ += mapper_.layout()(referenceElement.type(i, codim), gridDim);
87 }
88 }
89
91 const GridView& gridView() const
92 {
93 return gridView_;
94 }
95
97 void update(const GridView& gv)
98 {
99 gridView_ = gv;
100 mapper_.update(gridView_);
101 }
102
105 {
106 return mapper_.size();
107 }
108
111 {
112 return maxNodeSize_;
113 }
114
116 template<class Node, class It>
117 It indices(const Node& node, It it) const
118 {
119 for(const auto& globalIndex : subIndexRange(mapper_, node.element(), node.finiteElement().localCoefficients()))
120 {
121 *it = {{ (size_type)globalIndex }};
122 ++it;
123 }
124 return it;
125 }
126
127protected:
128 GridView gridView_;
130 std::size_t maxNodeSize_;
131};
132
133
134
135} // end namespace Dune::Functions
136
137#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LEAFPREBASISMAPPERMIXIN_HH
A generic MixIn class for PreBasis with flat indices computed from a mapper.
Definition: leafprebasismappermixin.hh:58
const GridView & gridView() const
Export the stored GridView.
Definition: leafprebasismappermixin.hh:91
size_type dimension() const
Return total number of basis functions.
Definition: leafprebasismappermixin.hh:104
std::size_t size_type
Type used for index digits.
Definition: leafprebasismappermixin.hh:67
void update(const GridView &gv)
Update the stored GridView.
Definition: leafprebasismappermixin.hh:97
LeafPreBasisMapperMixin(const GridView &gv, Dune::MCMGLayout layout)
Construct from GridView and local DOF layout.
Definition: leafprebasismappermixin.hh:70
GV GridView
Type of the associated GridView.
Definition: leafprebasismappermixin.hh:64
size_type maxNodeSize() const
Return maximal number of basis functions per element.
Definition: leafprebasismappermixin.hh:110
void initializeIndices()
Initialize the global index information.
Definition: leafprebasismappermixin.hh:76
It indices(const Node &node, It it) const
Fill cache with global indices of DOFs associated to the given bound node.
Definition: leafprebasismappermixin.hh:117
A generic MixIn class for PreBasis.
Definition: leafprebasismixin.hh:32
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Grid view abstract base class.
Definition: gridview.hh:66
size_type size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mcmgmapper.hh:204
void update(const GV &gridView)
Recalculates indices after grid adaptation.
Definition: mcmgmapper.hh:308
unspecified value type referenceElement(T &&... t)
Returns a reference element for the objects t....
std::function< size_t(GeometryType, int)> MCMGLayout
layout function for MultipleCodimMultipleGeomTypeMapper
Definition: mcmgmapper.hh:64
auto transformedRangeView(R &&range, F &&f)
Create a TransformedRangeView.
Definition: rangeutilities.hh:670
Mapper for multiple codim and multiple geometry types.
STL namespace.
Utilities for reduction like operations on ranges.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)