Dune-Functions 2.11
Loading...
Searching...
No Matches
restrictedbasis.hh
Go to the documentation of this file.
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_RESTRICTEDBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RESTRICTEDBASIS_HH
9
10#include <cstddef>
11#include <utility>
12
13#include <dune/common/typetree/traversal.hh>
14
16
17
19
20
21
42template<class GV, class SDPB, class SD>
44{
46
47public:
48
49 using SubDomain = SD;
50 using SubDomainPreBasis = SDPB;
51 using SubDomainGridView = typename SubDomainPreBasis::GridView;
52
54 using GridView = GV;
55
57 using size_type = std::size_t;
58
60 class Node
61 : public SubDomainPreBasis::Node
62 {
63 using Base = typename SubDomainPreBasis::Node;
64 public:
65
66 using Element = typename Base::Element;
67
68 Node(Base&& base, const SubDomainGridView& subDomainGridView, const SubDomain& subDomain)
69 : Base(base)
70 , subDomainGridView_(subDomainGridView)
71 , subDomain_(subDomain)
72 {}
73
74 void bind(const Element& element)
75 {
76 if (subDomainGridView_.contains(element))
77 Base::bind(element);
78 else
79 {
80 Dune::TypeTree::forEachNode(static_cast<Base&>(*this) , [&](auto& node, const auto& treePath) {
81 Dune::Functions::Impl::BasisNodeSetupHelper::setOffset(node, this->offset());
82 Dune::Functions::Impl::BasisNodeSetupHelper::setSize(node, 0);
83 });
84 }
85 }
86
87 const SubDomain& subDomain() const
88 {
89 return subDomain_;
90 }
91
92 private:
93 const SubDomainGridView& subDomainGridView_;
94 const SubDomain& subDomain_;
95 };
96
97 static constexpr size_type maxMultiIndexSize = SubDomainPreBasis::maxMultiIndexSize;
98 static constexpr size_type minMultiIndexSize = SubDomainPreBasis::minMultiIndexSize;
99 static constexpr size_type multiIndexBufferSize = SubDomainPreBasis::multiIndexBufferSize;
100
112
115 {
116 subDomainPreBasis_.initializeIndices();
117 }
118
120 const GridView& gridView() const
121 {
122 return gridView_;
123 }
124
133 void update(const GridView& gv)
134 {
135 gridView_ = gv;
136 subDomainPreBasis_.update(subDomainPtr_->gridView());
137 }
138
143 {
144 return Node(subDomainPreBasis_.makeNode(), subDomainPreBasis_.gridView(), *subDomainPtr_);
145 }
146
149 {
150 return subDomainPreBasis_.size();
151 }
152
154 template<class SizePrefix>
155 size_type size(const SizePrefix& prefix) const
156 {
157 return subDomainPreBasis_.size(prefix);
158 }
159
162 {
163 return subDomainPreBasis_.containerDescriptor();
164 }
165
168 {
169 return subDomainPreBasis_.dimension();
170 }
171
174 {
175 return subDomainPreBasis_.maxNodeSize();
176 }
177
179 {
180 return subDomainPreBasis_;
181 }
182
187
188 template<typename It>
189 It indices(const Node& node, It it) const
190 {
191 if (node.size() == 0)
192 return it;
193 else
194 return subDomainPreBasis_.indices(node, it);
195 }
196
197protected:
201};
202
203
204
205namespace BasisFactory {
206
224template<class SubDomainBasisFactory, class SubDomain>
225auto restrict(SubDomainBasisFactory&& subPreBasisFactory, const SubDomain& subDomain)
226{
227 return [
228 subPreBasisFactory=std::forward<SubDomainBasisFactory>(subPreBasisFactory),
229 &subDomain
230 ](const auto& gridView) {
231 return Dune::Functions::Experimental::RestrictedPreBasis(gridView, subPreBasisFactory(subDomain.gridView()), subDomain);
232 };
233}
234
235
236} // end namespace BasisFactory
237} // end namespace Dune::Functions::Experimental
238
239
240#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RESTRICTEDBASIS_HH
auto restrict(SubDomainBasisFactory &&subPreBasisFactory, const SubDomain &subDomain)
Create a RestrictedPreBasisFactory.
Definition restrictedbasis.hh:225
Definition subdomain.hh:28
Definition restrictedbasis.hh:205
Class representing a sub-domain of a GridView.
Definition subdomain.hh:534
GridView gridView() const
Create grid view representing the SubDomain.
Definition subdomain.hh:565
A pre-basis restricted to a sub-domain.
Definition restrictedbasis.hh:44
std::size_t size_type
Type used for indices and size information.
Definition restrictedbasis.hh:57
RestrictedPreBasis(const GridView &gridView, SubDomainPreBasis &&subDomainPreBasis, const SubDomain &subDomain)
Constructor for given sub-domain pre-basis.
Definition restrictedbasis.hh:107
void initializeIndices()
Initialize the global indices.
Definition restrictedbasis.hh:114
const SubDomainPreBasis & subDomainPreBasis() const
Definition restrictedbasis.hh:178
SDPB SubDomainPreBasis
Definition restrictedbasis.hh:50
static constexpr size_type minMultiIndexSize
Definition restrictedbasis.hh:98
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition restrictedbasis.hh:167
SubDomainPreBasis subDomainPreBasis_
Definition restrictedbasis.hh:199
SubDomainPreBasis & subDomainPreBasis()
Definition restrictedbasis.hh:183
GV GridView
The grid view that the FE basis is defined on.
Definition restrictedbasis.hh:54
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition restrictedbasis.hh:173
SD SubDomain
Definition restrictedbasis.hh:49
size_type size() const
Same as size(prefix) with empty prefix.
Definition restrictedbasis.hh:148
const SubDomain * subDomainPtr_
Definition restrictedbasis.hh:200
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition restrictedbasis.hh:155
typename SubDomainPreBasis::GridView SubDomainGridView
Definition restrictedbasis.hh:51
static constexpr size_type multiIndexBufferSize
Definition restrictedbasis.hh:99
GridView gridView_
Definition restrictedbasis.hh:198
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition restrictedbasis.hh:120
It indices(const Node &node, It it) const
Definition restrictedbasis.hh:189
auto containerDescriptor() const
Return the container descriptor of the pre-basis.
Definition restrictedbasis.hh:161
Node makeNode() const
Create tree node.
Definition restrictedbasis.hh:142
static constexpr size_type maxMultiIndexSize
Definition restrictedbasis.hh:97
void update(const GridView &gv)
Update the stored grid view, to be called.
Definition restrictedbasis.hh:133
Template mapping root tree path to type of created tree node.
Definition restrictedbasis.hh:62
typename Base::Element Element
Definition restrictedbasis.hh:66
void bind(const Element &element)
Definition restrictedbasis.hh:74
const SubDomain & subDomain() const
Definition restrictedbasis.hh:87
Node(Base &&base, const SubDomainGridView &subDomainGridView, const SubDomain &subDomain)
Definition restrictedbasis.hh:68