version 0.4.1
utils/basis.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers mueller@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
10#pragma once
11
12#include <utility>
13
14#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
15
17
18namespace Ikarus {
19
28template <typename PB>
30{
31public:
32 using PreBasis = PB;
33 using GridView = typename PreBasis::GridView;
35 decltype(Dune::Functions::DefaultGlobalBasis(std::declval<PreBasis>()));
36 using FlatBasis = decltype(Dune::Functions::DefaultGlobalBasis(
37 Ikarus::flatPreBasis(std::declval<PreBasis>())));
38
46 explicit BasisHandler(const PreBasis& pb)
47 : bb_{Dune::Functions::DefaultGlobalBasis(pb)},
48 fb_{Dune::Functions::DefaultGlobalBasis(Ikarus::flatPreBasis(pb))} {}
49
55 auto& flat() { return fb_; }
56
62 auto& untouched() { return bb_; }
63
69 const auto& flat() const { return fb_; }
70
76 const auto& untouched() const { return bb_; }
77
83 const auto& gridView() const { return bb_.gridView(); }
84
90 auto& gridView() { return bb_.gridView(); }
91
92private:
94 FlatBasis fb_;
95};
96
108template <typename GV, typename PBF>
109auto makeBasis(const GV& gv, const PBF& pb) {
110 auto preBasis = pb(gv);
111 return BasisHandler(preBasis);
112}
113
122template <typename PB>
123auto makeBasis(const Dune::Functions::DefaultGlobalBasis<PB>& gb) {
124 return BasisHandler(gb.preBasis());
125}
126} // namespace Ikarus
Implementation of creating a flat basis from a possibly blocked basis.
decltype(auto) flatPreBasis(const PreBasis &preBasis)
Generator function for a flatted PreBasis.
Definition: flatprebasis.hh:110
Definition: assemblermanipulatorbuildingblocks.hh:22
auto makeBasis(const GV &gv, const PBF &pb)
Factory function to create a Basis object.
Definition: utils/basis.hh:109
Definition: utils/dirichletvalues.hh:30
Wrapper class for a hierarchical basis constructed from a pre-basis.
Definition: utils/basis.hh:30
auto & flat()
Returns a reference to the flat version of the basis.
Definition: utils/basis.hh:55
decltype(Dune::Functions::DefaultGlobalBasis(std::declval< PreBasis >())) UntouchedBasis
The type of the untouched basis.
Definition: utils/basis.hh:35
const auto & flat() const
Returns a const reference to the flat version of the basis.
Definition: utils/basis.hh:69
BasisHandler(const PreBasis &pb)
Constructs a Basis object from a pre-basis.
Definition: utils/basis.hh:46
decltype(Dune::Functions::DefaultGlobalBasis(Ikarus::flatPreBasis(std::declval< PreBasis >()))) FlatBasis
The type of the flattened basis.
Definition: utils/basis.hh:37
auto & gridView()
Returns a reference to the grid view associated with the untouched basis.
Definition: utils/basis.hh:90
auto & untouched()
Returns a reference to the untouched version of the basis.
Definition: utils/basis.hh:62
const auto & gridView() const
Returns a const reference to the grid view associated with the untouched basis.
Definition: utils/basis.hh:83
typename PreBasis::GridView GridView
The type of the grid view.
Definition: utils/basis.hh:33
const auto & untouched() const
Returns a const reference to the untouched version of the basis.
Definition: utils/basis.hh:76
PB PreBasis
The type of the untouched pre basis.
Definition: utils/basis.hh:32