v0.14.0
d_one_sided_Tensor1.hpp
Go to the documentation of this file.
1 /* Takes a one-sided derivative of a Tensor1 in a particular
2  direction, yieldind a Tensor1. */
3 
4 #pragma once
5 
6 namespace FTensor
7 {
8  template <class T, int Dim, char i, int axis> class d_one_sided_Tensor1
9  {
11  const int di, dj, dk;
12  const double dx, dy, dz;
13 
14  public:
15  typename promote<T, double>::V operator()(const int N1) const
16  {
17  return axis == 0 ? (a(N1) - *(a.ptr(N1) - di)) * dx
18  : (axis == 1 ? (a(N1) - *(a.ptr(N1) - dj)) * dy
19  : (a(N1) - *(a.ptr(N1) - dk)) * dz);
20  }
21  d_one_sided_Tensor1(const Tensor1<T *, Dim> &A, const int Di, const int Dj,
22  const int Dk, const double Dx, const double Dy,
23  const double Dz)
24  : a(A), di(Di), dj(Dj), dk(Dk), dx(Dx), dy(Dy), dz(Dz)
25  {}
26  };
27 
28  template <class T, int Dim, char i, int axis>
30  typename promote<T, double>::V, Dim, i>
32  const Index<i, Dim> index1, const int &di, const int &dj,
33  const int &dk, const double &dx, const double &dy,
34  const double &dz)
35  {
36  using TensorExpr = d_one_sided_Tensor1<T, Dim, i, axis>;
38  TensorExpr(a, di, dj, dk, dx, dy, dz));
39  }
40 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor1< T *, Dim >
FTensor::d_one_sided
promote< T, double >::V d_one_sided(const Tensor0< T * > &a, const Number< 0 > n1, const int &di, const int &dj, const int &dk, const double &dx, const double &dy, const double &dz)
Definition: d_one_sided_Tensor0.hpp:10
FTensor::d_one_sided_Tensor1::dj
const int dj
Definition: d_one_sided_Tensor1.hpp:11
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::d_one_sided_Tensor1::operator()
promote< T, double >::V operator()(const int N1) const
Definition: d_one_sided_Tensor1.hpp:15
FTensor::Number
Definition: Number.hpp:11
FTensor::d_one_sided_Tensor1::dz
const double dz
Definition: d_one_sided_Tensor1.hpp:12
FTensor::Tensor1_Expr
Definition: Tensor1_Expr.hpp:27
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::d_one_sided_Tensor1::dk
const int dk
Definition: d_one_sided_Tensor1.hpp:11
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::d_one_sided_Tensor1::dx
const double dx
Definition: d_one_sided_Tensor1.hpp:12
FTensor::Index
Definition: Index.hpp:23
FTensor::d_one_sided_Tensor1::a
const Tensor1< T *, Dim > & a
Definition: d_one_sided_Tensor1.hpp:10
FTensor::d_one_sided_Tensor1::d_one_sided_Tensor1
d_one_sided_Tensor1(const Tensor1< T *, Dim > &A, const int Di, const int Dj, const int Dk, const double Dx, const double Dy, const double Dz)
Definition: d_one_sided_Tensor1.hpp:21
FTensor::d_one_sided_Tensor1::dy
const double dy
Definition: d_one_sided_Tensor1.hpp:12
FTensor::d_one_sided_Tensor1
Definition: d_one_sided_Tensor1.hpp:8
Tensor1_Expr
Definition: single.cpp:11
FTensor::d_one_sided_Tensor1::di
const int di
Definition: d_one_sided_Tensor1.hpp:11