v0.14.0
Dg_Expr.hpp
Go to the documentation of this file.
1 /* Declares a wrapper class for symmetric rank 3 Tensor expressions
2  that are symmetric on the first two indices. It is also used for
3  Christof's but with some games played with the
4  indices. */
5 
6 #pragma once
7 
8 #include "Dg_and_Dg.hpp"
9 #include "Dg_and_Tensor1.hpp"
11 #include "Dg_divide_generic.hpp"
12 #include "Dg_minus_Dg.hpp"
13 #include "Dg_or_Dg.hpp"
14 #include "Dg_plus_Dg.hpp"
15 #include "Dg_times_Dg.hpp"
16 #include "Dg_times_Tensor1.hpp"
17 #include "Dg_times_Tensor2.hpp"
19 #include "Dg_times_generic.hpp"
20 #include "minus_Dg.hpp"
21 
22 namespace FTensor
23 {
24  template <class A, class T, int Dim01, int Dim2, char i, char j, char k>
25  class Dg_Expr
26  {
28 
29  public:
30  Dg_Expr(const A &a) : iter(a) {}
31  T operator()(const int N1, const int N2, const int N3) const
32  {
33  return iter(N1, N2, N3);
34  }
35  };
36 
37  template <class A, class T, int Tensor_Dim01, int Tensor_Dim2, int Dim01,
38  int Dim2, char i, char j, char k>
39  class Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2, i, j, k>
40  {
42 
43  public:
45  T &operator()(const int N1, const int N2, const int N3)
46  {
47  return iter(N1, N2, N3);
48  }
49  T operator()(const int N1, const int N2, const int N3) const
50  {
51  return iter(N1, N2, N3);
52  }
53 
54  /* Various assignment operators. I have to explicitly declare the
55  second operator= because otherwise the compiler will generate its
56  own and not use the template code. */
57 
58  template <class B, class U>
59  Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2, i, j, k> &
60  operator=(const Dg_Expr<B, U, Dim01, Dim2, i, j, k> &result);
61 
62  Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2, i, j, k> &
63  operator=(const Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2,
64  i, j, k> &result);
65 
66  template <class B, class U>
67  Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2, i, j, k> &
68  operator+=(const Dg_Expr<B, U, Dim01, Dim2, i, j, k> &result);
69 
70  Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2, i, j, k> &
71  operator+=(const Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2,
72  i, j, k> &result);
73 
74  template <class B, class U>
75  Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2, i, j, k> &
76  operator-=(const Dg_Expr<B, U, Dim01, Dim2, i, j, k> &result);
77 
78  Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2, i, j, k> &
79  operator-=(const Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2,
80  i, j, k> &result);
81 
82  template <class U>
83  Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2, i, j, k> &
84  operator=(const U &d);
85  };
86 
87  /* I need a version for const and non-const Christof,
88  otherwise it will use the default and the index order will get all
89  messed up. The class A is either T or T*, depending on whether
90  Christof has an array of T's or T *'s. */
91 
92  template <class A, class T, int Tensor_Dim0, int Tensor_Dim12, int Dim12,
93  int Dim0, char i, char j, char k>
94  class Dg_Expr<const Christof<A, Tensor_Dim0, Tensor_Dim12>, T, Dim12, Dim0,
95  i, j, k>
96  {
98 
99  public:
101 
102  /* Need to switch the index order because a christof tensor is just
103  a dg tensor with the indices switched. */
104 
105  T operator()(const int N1, const int N2, const int N3) const
106  {
107  return iter(N3, N1, N2);
108  }
109  };
110 
111  template <class A, class T, int Tensor_Dim0, int Tensor_Dim12, int Dim12,
112  int Dim0, char i, char j, char k>
113  class Dg_Expr<Christof<A, Tensor_Dim0, Tensor_Dim12>, T, Dim12, Dim0, i, j, k>
114  {
116 
117  public:
119 
120  /* Need to switch the index order because a christof tensor is just
121  a dg tensor with the indices switched. I have to explicitly
122  declare the second operator= because otherwise the compiler will
123  generate its own and not use the template code. */
124 
125  T operator()(const int N1, const int N2, const int N3) const
126  {
127  return iter(N3, N1, N2);
128  }
129 
130  template <class B, class U>
132  operator=(const Dg_Expr<B, U, Dim12, Dim0, i, j, k> &result);
133 
135  operator=(const Dg_Expr<Christof<A, Tensor_Dim0, Tensor_Dim12>, T, Dim12,
136  Dim0, i, j, k> &result);
137 
138  template <class B, class U>
140  operator+=(const Dg_Expr<B, U, Dim12, Dim0, i, j, k> &result);
141 
143  operator+=(const Dg_Expr<Christof<A, Tensor_Dim0, Tensor_Dim12>, T, Dim12,
144  Dim0, i, j, k> &result);
145 
146  template <class B, class U>
148  operator-=(const Dg_Expr<B, U, Dim12, Dim0, i, j, k> &result);
149 
151  operator-=(const Dg_Expr<Christof<A, Tensor_Dim0, Tensor_Dim12>, T, Dim12,
152  Dim0, i, j, k> &result);
153 
154  template <class U>
156  operator=(const U &d);
157  };
158 
159  /* Specialized for Ddg_number_rhs_0 (Ddg with the
160  first index explicitly given). */
161 
162  template <class A, class T, int Dim23, int Dim1, char i, char j, char k,
163  int N0>
164  class Dg_Expr<Ddg_number_rhs_0<A, T, N0>, T, Dim23, Dim1, i, j, k>
165  {
166  A &iter;
167 
168  public:
169  Dg_Expr(A &a) : iter(a) {}
170  T &operator()(const int N1, const int N2, const int N3)
171  {
172  return iter(N0, N1, N2, N3);
173  }
174  T operator()(const int N1, const int N2, const int N3) const
175  {
176  return iter(N0, N1, N2, N3);
177  }
178 
179  /* Various assignment operators. I have to explicitly declare the
180  second operator= because otherwise the compiler will generate its
181  own and not use the template code. */
182 
183  template <class B, class U>
184  Dg_Expr<Ddg_number_rhs_0<A, T, N0>, T, Dim23, Dim1, i, j, k> &
185  operator=(const Dg_Expr<B, U, Dim23, Dim1, i, j, k> &result);
186 
187  Dg_Expr<Ddg_number_rhs_0<A, T, N0>, T, Dim23, Dim1, i, j, k> &
188  operator=(const Dg_Expr<Ddg_number_rhs_0<A, T, N0>, T, Dim23, Dim1, i, j,
189  k> &result);
190  };
191 }
192 
193 #include "Dg_Expr_equals.hpp"
Dg_times_generic.hpp
Dg_times_Tensor2.hpp
FTensor::Dg_Expr< const Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k >::Dg_Expr
Dg_Expr(const Christof< A, Tensor_Dim0, Tensor_Dim12 > &a)
Definition: Dg_Expr.hpp:100
FTensor::Christof
Definition: Christof_value.hpp:9
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
Dg_times_Tensor1.hpp
FTensor::Dg_Expr< Dg< A, Tensor_Dim01, Tensor_Dim2 >, T, Dim01, Dim2, i, j, k >::operator()
T operator()(const int N1, const int N2, const int N3) const
Definition: Dg_Expr.hpp:49
Dg_and_Tensor2_symmetric.hpp
FTensor::Dg_Expr< Ddg_number_rhs_0< A, T, N0 >, T, Dim23, Dim1, i, j, k >::Dg_Expr
Dg_Expr(A &a)
Definition: Dg_Expr.hpp:169
FTensor::Dg_Expr::operator()
T operator()(const int N1, const int N2, const int N3) const
Definition: Dg_Expr.hpp:31
FTensor::Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k >::Dg_Expr
Dg_Expr(Christof< A, Tensor_Dim0, Tensor_Dim12 > &a)
Definition: Dg_Expr.hpp:118
Dg_plus_Dg.hpp
Dg_times_Dg.hpp
FTensor::Dg_Expr< Dg< A, Tensor_Dim01, Tensor_Dim2 >, T, Dim01, Dim2, i, j, k >::operator()
T & operator()(const int N1, const int N2, const int N3)
Definition: Dg_Expr.hpp:45
FTensor::Dg_Expr< Ddg_number_rhs_0< A, T, N0 >, T, Dim23, Dim1, i, j, k >::iter
A & iter
Definition: Dg_Expr.hpp:166
FTensor::d
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: dTensor0.hpp:27
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
Dg_minus_Dg.hpp
FTensor::Dg_Expr::iter
A iter
Definition: Dg_Expr.hpp:27
FTensor::Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k >::iter
Christof< A, Tensor_Dim0, Tensor_Dim12 > & iter
Definition: Dg_Expr.hpp:115
FTensor::Dg_Expr< const Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k >::iter
Christof< A, Tensor_Dim0, Tensor_Dim12 > iter
Definition: Dg_Expr.hpp:97
FTensor::Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k >::operator()
T operator()(const int N1, const int N2, const int N3) const
Definition: Dg_Expr.hpp:125
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Dg_Expr< Dg< A, Tensor_Dim01, Tensor_Dim2 >, T, Dim01, Dim2, i, j, k >::Dg_Expr
Dg_Expr(Dg< A, Tensor_Dim01, Tensor_Dim2 > &a)
Definition: Dg_Expr.hpp:44
minus_Dg.hpp
Dg_times_Tensor2_symmetric.hpp
Dg_divide_generic.hpp
FTensor::Dg_Expr< Ddg_number_rhs_0< A, T, N0 >, T, Dim23, Dim1, i, j, k >::operator()
T operator()(const int N1, const int N2, const int N3) const
Definition: Dg_Expr.hpp:174
Dg_Expr_equals.hpp
Dg_and_Dg.hpp
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Dg_Expr::Dg_Expr
Dg_Expr(const A &a)
Definition: Dg_Expr.hpp:30
Dg_and_Tensor1.hpp
FTensor::Dg
Definition: Dg_value.hpp:9
FTensor::Dg_Expr
Definition: Dg_Expr.hpp:25
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
Dg_or_Dg.hpp
FTensor::Dg_Expr< Ddg_number_rhs_0< A, T, N0 >, T, Dim23, Dim1, i, j, k >::operator()
T & operator()(const int N1, const int N2, const int N3)
Definition: Dg_Expr.hpp:170
FTensor::Dg_Expr< const Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k >::operator()
T operator()(const int N1, const int N2, const int N3) const
Definition: Dg_Expr.hpp:105
FTensor::Dg_Expr< Dg< A, Tensor_Dim01, Tensor_Dim2 >, T, Dim01, Dim2, i, j, k >::iter
Dg< A, Tensor_Dim01, Tensor_Dim2 > & iter
Definition: Dg_Expr.hpp:41
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
FTensor::Ddg_number_rhs_0
Definition: Ddg_number.hpp:40