v0.14.0
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 
8 #include "Riemann_times_Ddg.hpp"
11 
12 namespace 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 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Riemann_Expr::operator()
T operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Riemann_Expr.hpp:21
Riemann_minus_Riemann.hpp
Riemann_times_Ddg.hpp
FTensor::Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l >::operator()
T operator()(const int N1, const int N2, const int N3, const int N4) const
Definition: Riemann_Expr.hpp:34
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Riemann_Expr::Riemann_Expr
Riemann_Expr(const A &a)
Definition: Riemann_Expr.hpp:20
FTensor::Riemann_Expr::iter
A iter
Definition: Riemann_Expr.hpp:17
Riemann_times_Tensor1.hpp
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Riemann_Expr
Definition: Riemann_Expr.hpp:15
Riemann_plus_Riemann.hpp
FTensor::Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l >::operator=
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)
Definition: Riemann_Expr.hpp:57
Riemann_times_Tensor2_symmetric.hpp
FTensor::Riemann
Definition: Riemann.hpp:10
FTensor::Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l >::operator+=
const Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l > & operator+=(const Riemann_Expr< B, U, Dim, j, i, k, l > &result)
Definition: Riemann_Expr.hpp:79
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l >::Riemann_Expr
Riemann_Expr(Riemann< A, Dim > &a)
Definition: Riemann_Expr.hpp:33
FTensor::Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l >::iter
Riemann< A, Dim > & iter
Definition: Riemann_Expr.hpp:30
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l >::operator=
const Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l > & operator=(const Riemann_Expr< B, U, Dim, i, j, k, l > &result)
Definition: Riemann_Expr.hpp:45
FTensor::Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l >::operator+=
const Riemann_Expr< Riemann< A, Dim >, T, Dim, i, j, k, l > & operator+=(const Riemann_Expr< B, U, Dim, i, j, k, l > &result)
Definition: Riemann_Expr.hpp:63
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21