version 0.4
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
28 template <typename PreBasis_>
29 class Basis {
30 public:
31 using PreBasis = PreBasis_;
32 using GridView = typename PreBasis::GridView;
34 = decltype(Dune::Functions::DefaultGlobalBasis(std::declval<PreBasis>()));
35 using FlatBasis = decltype(Dune::Functions::DefaultGlobalBasis(
36 Ikarus::flatPreBasis(std::declval<PreBasis>())));
37
45 explicit Basis(const PreBasis& pb)
46 : bb{Dune::Functions::DefaultGlobalBasis(pb)},
47 fb{Dune::Functions::DefaultGlobalBasis(Ikarus::flatPreBasis(pb))} {}
48
54 auto& flat() { return fb; }
55
61 auto& untouched() { return bb; }
62
68 const auto& flat() const { return fb; }
69
75 const auto& untouched() const { return bb; }
76
82 const auto& gridView() const { return bb.gridView(); }
83
89 auto& gridView() { return bb.gridView(); }
90
91 private:
93 FlatBasis fb;
94 };
95
107 template <typename GridView, typename PreBasisFactory>
108 auto makeBasis(const GridView& gv, const PreBasisFactory& pb) {
109 auto preBasis = pb(gv);
110 return Basis(preBasis);
111 }
112
121 template <typename PreBasis>
122 auto makeBasis(const Dune::Functions::DefaultGlobalBasis<PreBasis>& gb) {
123 return Basis(gb.preBasis());
124 }
125} // namespace Ikarus
Implementation of creating a flat basis from a possibly blocked basis.
decltype(auto) flatPreBasis(PreBasis const &preBasis)
Generator function for a flatted PreBasis.
Definition: flatprebasis.hh:104
Definition: simpleassemblers.hh:21
auto makeBasis(const GridView &gv, const PreBasisFactory &pb)
Factory function to create a Basis object.
Definition: utils/basis.hh:108
Definition: resultevaluators.hh:17
Wrapper class for a hierarchical basis constructed from a pre-basis.
Definition: utils/basis.hh:29
typename PreBasis::GridView GridView
The type of the grid view.
Definition: utils/basis.hh:32
auto & untouched()
Returns a reference to the untouched version of the basis.
Definition: utils/basis.hh:61
PreBasis_ PreBasis
The type of the untouched pre basis.
Definition: utils/basis.hh:31
const auto & gridView() const
Returns a const reference to the grid view associated with the untouched basis.
Definition: utils/basis.hh:82
const auto & untouched() const
Returns a const reference to the untouched version of the basis.
Definition: utils/basis.hh:75
auto & gridView()
Returns a reference to the grid view associated with the untouched basis.
Definition: utils/basis.hh:89
const auto & flat() const
Returns a const reference to the flat version of the basis.
Definition: utils/basis.hh:68
decltype(Dune::Functions::DefaultGlobalBasis(Ikarus::flatPreBasis(std::declval< PreBasis >()))) FlatBasis
The type of the flattened basis.
Definition: utils/basis.hh:36
Basis(const PreBasis &pb)
Constructs a Basis object from a pre-basis.
Definition: utils/basis.hh:45
decltype(Dune::Functions::DefaultGlobalBasis(std::declval< PreBasis >())) UntouchedBasis
The type of the untouched basis.
Definition: utils/basis.hh:34
auto & flat()
Returns a reference to the flat version of the basis.
Definition: utils/basis.hh:54