version 0.4.1
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 {
36template <class PreBasis>
38{
39 using type = PreBasis;
40
42 template <class PB>
43 static type create(PB const& preBasis) {
44 return type(preBasis.gridView());
45 }
46
48 static const PreBasis& create(const PreBasis& preBasis) { return preBasis; }
49};
50
52template <class PreBasis>
54
56template <class IMS>
58{
59 using type = IMS;
60};
61
62// specialization for BlockedInterleaved
63template <>
64struct FlatIndexMergingStrategy<Dune::Functions::BasisFactory::BlockedInterleaved>
65{
66 using type = Dune::Functions::BasisFactory::FlatInterleaved;
67};
68
69// specialization for BlockedLexicographic
70template <>
71struct FlatIndexMergingStrategy<Dune::Functions::BasisFactory::BlockedLexicographic>
72{
73 using type = Dune::Functions::BasisFactory::FlatLexicographic;
74};
75
76// specialization for composite bases
77template <class IMS, class... SPB>
78struct FlatPreBasis<Dune::Functions::CompositePreBasis<IMS, SPB...>>
79{
81 using type = Dune::Functions::CompositePreBasis<FIMS, FlatPreBasis_t<SPB>...>;
82
83 template <class PreBasis>
84 static type create(const PreBasis& preBasis) {
85 return create(preBasis, std::index_sequence_for<SPB...>{});
86 }
87
88 template <class PreBasis, std::size_t... I>
89 static type create(const PreBasis& preBasis, std::index_sequence<I...>) {
90 return type(FlatPreBasis<SPB>::create(preBasis.subPreBasis(Dune::index_constant<I>{}))...);
91 }
92};
93
94// specialization for power bases
95template <class IMS, class SPB, std::size_t C>
96struct FlatPreBasis<Dune::Functions::PowerPreBasis<IMS, SPB, C>>
97{
99 using type = Dune::Functions::PowerPreBasis<FIMS, FlatPreBasis_t<SPB>, C>;
100
101 template <class PreBasis>
102 static type create(const PreBasis& preBasis) {
103 return type(FlatPreBasis<SPB>::create(preBasis.subPreBasis()));
104 }
105};
106
109template <class PreBasis>
110decltype(auto) flatPreBasis(const PreBasis& preBasis) {
111 return FlatPreBasis<PreBasis>::create(preBasis);
112}
113
114} // end namespace Ikarus
decltype(auto) flatPreBasis(const PreBasis &preBasis)
Generator function for a flatted PreBasis.
Definition: flatprebasis.hh:110
Definition: simpleassemblers.hh:22
typename FlatPreBasis< PreBasis >::type FlatPreBasis_t
Type alias for flatted PreBasis.
Definition: flatprebasis.hh:53
Definition: utils/dirichletvalues.hh:28
Transform a PreBasis into one with flat index-merging strategyThis utility takes a pre-basis and conv...
Definition: flatprebasis.hh:38
PreBasis type
Definition: flatprebasis.hh:39
static type create(PB const &preBasis)
Try to construct the pre-basis using a gridView.
Definition: flatprebasis.hh:43
static const PreBasis & create(const PreBasis &preBasis)
Do not transform the preBasis if already flat.
Definition: flatprebasis.hh:48
Define the flat index-merging strategy for a given strategy IMS
Definition: flatprebasis.hh:58
IMS type
Definition: flatprebasis.hh:59
Dune::Functions::BasisFactory::FlatInterleaved type
Definition: flatprebasis.hh:66
Dune::Functions::BasisFactory::FlatLexicographic type
Definition: flatprebasis.hh:73
typename FlatIndexMergingStrategy< IMS >::type FIMS
Definition: flatprebasis.hh:80
Dune::Functions::CompositePreBasis< FIMS, FlatPreBasis_t< SPB >... > type
Definition: flatprebasis.hh:81
static type create(const PreBasis &preBasis)
Definition: flatprebasis.hh:84
static type create(const PreBasis &preBasis, std::index_sequence< I... >)
Definition: flatprebasis.hh:89
static type create(const PreBasis &preBasis)
Definition: flatprebasis.hh:102
Dune::Functions::PowerPreBasis< FIMS, FlatPreBasis_t< SPB >, C > type
Definition: flatprebasis.hh:99
typename FlatIndexMergingStrategy< IMS >::type FIMS
Definition: flatprebasis.hh:98