v0.13.2
Searching...
No Matches
Riemann_Expr.hpp
Go to the documentation of this file.
1/* Declares a wrapper class for rank 4 Tensor expressions with Riemann
2 symmetries. */
3
4#pragma once
5
11
12namespace FTensor
13{
14 template <class A, class T, int Dim, char i, char j, char k, char l>
16 {
18
19 public:
20 Riemann_Expr(const A &a) : iter(a) {}
21 T operator()(const int N1, const int N2, const int N3, const int N4) const
22 {
23 return iter(N1, N2, N3, N4);
24 }
25 };
26
27 template <class A, class T, int Dim, char i, char j, char k, char l>
28 class Riemann_Expr<Riemann<A, Dim>, T, Dim, i, j, k, l>
29 {
31
32 public:
34 T operator()(const int N1, const int N2, const int N3, const int N4) const
35 {
36 return iter.eval(N1, N2, N3, N4);
37 }
38
39 /* Various assignment operators. I have to explicitly declare the
40 second operator= because otherwise the compiler will generate its
41 own and not use the template code. */
42
43 template <class B, class U>
44 const Riemann_Expr<Riemann<A, Dim>, T, Dim, i, j, k, l> &
46 {
47 iter(0, 1, 0, 1) = result(0, 1, 0, 1);
48 iter(0, 1, 0, 2) = result(0, 1, 0, 2);
49 iter(0, 2, 0, 2) = result(0, 2, 0, 2);
50 iter(0, 1, 1, 2) = result(0, 1, 1, 2);
51 iter(0, 2, 1, 2) = result(0, 2, 1, 2);
52 iter(1, 2, 1, 2) = result(1, 2, 1, 2);
53 return *this;
54 }
55
56 const Riemann_Expr<Riemann<A, Dim>, T, Dim, i, j, k, l> &
57 operator=(const Riemann_Expr<Riemann<A, Dim>, T, Dim, i, j, k, l> &result)
58 {
59 return operator=<Riemann<A, Dim>, T>(result);
60 }
61 template <class B, class U>
62 const Riemann_Expr<Riemann<A, Dim>, T, Dim, i, j, k, l> &
64 {
65 iter(0, 1, 0, 1) += result(0, 1, 0, 1);
66 iter(0, 1, 0, 2) += result(0, 1, 0, 2);
67 iter(0, 2, 0, 2) += result(0, 2, 0, 2);
68 iter(0, 1, 1, 2) += result(0, 1, 1, 2);
69 iter(0, 2, 1, 2) += result(0, 2, 1, 2);
70 iter(1, 2, 1, 2) += result(1, 2, 1, 2);
71 return *this;
72 }
73
74 /* Add a Riemann with the indices switched, making it a
75 subtraction. */
76
77 template <class B, class U>
78 const Riemann_Expr<Riemann<A, Dim>, T, Dim, i, j, k, l> &
80 {
81 iter(0, 1, 0, 1) -= result(0, 1, 0, 1);
82 iter(0, 1, 0, 2) -= result(0, 1, 0, 2);
83 iter(0, 2, 0, 2) -= result(0, 2, 0, 2);
84 iter(0, 1, 1, 2) -= result(0, 1, 1, 2);
85 iter(0, 2, 1, 2) -= result(0, 2, 1, 2);
86 iter(1, 2, 1, 2) -= result(1, 2, 1, 2);
87 return *this;
88 }
89 };
90}
static Number< 2 > N2
static Number< 1 > N1
constexpr double a
const Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l > & operator+=(const Riemann_Expr< B, U, Dim, i, j, k, l > &result)
const Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l > & operator=(const Riemann_Expr< B, U, Dim, i, j, k, l > &result)
T operator()(const int N1, const int N2, const int N3, const int N4) const
const Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l > & operator+=(const Riemann_Expr< B, U, Dim, j, i, k, l > &result)
const Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l > & operator=(const Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l > &result)
Riemann_Expr(const A &a)
T operator()(const int N1, const int N2, const int N3, const int N4) const
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
const double T
Tensors class implemented by Walter Landry.
Definition: FTensor.hpp:51
constexpr AssemblyType A