v0.9.0
ddTensor0.hpp
Go to the documentation of this file.
1 /* Takes a second derivative of a Tensor0 yielding a Tensor2_symmetric. */
2 
3 #pragma once
4 
5 namespace FTensor
6 {
7  template <class T, int Dim, char i, char j> class ddTensor0
8  {
9  const Tensor0<T *> &a;
12 
13  public:
14  typename promote<T, double>::V operator()(const int N1, const int N2) const
15  {
16  return N1 == N2
17  ? (*(&a + d_ijk(N1)) - 2 * a + *(&a - d_ijk(N1))) * d_xyz(N1)
18  * d_xyz(N1)
19  : (*(&a + d_ijk(N1) + d_ijk(N2)) - *(&a - d_ijk(N1) + d_ijk(N2))
20  - *(&a + d_ijk(N1) - d_ijk(N2))
21  + *(&a - d_ijk(N1) - d_ijk(N2)))
22  * d_xyz(N1) * d_xyz(N2) * 0.25;
23  }
24  ddTensor0(const Tensor0<T *> &A, const Tensor1<int, Dim> &D_ijk,
25  const Tensor1<double, Dim> &D_xyz)
26  : a(A), d_ijk(D_ijk), d_xyz(D_xyz)
27  {}
28  };
29 
30  template <class T, int Dim, char i, char j>
31  const Tensor2_symmetric_Expr<const ddTensor0<T, Dim, i, j>,
32  typename promote<T, double>::V, Dim, i, j>
33  dd(const Tensor0<T *> &a, const Index<i, Dim> index1,
34  const Index<j, Dim> index2, const Tensor1<int, Dim> &d_ijk,
35  const Tensor1<double, Dim> &d_xyz)
36  {
37  using Tensor_Expr = ddTensor0<T, Dim, i, j>;
39  Dim, i, j>(Tensor_Expr(a, d_ijk, d_xyz));
40  }
41 }
ddTensor0(const Tensor0< T * > &A, const Tensor1< int, Dim > &D_ijk, const Tensor1< double, Dim > &D_xyz)
Definition: ddTensor0.hpp:24
const Tensor1< double, Dim > & d_xyz
Definition: ddTensor0.hpp:11
Fully Antisymmetric Levi-Civita Tensor.
const Tensor1< int, Dim > & d_ijk
Definition: ddTensor0.hpp:10
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
const Tensor0< T * > & a
Definition: ddTensor0.hpp:9
promote< T, double >::V operator()(const int N1, const int N2) const
Definition: ddTensor0.hpp:14