Dune-Functions 2.11
Loading...
Searching...
No Matches
defaultlocalview.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_DEFAULTLOCALVIEW_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTLOCALVIEW_HH
9
10
11#include <tuple>
12#include <optional>
13
14#include <dune/common/concept.hh>
15#include <dune/common/hybridutilities.hh>
16#include <dune/common/reservedvector.hh>
17
21
22
23
24namespace Dune {
25namespace Functions {
26
27
28
30template<class GB>
32{
33public:
34
36 using GlobalBasis = GB;
37
40
42 using Element = typename GridView::template Codim<0>::Entity;
43
45 using size_type = std::size_t;
46
48 using Tree = typename GlobalBasis::PreBasis::Node;
49
50protected:
51
53
54 // Type used to store the multi indices of the basis vectors.
55 // In contrast to MultiIndex this always has dynamic size.
56 // It's guaranteed, that you can always cast it to MultiIndex
58 std::conditional_t<(PreBasis::minMultiIndexSize == PreBasis::maxMultiIndexSize),
60 Dune::ReservedVector<size_type, PreBasis::multiIndexBufferSize>>;
61
62public:
63
65 using MultiIndex =
66 std::conditional_t<(PreBasis::minMultiIndexSize == PreBasis::maxMultiIndexSize),
68 Dune::ReservedVector<size_type, PreBasis::multiIndexBufferSize>>;
69
70
74 tree_(globalBasis_->preBasis().makeNode())
75 {
76 static_assert(models<Concept::BasisTree<GridView>, Tree>(), "Tree type passed to DefaultLocalView does not model the BasisNode concept.");
78 }
79
83 tree_(globalBasis_->preBasis().makeNode())
84 {
86 if (other.bound())
87 bind(other.element());
88 }
89
95 void bind(const Element& e)
96 {
97 element_ = e;
99 indices_.resize(size());
100 globalBasis_->preBasis().indices(tree_, indices_.begin());
101 }
102
105 bool bound() const
106 {
107 return static_cast<bool>(element_);
108 }
109
114 const Element& element() const
115 {
116 return *element_;
117 }
118
123 void unbind()
124 {
125 element_.reset();
126 }
127
132 const Tree& tree() const
133 {
134 return tree_;
135 }
136
140 {
141 return tree_.size();
142 }
143
151 {
152 return globalBasis_->preBasis().maxNodeSize();
153 }
154
156 const MultiIndex& index(size_type i) const
157 {
158 return indices_[i];
159 }
160
164 {
165 return *globalBasis_;
166 }
167
169 {
170 return *this;
171 }
172
173protected:
175 std::optional<Element> element_;
177 std::vector<MultiIndexStorage> indices_;
178};
179
180
181
182} // end namespace Functions
183} // end namespace Dune
184
185
186
187#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTLOCALVIEW_HH
Definition monomialset.hh:19
Definition monomialset.hh:19
void bindTree(Tree &tree, const Entity &entity, std::size_t offset=0)
Definition nodes.hh:469
void initializeTree(Tree &tree, std::size_t treeIndexOffset=0)
Definition nodes.hh:476
A statically sized MultiIndex type.
Definition multiindex.hh:30
A dynamically sized array-like class with overflow.
Definition overflowarray.hh:49
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition defaultglobalbasis.hh:64
PB PreBasis
Pre-basis providing the implementation details.
Definition defaultglobalbasis.hh:58
typename GlobalBasis::PreBasis PreBasis
Definition defaultlocalview.hh:52
void unbind()
Unbind from the current element.
Definition defaultlocalview.hh:123
bool bound() const
Return if the view is bound to a grid element.
Definition defaultlocalview.hh:105
typename GlobalBasis::GridView GridView
Definition defaultlocalview.hh:39
const MultiIndex & index(size_type i) const
Maps from subtree index set [0..size-1] to a globally unique multi index in global basis.
Definition defaultlocalview.hh:156
DefaultLocalView(const DefaultLocalView &other)
Deep copy of the local view.
Definition defaultlocalview.hh:81
std::optional< Element > element_
Definition defaultlocalview.hh:175
typename GridView::template Codim< 0 >::Entity Element
Definition defaultlocalview.hh:42
const Tree & tree() const
Return the local ansatz tree associated to the bound entity.
Definition defaultlocalview.hh:132
std::conditional_t<(PreBasis::minMultiIndexSize==PreBasis::maxMultiIndexSize), StaticMultiIndex< size_type, PreBasis::maxMultiIndexSize >, Dune::ReservedVector< size_type, PreBasis::multiIndexBufferSize > > MultiIndex
Definition defaultlocalview.hh:65
void bind(const Element &e)
Bind the view to a grid element.
Definition defaultlocalview.hh:95
const Element & element() const
Return the grid element that the view is bound to.
Definition defaultlocalview.hh:114
size_type size() const
Total number of degrees of freedom on this element.
Definition defaultlocalview.hh:139
DefaultGlobalBasis< PreBasis > GlobalBasis
Definition defaultlocalview.hh:36
size_type maxSize() const
Maximum local size for any element on the GridView.
Definition defaultlocalview.hh:150
std::size_t size_type
Definition defaultlocalview.hh:45
const DefaultLocalView & rootLocalView() const
Definition defaultlocalview.hh:168
std::conditional_t<(PreBasis::minMultiIndexSize==PreBasis::maxMultiIndexSize), OverflowArray< StaticMultiIndex< size_type, PreBasis::maxMultiIndexSize >, PreBasis::multiIndexBufferSize >, Dune::ReservedVector< size_type, PreBasis::multiIndexBufferSize > > MultiIndexStorage
Definition defaultlocalview.hh:57
std::vector< MultiIndexStorage > indices_
Definition defaultlocalview.hh:177
typename GlobalBasis::PreBasis::Node Tree
Definition defaultlocalview.hh:48
DefaultLocalView(const GlobalBasis &globalBasis)
Construct local view for a given global finite element basis.
Definition defaultlocalview.hh:72
const GlobalBasis * globalBasis_
Definition defaultlocalview.hh:174
const GlobalBasis & globalBasis() const
Definition defaultlocalview.hh:163