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
4// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LEAFPREBASISMAPPERMIXIN_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LEAFPREBASISMAPPERMIXIN_HH
9
11
12#include <dune/functions/functionspacebases/leafprebasismixin.hh>
13
14#include <dune/geometry/referenceelements.hh>
15
17
18
19
20namespace Dune::Functions {
21
22
23
24// Helper function returning a random access range
25// of global indices associated to the element. The ordering
26// is derived from the LocalCoefficients object.
27// Having this as a member of MCMGMapper would be nice.
28// But this would introduce the LocalCoefficient in dune-grid.
29// This would introduce at least a weak 'conceptual' dependency problem.
30template<class GridView, class LocalCoefficients>
31auto subIndexRange(const Dune::MultipleCodimMultipleGeomTypeMapper<GridView>& mapper, const typename GridView::template Codim<0>::Entity& element, const LocalCoefficients& localCoefficients)
32{
33 // Here we make use of the 'hidden' (poorly documented) MCMGMapper feature to support
34 // multiple DOFs per subentity. However, we do not take care for any reordering.
35 return Dune::transformedRangeView(Dune::range(localCoefficients.size()), [&](auto localIndex) {
36 auto localKey = localCoefficients.localKey(localIndex);
37 return mapper.subIndex(element, localKey.subEntity(), localKey.codim()) + localKey.index();
38 });
39}
40
41
42
59template<typename GV>
61 : public LeafPreBasisMixin<LeafPreBasisMapperMixin<GV>>
62{
63 static const int gridDim = GV::dimension;
64
65public:
66
68 using GridView = GV;
69
71 using size_type = std::size_t;
72
75 gridView_(gv),
76 mapper_(gridView_, std::move(layout))
77 {}
78
81 {
82 // Determine upper bound for node size by traversing
83 // the layout for all element types in the grid
84 maxNodeSize_ = 0;
85 for(const GeometryType& elementType : gridView_.indexSet().types(0))
86 {
87 auto referenceElement = Dune::referenceElement<double, gridDim>(elementType);
88 for(auto codim : Dune::range(gridDim+1))
89 for(auto i : Dune::range(referenceElement.size(codim)))
90 maxNodeSize_ += mapper_.layout()(referenceElement.type(i, codim), gridDim);
91 }
92 }
93
95 const GridView& gridView() const
96 {
97 return gridView_;
98 }
99
101 void update(const GridView& gv)
102 {
103 gridView_ = gv;
104 mapper_.update(gridView_);
105 }
106
109 {
110 return mapper_.size();
111 }
112
115 {
116 return maxNodeSize_;
117 }
118
120 template<class Node, class It>
121 It indices(const Node& node, It it) const
122 {
123 for(const auto& globalIndex : subIndexRange(mapper_, node.element(), node.finiteElement().localCoefficients()))
124 {
125 *it = {{ (size_type)globalIndex }};
126 ++it;
127 }
128 return it;
129 }
130
131protected:
132 GridView gridView_;
134 std::size_t maxNodeSize_;
135};
136
137
138
139} // end namespace Dune::Functions
140
141#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LEAFPREBASISMAPPERMIXIN_HH
A generic MixIn class for PreBasis with flat indices computed from a mapper.
Definition: leafprebasismappermixin.hh:62
const GridView & gridView() const
Export the stored GridView.
Definition: leafprebasismappermixin.hh:95
size_type dimension() const
Return total number of basis functions.
Definition: leafprebasismappermixin.hh:108
std::size_t size_type
Type used for index digits.
Definition: leafprebasismappermixin.hh:71
void update(const GridView &gv)
Update the stored GridView.
Definition: leafprebasismappermixin.hh:101
LeafPreBasisMapperMixin(const GridView &gv, Dune::MCMGLayout layout)
Construct from GridView and local DOF layout.
Definition: leafprebasismappermixin.hh:74
GV GridView
Type of the associated GridView.
Definition: leafprebasismappermixin.hh:68
size_type maxNodeSize() const
Return maximal number of basis functions per element.
Definition: leafprebasismappermixin.hh:114
void initializeIndices()
Initialize the global index information.
Definition: leafprebasismappermixin.hh:80
It indices(const Node &node, It it) const
Fill cache with global indices of DOFs associated to the given bound node.
Definition: leafprebasismappermixin.hh:121
A generic MixIn class for PreBasis.
Definition: leafprebasismixin.hh:36
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 (Nov 24, 23:30, 2024)