v0.14.0
Ddg_Expr_equals.hpp
Go to the documentation of this file.
1 /* Various assignment operators. I have to explicitly declare the
2  second operator= because otherwise the compiler will generate its
3  own and not use the template code. */
4 
5 #pragma once
6 
7 namespace FTensor
8 {
9  template <class A, class B, class U, int Current_Dim0, int Current_Dim1,
10  int Current_Dim2, int Current_Dim3, int Dim01, int Dim23, char i,
11  char j, char k, char l>
12  void
15  const Number<Current_Dim0> &,
16  const Number<Current_Dim1> &,
17  const Number<Current_Dim2> &,
18  const Number<Current_Dim3> &)
19  {
20  iter(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
21  Current_Dim3 - 1)
22  = result(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
23  Current_Dim3 - 1);
27  }
28 
29  template <class A, class B, class U, int Current_Dim1, int Current_Dim2,
30  int Current_Dim3, int Dim01, int Dim23, char i, char j, char k,
31  char l>
32  void
35  const Number<1> &, const Number<Current_Dim1> &,
36  const Number<Current_Dim2> &,
37  const Number<Current_Dim3> &)
38  {
39  iter(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1)
40  = result(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1);
44  }
45 
46  template <class A, class B, class U, int Current_Dim2, int Current_Dim3,
47  int Dim01, int Dim23, char i, char j, char k, char l>
48  void
51  const Number<1> &, const Number<1> &,
52  const Number<Current_Dim2> &,
53  const Number<Current_Dim3> &)
54  {
55  iter(0, 0, Current_Dim2 - 1, Current_Dim3 - 1)
56  = result(0, 0, Current_Dim2 - 1, Current_Dim3 - 1);
59  }
60 
61  template <class A, class B, class U, int Current_Dim3, int Dim01, int Dim23,
62  char i, char j, char k, char l>
63  void
66  const Number<1> &, const Number<1> &, const Number<1> &,
67  const Number<Current_Dim3> &)
68  {
69  iter(0, 0, 0, Current_Dim3 - 1) = result(0, 0, 0, Current_Dim3 - 1);
72  }
73 
74  template <class A, class B, class U, int Dim01, int Dim23, char i, char j,
75  char k, char l>
76  void
79  const Number<1> &, const Number<1> &, const Number<1> &,
80  const Number<1> &)
81  {
82  iter(0, 0, 0, 0) = result(0, 0, 0, 0);
83  }
84 
85  template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
86  int Dim23, char i, char j, char k, char l>
87  template <class B, class U>
88  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
89  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l>::
91  {
94  return *this;
95  }
96 
97  template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
98  int Dim23, char i, char j, char k, char l>
99  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
100  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l>::
101  operator=(const Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23,
102  i, j, k, l> &result)
103  {
104  return operator=<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T>(result);
105  }
106 
107  template <bool S> struct Sign_of_T4ddg_plus_equals_T4ddg {};
108 
109  template <> struct Sign_of_T4ddg_plus_equals_T4ddg<true> {
110  template <typename L, typename R> static inline void op(L &l, R &&r) {
111  l += r;
112  }
113  };
114 
115  template <> struct Sign_of_T4ddg_plus_equals_T4ddg<false> {
116  template <typename L, typename R> static inline void op(L &l, R &&r) {
117  l -= r;
118  }
119  };
120 
121  template <class A, class B, class U, int Current_Dim0, int Current_Dim1,
122  int Current_Dim2, int Current_Dim3, int Dim01, int Dim23, char i,
123  char j, char k, char l, class Op>
125  A &iter, const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result,
127  const Number<Current_Dim2> &, const Number<Current_Dim3> &, const Op &) {
128 
129  Op::op(iter(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
130  Current_Dim3 - 1),
131  result(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
132  Current_Dim3 - 1));
135  Number<Current_Dim3>(), Op());
136  }
137 
138  template <class A, class B, class U, int Current_Dim1,
139  int Current_Dim2, int Current_Dim3, int Dim01, int Dim23, char i,
140  char j, char k, char l, class Op>
142  A &iter, const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result,
143  const Number<1> &, const Number<Current_Dim1> &,
144  const Number<Current_Dim2> &, const Number<Current_Dim3> &, const Op &) {
145  Op::op(iter(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1),
146  result(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1));
149  Number<Current_Dim3>(), Op());
150  }
151 
152  template <class A, class B, class U, int Current_Dim2,
153  int Current_Dim3, int Dim01, int Dim23, char i, char j, char k,
154  char l, class Op>
156  A &iter, const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result,
157  const Number<1> &, const Number<1> &, const Number<Current_Dim2> &,
158  const Number<Current_Dim3> &, const Op &) {
159  Op::op(iter(0, 0, Current_Dim2 - 1, Current_Dim3 - 1),
160  result(0, 0, Current_Dim2 - 1, Current_Dim3 - 1));
163  Op());
164  }
165 
166  template <class A, class B, class U, int Current_Dim3, int Dim01,
167  int Dim23, char i, char j, char k, char l, class Op>
169  A &iter, const Ddg_Expr<B, U, Dim01, Dim23, i, j, k, l> &result,
170  const Number<1> &, const Number<1> &, const Number<1> &,
171  const Number<Current_Dim3> &, const Op &) {
172  Op::op(iter(0, 0, 0, Current_Dim3 - 1), result(0, 0, 0, Current_Dim3 - 1));
176  }
177 
178  template <class A, class B, class U, int Dim01, int Dim23, char i, char j,
179  char k, char l, class Op>
180  void
183  const Number<1> &, const Number<1> &, const Number<1> &,
184  const Number<1> &, const Op &)
185  {
186  Op::op(iter(0, 0, 0, 0), result(0, 0, 0, 0));
187  }
188 
189  template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
190  int Dim23, char i, char j, char k, char l>
191  template <class B, class U>
192  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
193  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l>::
195  {
199  return *this;
200  }
201 
202  template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
203  int Dim23, char i, char j, char k, char l>
204  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
205  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l>::
206  operator+=(const Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23,
207  i, j, k, l> &result)
208  {
209  return operator+=<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T>(result);
210  }
211 
212  template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
213  int Dim23, char i, char j, char k, char l>
214  template <class B, class U>
215  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
216  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l>::
218  {
222  return *this;
223  }
224 
225  template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
226  int Dim23, char i, char j, char k, char l>
227  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
228  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l>::
229  operator-=(const Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23,
230  i, j, k, l> &result)
231  {
232  return operator-=<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T>(result);
233  }
234 
235  /* Ddgs*=U */
236 
237  template <class A, class T, class U, int Dim01, int Dim23>
239 
241  const U &u;
242 
243  template <int Current_Dim0, int Current_Dim1, int Current_Dim2,
244  int Current_Dim3>
246  const Number<Current_Dim2> &, const Number<Current_Dim3> &) {
247  iter(Current_Dim0 - 1, Current_Dim1 - 1, Current_Dim2 - 1,
248  Current_Dim3 - 1) *= u;
251  }
252 
253  template <int Current_Dim1, int Current_Dim2, int Current_Dim3>
254  void eval(const Number<1> &, const Number<Current_Dim1> &,
255  const Number<Current_Dim2> &, const Number<Current_Dim3> &) {
256  iter(0, Current_Dim1 - 1, Current_Dim2 - 1, Current_Dim3 - 1) *= u;
259  }
260 
261  template <int Current_Dim2, int Current_Dim3>
262  void eval(const Number<1> &, const Number<1> &,
263  const Number<Current_Dim2> &, const Number<Current_Dim3> &) {
264  iter(0, 0, Current_Dim2 - 1, Current_Dim3 - 1) *= u;
267  }
268 
269  template <int Current_Dim3>
270  void eval(const Number<1> &, const Number<1> &, const Number<1> &,
271  const Number<Current_Dim3> &) {
272  iter(0, 0, 0, Current_Dim3 - 1) *= u;
275  }
276 
277  void eval(const Number<1> &, const Number<1> &, const Number<1> &,
278  const Number<1> &) {
279  iter(0, 0, 0, 0) *= u;
280  }
281 
282  public:
284  : iter(a), u(b) {}
285 
286  void operator()() {
288  }
289  };
290 
291  template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
292  int Dim23, char i, char j, char k, char l>
293  template <class U>
294  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
295  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l>::
296  operator*=(const U &d) {
298  return *this;
299  }
300 
301  template <class A, class T, class U, int Dim01, int Dim23>
303 
305  const U &u;
306 
307  template <int Current_Dim0, int Current_Dim1, int Current_Dim2,
308  int Current_Dim3>
310  const Number<Current_Dim2> &, const Number<Current_Dim3> &) {
315  }
316 
317  template <int Current_Dim1, int Current_Dim2, int Current_Dim3>
318  void eval(const Number<1> &, const Number<Current_Dim1> &,
319  const Number<Current_Dim2> &, const Number<Current_Dim3> &) {
324  }
325 
326  template <int Current_Dim2, int Current_Dim3>
327  void eval(const Number<1> &, const Number<1> &,
328  const Number<Current_Dim2> &, const Number<Current_Dim3> &) {
333  }
334 
335  template <int Current_Dim3>
336  void eval(const Number<1> &, const Number<1> &, const Number<1> &,
337  const Number<Current_Dim3> &) {
339  u;
342  }
343 
344  void eval(const Number<1> &, const Number<1> &, const Number<1> &,
345  const Number<1> &) {
347  }
348 
349  public:
351 
352  void operator()() {
354  }
355  };
356 
357  template <class A, class T, int Tensor_Dim01, int Tensor_Dim23, int Dim01,
358  int Dim23, char i, char j, char k, char l>
359  template <class U>
360  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k, l> &
361  Ddg_Expr<Ddg<A, Tensor_Dim01, Tensor_Dim23>, T, Dim01, Dim23, i, j, k,
362  l>::operator=(const U &d) {
364  return *this;
365  }
366 }
FTensor::Sign_of_T4ddg_plus_equals_T4ddg< false >::op
static void op(L &l, R &&r)
Definition: Ddg_Expr_equals.hpp:116
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::T4Ddg_times_equals_generic::eval
void eval(const Number< 1 > &, const Number< 1 > &, const Number< 1 > &, const Number< Current_Dim3 > &)
Definition: Ddg_Expr_equals.hpp:270
FTensor::T4Ddg_equals_generic::eval
void eval(const Number< 1 > &, const Number< 1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
Definition: Ddg_Expr_equals.hpp:327
FTensor::Sign_of_T4ddg_plus_equals_T4ddg< true >::op
static void op(L &l, R &&r)
Definition: Ddg_Expr_equals.hpp:110
FTensor::T4Ddg_times_equals_generic::eval
void eval(const Number< 1 > &, const Number< 1 > &, const Number< 1 > &, const Number< 1 > &)
Definition: Ddg_Expr_equals.hpp:277
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
FTensor::T4ddg_equals_T4ddg
void T4ddg_equals_T4ddg(A &iter, const Ddg_Expr< B, U, Dim01, Dim23, i, j, k, l > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
Definition: Ddg_Expr_equals.hpp:13
FTensor::T4Ddg_times_equals_generic::T4Ddg_times_equals_generic
T4Ddg_times_equals_generic(Ddg< A, Dim01, Dim23 > &a, const U &b)
Definition: Ddg_Expr_equals.hpp:283
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::T4Ddg_equals_generic
Definition: Ddg_Expr_equals.hpp:302
FTensor::T4Ddg_times_equals_generic::iter
Ddg< A, Dim01, Dim23 > & iter
Definition: Ddg_Expr_equals.hpp:240
FTensor::Ddg_Expr< B, U, Dim01, Dim23, i, j, k, l >
sdf.r
int r
Definition: sdf.py:8
FTensor::T4ddg_plus_equals_T4ddg
void T4ddg_plus_equals_T4ddg(A &iter, const Ddg_Expr< B, U, Dim01, Dim23, i, j, k, l > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &, const Op &)
Definition: Ddg_Expr_equals.hpp:124
FTensor::T4Ddg_equals_generic::eval
void eval(const Number< 1 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
Definition: Ddg_Expr_equals.hpp:318
FTensor::T4Ddg_equals_generic::eval
void eval(const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
Definition: Ddg_Expr_equals.hpp:309
FTensor::Number
Definition: Number.hpp:11
a
constexpr double a
Definition: approx_sphere.cpp:30
R
@ R
Definition: free_surface.cpp:394
FTensor::T4Ddg_equals_generic::u
const U & u
Definition: Ddg_Expr_equals.hpp:305
FTensor::T4Ddg_times_equals_generic::eval
void eval(const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
Definition: Ddg_Expr_equals.hpp:245
MoFEM::L
VectorDouble L
Definition: Projection10NodeCoordsOnField.cpp:124
FTensor::T4Ddg_equals_generic::eval
void eval(const Number< 1 > &, const Number< 1 > &, const Number< 1 > &, const Number< Current_Dim3 > &)
Definition: Ddg_Expr_equals.hpp:336
FTensor::Sign_of_T4ddg_plus_equals_T4ddg< false >
Definition: Ddg_Expr_equals.hpp:115
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::T4Ddg_equals_generic::eval
void eval(const Number< 1 > &, const Number< 1 > &, const Number< 1 > &, const Number< 1 > &)
Definition: Ddg_Expr_equals.hpp:344
FTensor::T4Ddg_times_equals_generic::eval
void eval(const Number< 1 > &, const Number< Current_Dim1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
Definition: Ddg_Expr_equals.hpp:254
FTensor::T4Ddg_times_equals_generic
Definition: Ddg_Expr_equals.hpp:238
FTensor::T4Ddg_equals_generic::T4Ddg_equals_generic
T4Ddg_equals_generic(Ddg< A, Dim01, Dim23 > &a, const U &b)
Definition: Ddg_Expr_equals.hpp:350
Op
Definition: prism_elements_from_surface.cpp:78
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Ddg< A, Tensor_Dim01, Tensor_Dim23 >
FTensor::T4Ddg_equals_generic::iter
Ddg< A, Dim01, Dim23 > & iter
Definition: Ddg_Expr_equals.hpp:304
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
FTensor::T4Ddg_equals_generic::operator()
void operator()()
Definition: Ddg_Expr_equals.hpp:352
FTensor::Sign_of_T4ddg_plus_equals_T4ddg
Definition: Ddg_Expr_equals.hpp:107
FTensor::T4Ddg_times_equals_generic::operator()
void operator()()
Definition: Ddg_Expr_equals.hpp:286
FTensor::T4Ddg_times_equals_generic::eval
void eval(const Number< 1 > &, const Number< 1 > &, const Number< Current_Dim2 > &, const Number< Current_Dim3 > &)
Definition: Ddg_Expr_equals.hpp:262
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21
FTensor::Sign_of_T4ddg_plus_equals_T4ddg< true >
Definition: Ddg_Expr_equals.hpp:109
FTensor::T4Ddg_times_equals_generic::u
const U & u
Definition: Ddg_Expr_equals.hpp:241