v0.16.0
Loading...
Searching...
No Matches
DiffDeviator.hpp
Go to the documentation of this file.
1/**
2 * @file DiffDeviator.hpp
3 *
4 */
5
6#pragma once
7
8namespace FTensor {
9
10/**
11 * @brief Fourth-order differential deviator tensor
12 *
13 * @tparam T
14 * @tparam Dim
15 */
16template <class T = int, int Dim = 3> class DiffDeviator {
17public:
19
20 constexpr value_type operator()(const int N0, const int N1, const int N2,
21 const int N3) const {
22 const auto diff = DiffTensor<T>()(N0, N1, N2, N3);
23 const auto delta_ij = (N0 == N1) ? value_type(1) : value_type(0);
24 const auto delta_kl = (N2 == N3) ? value_type(1) : value_type(0);
25 return diff - (delta_ij * delta_kl) / value_type(3);
26 }
27
28 template <char i, char j, char k, char l, int Dim01, int Dim23>
29 typename std::enable_if<
30 (Dim01 == 3 && Dim23 == Dim),
31 Ddg_Expr<DiffDeviator<T, Dim>, value_type, Dim01, Dim23, i, j, k,
32 l>>::type
33 operator()(const Index<i, Dim01> &, const Index<j, Dim01> &,
34 const Index<k, Dim23> &, const Index<l, Dim23> &) const {
35 return Ddg_Expr<DiffDeviator<T, Dim>, value_type, Dim01, Dim23, i, j, k,
36 l>(*this);
37 };
38};
39
40template <class T = int, int Dim> constexpr auto diff_deviator() {
41 return DiffDeviator<T, Dim>();
42}
43
44template <class T = int, int Dim>
45constexpr auto diff_deviator(const Number<Dim> &) {
46 return DiffDeviator<T, Dim>();
47}
48
49template <class T = int, int Dim, char i, char j, char k, char l, int Dim01,
50 int Dim23>
51typename std::enable_if<
52 (Dim01 == 3 && Dim23 == Dim),
53 Ddg_Expr<DiffDeviator<T, Dim>,
54 typename DiffDeviator<T, Dim>::value_type, Dim01, Dim23, i, j, k,
55 l>>::type
61
62} // namespace FTensor
std::string type
Fourth-order differential deviator tensor.
typename promote< T, double >::V value_type
constexpr value_type operator()(const int N0, const int N1, const int N2, const int N3) const
Fourth-order differential tensor symmetric in both index pairs.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
Tensors class implemented by Walter Landry.
Definition FTensor.hpp:51
constexpr auto diff_deviator()