3 #include <dune/common/version.hh> 4 #include <dune/functions/functionspacebases/basistags.hh> 5 #include <dune/functions/functionspacebases/compositebasis.hh> 6 #include <dune/functions/functionspacebases/lagrangebasis.hh> 7 #include <dune/functions/functionspacebases/powerbasis.hh> 8 #include <dune/functions/functionspacebases/flatmultiindex.hh> 10 #include <amdis/Output.hpp> 11 #include <amdis/common/TypeTraits.hpp> 12 #include <amdis/typetree/FiniteElementType.hpp> 18 template <
class PreBasis,
19 class MultiIndex = Dune::Functions::FlatMultiIndex<std::size_t>>
22 using type = PreBasis;
25 static type create(PB
const& preBasis)
27 return {preBasis.gridView()};
30 static PreBasis
const& create(PreBasis
const& preBasis)
36 template <
class PreBasis,
37 class MultiIndex = Dune::Functions::FlatMultiIndex<std::size_t>>
38 using FlatPreBasis_t =
typename FlatPreBasis<PreBasis, MultiIndex>::type;
40 template <
class PreBasis>
41 auto flatPreBasis(PreBasis
const& preBasis)
47 #if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7) 48 template <
class GV,
class MI,
class MultiIndex>
49 struct FlatPreBasis<Dune::Functions::LagrangePreBasis<GV,-1,MI>, MultiIndex>
51 using type = Dune::Functions::LagrangePreBasis<GV,-1,MultiIndex>;
53 template <
class GV,
class MI,
class R,
class MultiIndex>
54 struct FlatPreBasis<Dune::Functions::LagrangePreBasis<GV,-1,MI,R>, MultiIndex>
56 using type = Dune::Functions::LagrangePreBasis<GV,-1,
MultiIndex,R>;
60 static type create(PB
const& preBasis)
62 auto node = preBasis.makeNode();
63 node.bind(*preBasis.gridView().template begin<0>());
64 return {preBasis.gridView(), (
unsigned int)(node.finiteElement().localBasis().order())};
67 static type
const& create(type
const& preBasis)
75 #if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7) 78 template <
class PreBasis>
79 class DerivedPreBasis {
82 template <
class PB,
class SPB =
typename PB::SubPreBasis>
83 static SPB
const& subPreBasis(PB
const& pb)
85 return access(pb).subPreBasis_;
89 template <std::
size_t I,
class PB,
class SPB =
typename PB::
template SubPreBasis<I>>
90 static SPB
const& subPreBasis(PB
const& pb, Dune::index_constant<I>)
92 return std::get<I>(access(pb).subPreBases_);
96 class Accessor :
public T {
friend class DerivedPreBasis<PreBasis>; };
99 static Accessor<T>
const& access(T
const& obj) {
return static_cast<Accessor<T> const&
>(obj); }
102 template <
class PreBasis,
class... Index>
103 static auto const& subPreBasis(PreBasis
const& preBasis, Index... ii)
105 return DerivedPreBasis<PreBasis>::subPreBasis(preBasis,ii...);
108 template <
class PreBasis,
class... Index>
109 static auto const& subPreBasis(PreBasis
const& preBasis, Index... ii)
111 return preBasis.subPreBasis(ii...);
118 template <
class MI,
class IMS,
class... SPB,
class MultiIndex>
119 struct FlatPreBasis<Dune::Functions::CompositePreBasis<MI, IMS, SPB...>, MultiIndex>
121 using FIMS = Dune::Functions::BasisFactory::FlatLexicographic;
122 using type = Dune::Functions::CompositePreBasis<MultiIndex, FIMS, FlatPreBasis_t<SPB, MultiIndex>...>;
124 template <
class PreBasis>
125 static type create(PreBasis
const& preBasis)
127 return create(preBasis, std::index_sequence_for<SPB...>{});
130 template <
class PreBasis, std::size_t... I>
131 static type create(PreBasis
const& preBasis, std::index_sequence<I...>)
133 test_warning(std::is_same_v<IMS,FIMS>,
"Basis converted into flat index-merging strategy.");
139 template <
class MI,
class IMS,
class SPB, std::
size_t C,
class MultiIndex>
140 struct FlatPreBasis<Dune::Functions::PowerPreBasis<MI, IMS, SPB, C>, MultiIndex>
142 using type = Dune::Functions::PowerPreBasis<MultiIndex, IMS, SPB, C>;
144 template <
class PreBasis>
145 static type create(PreBasis
const& preBasis)
152 template <
class MI,
class SPB, std::
size_t C,
class MultiIndex>
154 <MI, Dune::Functions::BasisFactory::BlockedInterleaved, SPB, C>, MultiIndex>
156 using FIMS = Dune::Functions::BasisFactory::FlatInterleaved;
157 using type = Dune::Functions::PowerPreBasis<MultiIndex, FIMS, FlatPreBasis_t<SPB, MultiIndex>, C>;
159 template <
class PreBasis>
160 static type create(PreBasis
const& preBasis)
162 warning(
"Basis converted into flat index-merging strategy.");
168 template <
class MI,
class SPB, std::
size_t C,
class MultiIndex>
170 <MI, Dune::Functions::BasisFactory::BlockedLexicographic, SPB, C>, MultiIndex>
172 using FIMS = Dune::Functions::BasisFactory::FlatLexicographic;
173 using type = Dune::Functions::PowerPreBasis<MultiIndex, FIMS, FlatPreBasis_t<SPB, MultiIndex>, C>;
175 template <
class PreBasis>
176 static type create(PreBasis
const& preBasis)
178 warning(
"Basis converted into flat index-merging strategy.");
constexpr bool MultiIndex
A multi-index type.
Definition: Concepts.hpp:150
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
Definition: FlatPreBasis.hpp:20
void test_warning(bool condition, std::string const &str, Args &&... args)
test for condition and in case of failure print message
Definition: Output.hpp:183