v0.14.0
ddTensor1.hpp
Go to the documentation of this file.
1 /* Takes a second derivative of a Tensor1, yielding a Dg, but
2  with it's indices switched around so that it has the symmetries of
3  a Christof. */
4 
5 #pragma once
6 
7 namespace FTensor
8 {
9  template <class T, int Dim0, int Dim12, char i, char j, char k>
10  class ddTensor1
11  {
15 
16  public:
17  /* Note the indices switch here. */
18 
19  typename promote<T, double>::V
20  operator()(const int N2, const int N3, const int N1) const
21  {
22  return N2 == N3 ? (*(a.ptr(N1) + d_ijk(N2)) - 2 * a(N1)
23  + *(a.ptr(N1) - d_ijk(N2)))
24  * d_xyz(N2) * d_xyz(N2)
25  : (*(a.ptr(N1) + d_ijk(N2) + d_ijk(N3))
26  - *(a.ptr(N1) - d_ijk(N2) + d_ijk(N3))
27  - *(a.ptr(N1) + d_ijk(N2) - d_ijk(N3))
28  + *(a.ptr(N1) - d_ijk(N2) - d_ijk(N3)))
29  * d_xyz(N2) * d_xyz(N3) * 0.25;
30  }
32  const Tensor1<double, Dim12> &D_xyz)
33  : a(A), d_ijk(D_ijk), d_xyz(D_xyz)
34  {}
35  };
36 
37  /* Note that the indices are mixed up here to convert between being
38  symmetric on the last two indices to the first two indices. */
39 
40  template <class T, int Dim0, int Dim12, char i, char j, char k>
41  const Dg_Expr<const ddTensor1<T, Dim0, Dim12, i, j, k>,
42  typename promote<T, double>::V, Dim0, Dim12, i, j, k>
43  dd(const Tensor1<T *, Dim0> &a, const Index<k, Dim0> index0,
44  const Index<i, Dim12> index1, const Index<j, Dim12> index2,
45  const Tensor1<int, Dim12> &d_ijk, const Tensor1<double, Dim12> &d_xyz)
46  {
47  using TensorExpr = ddTensor1<T, Dim0, Dim12, i, j, k>;
49  j, k>(TensorExpr(a, d_ijk, d_xyz));
50  }
51 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::ddTensor1::ddTensor1
ddTensor1(const Tensor1< T *, Dim0 > &A, const Tensor1< int, Dim12 > &D_ijk, const Tensor1< double, Dim12 > &D_xyz)
Definition: ddTensor1.hpp:31
FTensor::Tensor1< T *, Dim0 >
FTensor::ddTensor1::d_ijk
const Tensor1< int, Dim12 > & d_ijk
Definition: ddTensor1.hpp:13
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::ddTensor1::operator()
promote< T, double >::V operator()(const int N2, const int N3, const int N1) const
Definition: ddTensor1.hpp:20
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::promote::V
T1 V
Definition: promote.hpp:17
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::Dg_Expr
Definition: Dg_Expr.hpp:25
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::ddTensor1::a
const Tensor1< T *, Dim0 > & a
Definition: ddTensor1.hpp:12
FTensor::ddTensor1::d_xyz
const Tensor1< double, Dim12 > & d_xyz
Definition: ddTensor1.hpp:14
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
FTensor::ddTensor1
Definition: ddTensor1.hpp:10