v0.14.0
diffusion_Tensor2_symmetric.hpp
Go to the documentation of this file.
1 /* Computes 2*del^2 of a Tensor2_symmetric<T*,Dim> but uses diagonal
2  derivatives for half of it. Yields a Tensor2_symmetric. */
3 
4 #pragma once
5 
6 namespace FTensor
7 {
8  template <class T, int Dim, char i, char j> class diffusion_Tensor2_symmetric
9  {
11  const int di, dj, dk;
12  const double dx;
13 
14  public:
15  typename promote<T, double>::V operator()(const int N1, const int N2) const
16  {
17  return ((*(a.ptr(N1, N2) + di) - 2 * a(N1, N2) + *(a.ptr(N1, N2) - di))
18  + (*(a.ptr(N1, N2) + dj) - 2 * a(N1, N2) + *(a.ptr(N1, N2) - dj))
19  + (*(a.ptr(N1, N2) + dk) - 2 * a(N1, N2) + *(a.ptr(N1, N2) - dk))
20  + ((*(a.ptr(N1, N2) + di + dj) + *(a.ptr(N1, N2) + di - dj)
21  + *(a.ptr(N1, N2) - di + dj) + *(a.ptr(N1, N2) - di - dj)
22  - 4 * a(N1, N2))
23  + (*(a.ptr(N1, N2) + di + dk) + *(a.ptr(N1, N2) + di - dk)
24  + *(a.ptr(N1, N2) - di + dk) + *(a.ptr(N1, N2) - di - dk)
25  - 4 * a(N1, N2))
26  + (*(a.ptr(N1, N2) + dj + dk) + *(a.ptr(N1, N2) + dj - dk)
27  + *(a.ptr(N1, N2) - dj + dk) + *(a.ptr(N1, N2) - dj - dk)
28  - 4 * a(N1, N2)))
29  / (std::sqrt(2.0)))
30  * dx * dx;
31  }
33  const int Di, const int Dj, const int Dk,
34  const double Dx)
35  : a(A), di(Di), dj(Dj), dk(Dk), dx(Dx)
36  {}
37  };
38 
39  template <class T, int Dim, char i, char j>
40  const Tensor2_symmetric_Expr<const diffusion_Tensor2_symmetric<T, Dim, i, j>,
41  typename promote<T, double>::V, Dim, i, j>
43  const Index<j, Dim> index2, const int &di, const int &dj,
44  const int &dk, const double &dx)
45  {
48  Dim, i, j>(Tensor_Expr(a, di, dj, dk, dx));
49  }
50 }
FTensor::diffusion_Tensor2_symmetric::di
const int di
Definition: diffusion_Tensor2_symmetric.hpp:11
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::diffusion_Tensor2_symmetric::dx
const double dx
Definition: diffusion_Tensor2_symmetric.hpp:12
FTensor::diffusion_Tensor2_symmetric::dj
const int dj
Definition: diffusion_Tensor2_symmetric.hpp:11
FTensor::Tensor2_symmetric_Expr
Definition: Tensor2_symmetric_Expr.hpp:36
FTensor::diffusion
promote< T, double >::V diffusion(const Tensor0< T * > &a, const int &di, const int &dj, const int &dk, const double &dx)
Definition: diffusion_Tensor0.hpp:10
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::diffusion_Tensor2_symmetric::dk
const int dk
Definition: diffusion_Tensor2_symmetric.hpp:11
FTensor::Tensor2_symmetric< T *, Dim >
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::diffusion_Tensor2_symmetric::diffusion_Tensor2_symmetric
diffusion_Tensor2_symmetric(const Tensor2_symmetric< T *, Dim > &A, const int Di, const int Dj, const int Dk, const double Dx)
Definition: diffusion_Tensor2_symmetric.hpp:32
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::diffusion_Tensor2_symmetric::a
const Tensor2_symmetric< T *, Dim > & a
Definition: diffusion_Tensor2_symmetric.hpp:10
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index
Definition: Index.hpp:23
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::diffusion_Tensor2_symmetric
Definition: diffusion_Tensor2_symmetric.hpp:8
FTensor::diffusion_Tensor2_symmetric::operator()
promote< T, double >::V operator()(const int N1, const int N2) const
Definition: diffusion_Tensor2_symmetric.hpp:15