v0.14.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 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::ddTensor0::operator()
promote< T, double >::V operator()(const int N1, const int N2) const
Definition: ddTensor0.hpp:14
FTensor::Tensor1< int, Dim >
FTensor::Tensor2_symmetric_Expr
Definition: Tensor2_symmetric_Expr.hpp:36
FTensor::ddTensor0
Definition: ddTensor0.hpp:7
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::Tensor0< T * >
Definition: Tensor0.hpp:19
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::ddTensor0::a
const Tensor0< T * > & a
Definition: ddTensor0.hpp:9
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index
Definition: Index.hpp:23
FTensor::dd
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
FTensor::ddTensor0::ddTensor0
ddTensor0(const Tensor0< T * > &A, const Tensor1< int, Dim > &D_ijk, const Tensor1< double, Dim > &D_xyz)
Definition: ddTensor0.hpp:24
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::ddTensor0::d_xyz
const Tensor1< double, Dim > & d_xyz
Definition: ddTensor0.hpp:11
FTensor::ddTensor0::d_ijk
const Tensor1< int, Dim > & d_ijk
Definition: ddTensor0.hpp:10