Loading [MathJax]/extensions/TeX/AMSsymbols.js

DUNE-ACFEM (unstable)

sumoperandtuple.hh
1#ifndef __DUNE_ACFEM_TENSOR_OPTIMIZATION_SUMOPERANDTUPLE_HH__
2#define __DUNE_ACFEM_TENSOR_OPTIMIZATION_SUMOPERANDTUPLE_HH__
3
4#include "../../expressions/operationpair.hh"
5#include "../../expressions/optimizesums.hh"
6#include "../modules/kronecker.hh"
7#include "../modules/eye.hh"
8
9namespace Dune::ACFem::Tensor::Optimization::Sums {
10
11 using namespace Expressions;
12
18 template<class Tuple, class SFINAE = void>
20 {
21 using Type = Tuple;
22 };
23
25
26 /*
27(delta<3,3@[2,2]> + (delta<3,3@[0,0]> + delta<3,3@[1,1]>)))
28 */
29
30 template<class Tuple, class SFINAE = void>
31 constexpr inline bool IsCompleteSumOfKroneckersV = false;
32
33 template<class T>
34 constexpr inline bool IsKroneckerNodeV = false;
35
36 template<class T, class Pos>
37 constexpr inline bool IsKroneckerNodeV<TreeData<PlusFunctor, T, Pos> > =
38 IsDiagonalKroneckerDelta<T>::value;
39
43 template<class T0, class... T>
44 constexpr bool isCompleteSumOfKroneckers(MPL::TypeTuple<T0, T...>)
45 {
46 constexpr std::size_t minDim = Head<typename TensorTraits<T0>::Signature>::value;
47 // constexpr std::size_t minDim = min(TensorTraits<T0>::signature());
48 if constexpr (minDim == (sizeof...(T)+1)) {
49 return ((Head<PivotSequence<T0> >::value + ... + Head<PivotSequence<T> >::value)
50 ==
51 minDim * (minDim - 1) / 2);
52 } else {
53 return false;
54 }
55 }
56
57 template<class T0, class... T>
58 constexpr inline bool IsCompleteSumOfKroneckersV<
59 MPL::TypeTuple<T0, T...>,
60 std::enable_if_t<(IsKroneckerNodeV<T0> && ... && IsKroneckerNodeV<T>)>
61 > = isCompleteSumOfKroneckers(MPL::TypeTuple<typename T0::Operand, typename T::Operand...>{});
62
63 template<class Tuple>
64 struct ProcessSumOperands<Tuple, std::enable_if_t<IsCompleteSumOfKroneckersV<Tuple> > >
65 {
66 using Signature = typename TensorTraits<typename MPL::FrontType<Tuple>::Operand>::Signature;
67 using Type = MPL::TypeTuple<TreeData<PlusFunctor, Eye<Signature>, TreePosition<~0UL> > >;
68 };
69
70
71#if 1
72
73 template<class In, class Out>
74 struct OptimizeAll;
75
76 template<class In0, class... In, class... Out>
77 struct OptimizeAll<MPL::TypeTuple<In0, In...>, MPL::TypeTuple<Out...> >
78 {
79 using Try = Expressions::Sums::TryAddSumOperand<In0, MPL::TypeTuple<Out...> >;
80 using Output = ConditionalType<(Try::size() > 0), Try, MPL::TypeTuple<Out..., In0> >;
81 using Type = typename OptimizeAll<MPL::TypeTuple<In...>, Output>::Type;
82 };
83
84 template<class Out>
85 struct OptimizeAll<MPL::TypeTuple<>, Out>
86 {
87 using Type = Out;
88 };
89
90 template<class In0, class In1, class... In>
91 struct ProcessSumOperands<MPL::TypeTuple<In0, In1, In...>, std::enable_if_t<!IsCompleteSumOfKroneckersV<MPL::TypeTuple<In0, In1, In...> > > >
92 {
93 using Type = typename OptimizeAll<MPL::TypeTuple<In1, In...>, MPL::TypeTuple<In0> >::Type;
94 };
95
96#endif
97}
98
99#endif // __DUNE_ACFEM_TENSOR_OPTIMIZATION_SUMOPERANDTUPLE_HH__
constexpr std::size_t size()
Gives the number of elements in tuple-likes and std::integer_sequence.
Definition: size.hh:73
STL namespace.
Gets the type of the n-th element of a tuple-like or the std::integral_constant corresponding to the ...
Definition: access.hh:42
Hook into the innermost operand tuple of the factor out code.
Definition: sumoperandtuple.hh:20
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Mar 12, 23:28, 2025)