version 0.4
flatprebasis.hh
Go to the documentation of this file.
1// Original File: https://gitlab.mn.tu-dresden.de/amdis/amdis-core/-/blob/master/amdis/functions/FlatPreBasis.hpp
2// SPDX-FileCopyrightText: 2023 Copyright (c) AMDiS
3// SPDX-License-Identifier: MIT
4// Modifications:
5// SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers mueller@ibb.uni-stuttgart.de
6// SPDX-License-Identifier: LGPL-3.0-or-later
7
13#pragma once
14
15#include <cstddef>
16#include <utility>
17
18#include <dune/common/indices.hh>
19#include <dune/functions/functionspacebases/basistags.hh>
20#include <dune/functions/functionspacebases/compositebasis.hh>
21#include <dune/functions/functionspacebases/powerbasis.hh>
22
23namespace Ikarus {
36 template <class PreBasis>
37 struct FlatPreBasis {
38 using type = PreBasis;
39
41 template <class PB>
42 static type create(PB const& preBasis) {
43 return {preBasis.gridView()};
44 }
45
47 static PreBasis const& create(PreBasis const& preBasis) { return preBasis; }
48 };
49
51 template <class PreBasis>
53
55 template <class IMS>
57 using type = IMS;
58 };
59
60 // specialization for BlockedInterleaved
61 template <>
62 struct FlatIndexMergingStrategy<Dune::Functions::BasisFactory::BlockedInterleaved> {
63 using type = Dune::Functions::BasisFactory::FlatInterleaved;
64 };
65
66 // specialization for BlockedLexicographic
67 template <>
68 struct FlatIndexMergingStrategy<Dune::Functions::BasisFactory::BlockedLexicographic> {
69 using type = Dune::Functions::BasisFactory::FlatLexicographic;
70 };
71
72 // specialization for composite bases
73 template <class IMS, class... SPB>
74 struct FlatPreBasis<Dune::Functions::CompositePreBasis<IMS, SPB...>> {
76 using type = Dune::Functions::CompositePreBasis<FIMS, FlatPreBasis_t<SPB>...>;
77
78 template <class PreBasis>
79 static type create(PreBasis const& preBasis) {
80 return create(preBasis, std::index_sequence_for<SPB...>{});
81 }
82
83 template <class PreBasis, std::size_t... I>
84 static type create(PreBasis const& preBasis, std::index_sequence<I...>) {
85 return {FlatPreBasis<SPB>::create(preBasis.subPreBasis(Dune::index_constant<I>{}))...};
86 }
87 };
88
89 // specialization for power bases
90 template <class IMS, class SPB, std::size_t C>
91 struct FlatPreBasis<Dune::Functions::PowerPreBasis<IMS, SPB, C>> {
93 using type = Dune::Functions::PowerPreBasis<FIMS, FlatPreBasis_t<SPB>, C>;
94
95 template <class PreBasis>
96 static type create(PreBasis const& preBasis) {
97 return {FlatPreBasis<SPB>::create(preBasis.subPreBasis())};
98 }
99 };
100
103 template <class PreBasis>
104 decltype(auto) flatPreBasis(PreBasis const& preBasis) {
105 return FlatPreBasis<PreBasis>::create(preBasis);
106 }
107
108} // end namespace Ikarus
decltype(auto) flatPreBasis(PreBasis const &preBasis)
Generator function for a flatted PreBasis.
Definition: flatprebasis.hh:104
Definition: simpleassemblers.hh:21
typename FlatPreBasis< PreBasis >::type FlatPreBasis_t
Type alias for flatted PreBasis.
Definition: flatprebasis.hh:52
Definition: resultevaluators.hh:17
Transform a PreBasis into one with flat index-merging strategyThis utility takes a pre-basis and conv...
Definition: flatprebasis.hh:37
PreBasis type
Definition: flatprebasis.hh:38
static type create(PB const &preBasis)
Try to construct the pre-basis using a gridView.
Definition: flatprebasis.hh:42
static PreBasis const & create(PreBasis const &preBasis)
Do not transform the preBasis if already flat.
Definition: flatprebasis.hh:47
Define the flat index-merging strategy for a given strategy IMS
Definition: flatprebasis.hh:56
IMS type
Definition: flatprebasis.hh:57
Dune::Functions::BasisFactory::FlatInterleaved type
Definition: flatprebasis.hh:63
Dune::Functions::BasisFactory::FlatLexicographic type
Definition: flatprebasis.hh:69
typename FlatIndexMergingStrategy< IMS >::type FIMS
Definition: flatprebasis.hh:75
static type create(PreBasis const &preBasis)
Definition: flatprebasis.hh:79
Dune::Functions::CompositePreBasis< FIMS, FlatPreBasis_t< SPB >... > type
Definition: flatprebasis.hh:76
static type create(PreBasis const &preBasis, std::index_sequence< I... >)
Definition: flatprebasis.hh:84
static type create(PreBasis const &preBasis)
Definition: flatprebasis.hh:96
Dune::Functions::PowerPreBasis< FIMS, FlatPreBasis_t< SPB >, C > type
Definition: flatprebasis.hh:93
typename FlatIndexMergingStrategy< IMS >::type FIMS
Definition: flatprebasis.hh:92