v0.14.0
Tensor2_symmetric_carat_Tensor2.hpp
Go to the documentation of this file.
1 /* Creates a Tensor2_symmetric expression by contracting a
2  Tensor2_symmetric and a Tensor2 together. There are different
3  versions, depending on where the contracting indices are located
4  (i.e. whether it is A(i,j)^B(j,k) or A(i,j)^B(k,j)). The classes
5  are numbered to differentiate between these. Thus, A(i,j)^B(j,k)
6  has 10 appended to the name because I count from 0. */
7 
8 #pragma once
9 
10 namespace FTensor
11 {
12  /* Base Template */
13  template <class A, class B, class T, class U, int Dim_0, int Dim0_1,
14  int Dim1_1, char i0, char j0, char i1, char j1>
16  {};
17 
18  /* A(i,j)*B(j,k) */
19 
20  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
21  class Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim, Dim, Dim, i, j, j, k>
22  {
25 
26  template <int Current_Dim>
27  typename promote<T, U>::V
28  eval(const int N1, const int N2, const Number<Current_Dim> &) const
29  {
30  return iterA(N1, Current_Dim - 1) * iterB(Current_Dim - 1, N2)
31  + eval(N1, N2, Number<Current_Dim - 1>());
32  }
33  typename promote<T, U>::V
34  eval(const int N1, const int N2, const Number<1> &) const
35  {
36  return iterA(N1, 0) * iterB(0, N2);
37  }
38 
39  public:
43  : iterA(a), iterB(b)
44  {}
45  typename promote<T, U>::V operator()(const int N1, const int N2) const
46  {
47  return eval(N1, N2, Number<Dim>());
48  }
49  };
50 
51  /* A(i,j)*B(k,j) */
52 
53  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
54  class Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim, Dim, Dim, i, j, k, j>
55  {
58 
59  template <int Current_Dim>
60  typename promote<T, U>::V
61  eval(const int N1, const int N2, const Number<Current_Dim> &) const
62  {
63  return iterA(N1, Current_Dim - 1) * iterB(N2, Current_Dim - 1)
64  + eval(N1, N2, Number<Current_Dim - 1>());
65  }
66  typename promote<T, U>::V
67  eval(const int N1, const int N2, const Number<1> &) const
68  {
69  return iterA(N1, 0) * iterB(N2, 0);
70  }
71 
72  public:
76  : iterA(a), iterB(b)
77  {}
78  typename promote<T, U>::V operator()(const int N1, const int N2) const
79  {
80  return eval(N1, N2, Number<Dim>());
81  }
82  };
83 
84  /* A(j,i)*B(j,k) */
85 
86  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
87  class Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim, Dim, Dim, j, i, j, k>
88  {
91 
92  template <int Current_Dim>
93  typename promote<T, U>::V
94  eval(const int N1, const int N2, const Number<Current_Dim> &) const
95  {
96  return iterA(Current_Dim - 1, N1) * iterB(Current_Dim - 1, N2)
97  + eval(N1, N2, Number<Current_Dim - 1>());
98  }
99  typename promote<T, U>::V
100  eval(const int N1, const int N2, const Number<1> &) const
101  {
102  return iterA(0, N1) * iterB(0, N2);
103  }
104 
105  public:
109  : iterA(a), iterB(b)
110  {}
111  typename promote<T, U>::V operator()(const int N1, const int N2) const
112  {
113  return eval(N1, N2, Number<Dim>());
114  }
115  };
116 
117  /* A(j,i)*B(k,j) */
118 
119  template <class A, class B, class T, class U, int Dim, char i, char j, char k>
120  class Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim, Dim, Dim, j, i, k, j>
121  {
124 
125  template <int Current_Dim>
126  typename promote<T, U>::V
127  eval(const int N1, const int N2, const Number<Current_Dim> &) const
128  {
129  return iterA(Current_Dim - 1, N1) * iterB(N2, Current_Dim - 1)
130  + eval(N1, N2, Number<Current_Dim - 1>());
131  }
132  typename promote<T, U>::V
133  eval(const int N1, const int N2, const Number<1> &) const
134  {
135  return iterA(0, N1) * iterB(N2, 0);
136  }
137 
138  public:
142  : iterA(a), iterB(b)
143  {}
144  typename promote<T, U>::V operator()(const int N1, const int N2) const
145  {
146  return eval(N1, N2, Number<Dim>());
147  }
148  };
149 
150  template <class A, class B, class T, class U, int Dim_0, int Dim0_1,
151  int Dim1_1, char i0, char j0, char i1, char j1>
154  {
155  using TensorExpr
156  = Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim_0, Dim0_1, Dim1_1, i0,
157  j0, i1, j1>;
158  static_assert(
159  !std::is_empty<TensorExpr>::value,
160  "Indexes or Dimensions are not compatible with the ^ operator");
161 
162  // Definition of Helper constexpr variables
163  constexpr char i = (i0 == i1 || i0 == j1) ? j0 : i0,
164  j = (i1 == i0 || i1 == j0) ? j1 : i1;
165 
167  i, j>(TensorExpr(a, b));
168  }
169 
170  /* B(k,j)*A(j,i) */
171 
172  template <class A, class B, class T, class U, int Dim_0, int Dim0_1,
173  int Dim1_1, char i0, char j0, char i1, char j1>
176  {
177  using TensorExpr
178  = Tensor2_symmetric_carat_Tensor2<A, B, T, U, Dim_0, Dim0_1, Dim1_1, i0,
179  j0, i1, j1>;
180  static_assert(
181  !std::is_empty<TensorExpr>::value,
182  "Indexes or Dimensions are not compatible with the ^ operator");
183 
184  // Definition of Helper constexpr variables
185  constexpr char i = (i0 == i1 || i0 == j1) ? j0 : i0,
186  j = (i1 == i0 || i1 == j0) ? j1 : i1;
187 
189  i, j>(TensorExpr(a, b));
190  }
191 }
FTensor::operator^
Ddg_Expr< Ddg_carat_Ddg_13< A, B, T, U, Dim, Dim23, i, j, k, l, m, n >, typename promote< T, U >::V, Dim, Dim23, i, k, m, n > operator^(const Ddg_Expr< A, T, Dim, Dim, i, j, k, l > &a, const Ddg_Expr< B, U, Dim, Dim23, j, l, m, n > &b)
Definition: Ddg_carat_Ddg.hpp:59
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, k, j >::Tensor2_symmetric_carat_Tensor2
Tensor2_symmetric_carat_Tensor2(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_Expr< B, U, Dim, Dim, k, j > &b)
Definition: Tensor2_symmetric_carat_Tensor2.hpp:73
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, j, k >::iterB
const Tensor2_Expr< B, U, Dim, Dim, j, k > iterB
Definition: Tensor2_symmetric_carat_Tensor2.hpp:90
FTensor::Tensor2_symmetric_Expr
Definition: Tensor2_symmetric_Expr.hpp:36
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, j, k >::iterA
const Tensor2_symmetric_Expr< A, T, Dim, j, i > iterA
Definition: Tensor2_symmetric_carat_Tensor2.hpp:89
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, j, k >::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:28
FTensor::Tensor2_Expr< B, U, Dim, Dim, j, k >
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, j, k >::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:34
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, j, k >::iterA
const Tensor2_symmetric_Expr< A, T, Dim, i, j > iterA
Definition: Tensor2_symmetric_carat_Tensor2.hpp:23
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, k, j >::iterA
const Tensor2_symmetric_Expr< A, T, Dim, j, i > iterA
Definition: Tensor2_symmetric_carat_Tensor2.hpp:122
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, k, j >::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:127
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, j, k >::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:45
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, j, k >::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:94
FTensor::Number
Definition: Number.hpp:11
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, k, j >::iterB
const Tensor2_Expr< B, U, Dim, Dim, k, j > iterB
Definition: Tensor2_symmetric_carat_Tensor2.hpp:57
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, j, k >::Tensor2_symmetric_carat_Tensor2
Tensor2_symmetric_carat_Tensor2(const Tensor2_symmetric_Expr< A, T, Dim, i, j > &a, const Tensor2_Expr< B, U, Dim, Dim, j, k > &b)
Definition: Tensor2_symmetric_carat_Tensor2.hpp:40
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, k, j >::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:78
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, j, k >::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:100
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, k, j >::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< Current_Dim > &) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:61
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor2_symmetric_carat_Tensor2
Definition: Tensor2_symmetric_carat_Tensor2.hpp:15
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, j, k >::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:111
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, k, j >::Tensor2_symmetric_carat_Tensor2
Tensor2_symmetric_carat_Tensor2(const Tensor2_symmetric_Expr< A, T, Dim, j, i > &a, const Tensor2_Expr< B, U, Dim, Dim, k, j > &b)
Definition: Tensor2_symmetric_carat_Tensor2.hpp:139
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, k, j >::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:133
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, j, k >::iterB
const Tensor2_Expr< B, U, Dim, Dim, j, k > iterB
Definition: Tensor2_symmetric_carat_Tensor2.hpp:24
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, k, j >::eval
promote< T, U >::V eval(const int N1, const int N2, const Number< 1 > &) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:67
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, j, k >::Tensor2_symmetric_carat_Tensor2
Tensor2_symmetric_carat_Tensor2(const Tensor2_symmetric_Expr< A, T, Dim, j, i > &a, const Tensor2_Expr< B, U, Dim, Dim, j, k > &b)
Definition: Tensor2_symmetric_carat_Tensor2.hpp:106
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, i, j, k, j >::iterA
const Tensor2_symmetric_Expr< A, T, Dim, i, j > iterA
Definition: Tensor2_symmetric_carat_Tensor2.hpp:56
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, k, j >::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_symmetric_carat_Tensor2.hpp:144
FTensor::Tensor2_symmetric_carat_Tensor2< A, B, T, U, Dim, Dim, Dim, j, i, k, j >::iterB
const Tensor2_Expr< B, U, Dim, Dim, k, j > iterB
Definition: Tensor2_symmetric_carat_Tensor2.hpp:123