v0.14.0
Tensor3_or_Tensor3.hpp
Go to the documentation of this file.
1 /* Adds a Tensor3 to a Tensor3, yielding a Dg. */
2 
3 #pragma once
4 
5 namespace FTensor
6 {
7  /* Base Template */
8  template <class A, class B, class T, class U, int Dim0_0, int Dim1_0,
9  int Dim2_0, int Dim0_1, int Dim1_1, int Dim2_1, char i0, char j0,
10  char k0, char i1, char j1, char k1>
12  {};
13 
14  /* A(i,j,k)+B(i,k,j)->Dg */
15 
16  template <class A, class B, class T, class U, int Dim0, int Dim12, char i,
17  char j, char k>
18  class Tensor3_or_Tensor3<A, B, T, U, Dim0, Dim12, Dim12, Dim0, Dim12, Dim12,
19  i, j, k, i, k, j>
20  {
23 
24  public:
25  typename promote<T, U>::V
26  operator()(const int N1, const int N2, const int N3) const
27  {
28  return iterA(N3, N1, N2) + iterB(N3, N2, N1);
29  }
30 
34  : iterA(a), iterB(b)
35  {}
36  };
37 
38  /* A(i,j,k)+B(k,j,i)->Dg */
39 
40  template <class A, class B, class T, class U, int Dim02, int Dim1, char i,
41  char j, char k>
42  class Tensor3_or_Tensor3<A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02,
43  i, j, k, k, j, i>
44  {
47 
48  public:
49  typename promote<T, U>::V
50  operator()(const int N1, const int N2, const int N3) const
51  {
52  return iterA(N1, N3, N2) + iterB(N2, N3, N1);
53  }
54 
58  : iterA(a), iterB(b)
59  {}
60  };
61 
62  /* A(i,j,k)+B(j,i,k)->Dg */
63 
64  template <class A, class B, class T, class U, int Dim02, int Dim1, char i,
65  char j, char k>
66  class Tensor3_or_Tensor3<A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02,
67  i, j, k, j, i, k>
68  {
71 
72  public:
73  typename promote<T, U>::V
74  operator()(const int N1, const int N2, const int N3) const
75  {
76  return iterA(N1, N2, N3) + iterB(N2, N1, N3);
77  }
78 
82  : iterA(a), iterB(b)
83  {}
84  };
85 
86  template <class A, class B, class T, class U, int Dim0_0, int Dim1_0,
87  int Dim2_0, int Dim0_1, int Dim1_1, int Dim2_1, char i0, char j0,
88  char k0, char i1, char j1, char k1>
89  auto
92  {
93  using TensorExpr =
94  Tensor3_or_Tensor3<A, B, T, U, Dim0_0, Dim1_0, Dim2_0, Dim0_1, Dim1_1,
95  Dim2_1, i0, j0, k0, i1, j1, k1>;
96  static_assert(
97  !std::is_empty<TensorExpr>::value,
98  "Indexes or Dimensions are not compatible with the || operator");
99 
100  // Definition of Helper constexpr variables
101  constexpr char i = (k0 == i1 || k0 == j1) ? ((i0 == i1) ? j0 : i0) : i0;
102  constexpr char j = (k0 == i1 || k0 == j1) ? k0 : j0;
103  constexpr char k = (k0 == i1 || k0 == j1) ? ((i0 == i1) ? i0 : j0) : k0;
104 
105  return Dg_Expr<TensorExpr, typename promote<T, U>::V, Dim0_0, Dim1_0, i,
106  j, k>(TensorExpr(a, b));
107  }
108 }
FTensor::Tensor3_or_Tensor3
Definition: Tensor3_or_Tensor3.hpp:11
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim0, Dim12, Dim12, Dim0, Dim12, Dim12, i, j, k, i, k, j >::Tensor3_or_Tensor3
Tensor3_or_Tensor3(const Tensor3_Expr< A, T, Dim0, Dim12, Dim12, i, j, k > &a, const Tensor3_Expr< B, U, Dim0, Dim12, Dim12, i, k, j > &b)
Definition: Tensor3_or_Tensor3.hpp:31
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02, i, j, k, j, i, k >::Tensor3_or_Tensor3
Tensor3_or_Tensor3(const Tensor3_Expr< A, T, Dim02, Dim1, Dim02, i, j, k > &a, const Tensor3_Expr< B, U, Dim02, Dim1, Dim02, j, i, k > &b)
Definition: Tensor3_or_Tensor3.hpp:79
FTensor::operator||
Ddg_Expr< Ddg_or_Ddg< A, B, T, U, Dim, i, j, k, l >, typename promote< T, U >::V, Dim, Dim, i, k, j, l > operator||(const Ddg_Expr< A, T, Dim, Dim, i, j, k, l > &a, const Ddg_Expr< B, U, Dim, Dim, i, l, k, j > &b)
Definition: Ddg_or_Ddg.hpp:33
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02, i, j, k, k, j, i >::iterB
Tensor3_Expr< B, U, Dim02, Dim1, Dim02, k, j, i > iterB
Definition: Tensor3_or_Tensor3.hpp:46
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02, i, j, k, j, i, k >::iterA
Tensor3_Expr< A, T, Dim02, Dim1, Dim02, i, j, k > iterA
Definition: Tensor3_or_Tensor3.hpp:69
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02, i, j, k, j, i, k >::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3) const
Definition: Tensor3_or_Tensor3.hpp:74
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02, i, j, k, j, i, k >::iterB
Tensor3_Expr< B, U, Dim02, Dim1, Dim02, j, i, k > iterB
Definition: Tensor3_or_Tensor3.hpp:70
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim0, Dim12, Dim12, Dim0, Dim12, Dim12, i, j, k, i, k, j >::iterB
Tensor3_Expr< B, U, Dim0, Dim12, Dim12, i, k, j > iterB
Definition: Tensor3_or_Tensor3.hpp:22
FTensor::Tensor3_Expr< A, T, Dim0, Dim12, Dim12, i, j, k >
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02, i, j, k, k, j, i >::Tensor3_or_Tensor3
Tensor3_or_Tensor3(const Tensor3_Expr< A, T, Dim02, Dim1, Dim02, i, j, k > &a, const Tensor3_Expr< B, U, Dim02, Dim1, Dim02, k, j, i > &b)
Definition: Tensor3_or_Tensor3.hpp:55
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim0, Dim12, Dim12, Dim0, Dim12, Dim12, i, j, k, i, k, j >::iterA
Tensor3_Expr< A, T, Dim0, Dim12, Dim12, i, j, k > iterA
Definition: Tensor3_or_Tensor3.hpp:21
FTensor::Dg_Expr
Definition: Dg_Expr.hpp:25
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02, i, j, k, k, j, i >::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3) const
Definition: Tensor3_or_Tensor3.hpp:50
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim02, Dim1, Dim02, Dim02, Dim1, Dim02, i, j, k, k, j, i >::iterA
Tensor3_Expr< A, T, Dim02, Dim1, Dim02, i, j, k > iterA
Definition: Tensor3_or_Tensor3.hpp:45
FTensor::Tensor3_or_Tensor3< A, B, T, U, Dim0, Dim12, Dim12, Dim0, Dim12, Dim12, i, j, k, i, k, j >::operator()
promote< T, U >::V operator()(const int N1, const int N2, const int N3) const
Definition: Tensor3_or_Tensor3.hpp:26
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197