v0.14.0
Loading...
Searching...
No Matches
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
22namespace 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>
60 operator=(const Dg_Expr<B, U, Dim01, Dim2, i, j, k> &result);
61
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>
68 operator+=(const Dg_Expr<B, U, Dim01, Dim2, i, j, k> &result);
69
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>
76 operator-=(const Dg_Expr<B, U, Dim01, Dim2, i, j, k> &result);
77
79 operator-=(const Dg_Expr<Dg<A, Tensor_Dim01, Tensor_Dim2>, T, Dim01, Dim2,
80 i, j, k> &result);
81
82 template <class U>
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>
133
136 Dim0, i, j, k> &result);
137
138 template <class B, class U>
141
144 Dim0, i, j, k> &result);
145
146 template <class B, class U>
149
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 {
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> &
186
187 Dg_Expr<Ddg_number_rhs_0<A, T, N0>, T, Dim23, Dim1, i, j, k> &
189 k> &result);
190 };
191}
192
193#include "Dg_Expr_equals.hpp"
static Number< 2 > N2
static Number< 1 > N1
static Number< 0 > N0
constexpr double a
Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k > & operator-=(const Dg_Expr< B, U, Dim12, Dim0, i, j, k > &result)
Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k > & operator-=(const Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k > &result)
Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k > & operator+=(const Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k > &result)
Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k > & operator+=(const Dg_Expr< B, U, Dim12, Dim0, i, j, k > &result)
Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k > & operator=(const Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k > &result)
Dg_Expr< Christof< A, Tensor_Dim0, Tensor_Dim12 >, T, Dim12, Dim0, i, j, k > & operator=(const Dg_Expr< B, U, Dim12, Dim0, i, j, k > &result)
Dg_Expr< Ddg_number_rhs_0< A, T, N0 >, T, Dim23, Dim1, i, j, k > & operator=(const Dg_Expr< B, U, Dim23, Dim1, i, j, k > &result)
T operator()(const int N1, const int N2, const int N3) const
Definition: Dg_Expr.hpp:174
T & operator()(const int N1, const int N2, const int N3)
Definition: Dg_Expr.hpp:170
Dg_Expr< Ddg_number_rhs_0< A, T, N0 >, T, Dim23, Dim1, i, j, k > & operator=(const Dg_Expr< Ddg_number_rhs_0< A, T, N0 >, T, Dim23, Dim1, i, j, k > &result)
T operator()(const int N1, const int N2, const int N3) const
Definition: Dg_Expr.hpp:49
T operator()(const int N1, const int N2, const int N3) const
Definition: Dg_Expr.hpp:31
Dg_Expr(const A &a)
Definition: Dg_Expr.hpp:30
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
const double T
Tensors class implemented by Walter Landry.
Definition: FTensor.hpp:51
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
constexpr AssemblyType A