v0.14.0
interpolate_Tensor1.hpp
Go to the documentation of this file.
1 /* Interpolates to (i0+distance[0], j0+distance[1], k0+distance[2])
2  yielding a Tensor1. (i0,j0,k0) are 3D array coordinates,
3  conjugate==1-distance, and (di,dj,dk) are the stride of the array
4  coordinates. It is assumed that the Tensor1<T*,Dim> is zero
5  centered. */
6 
7 #pragma once
8 
9 namespace FTensor
10 {
11  template <class T, int Dim, char i> class interpolate_Tensor1
12  {
14  const int di, dj, dk, i0, j0, k0;
15  const double *distance, *conjugate;
16 
17  public:
18  typename promote<T, double>::V operator()(const int N1) const
19  {
20  return conjugate[0] * conjugate[1] * conjugate[2]
21  * (*(a.ptr(N1) + di * i0 + dj * j0 + dk * k0))
22  + distance[0] * conjugate[1] * conjugate[2]
23  * (*(a.ptr(N1) + di * (i0 + 1) + dj * (j0) + dk * (k0)))
24  + conjugate[0] * distance[1] * conjugate[2]
25  * (*(a.ptr(N1) + di * (i0) + dj * (j0 + 1) + dk * (k0)))
26  + distance[0] * distance[1] * conjugate[2]
27  * (*(a.ptr(N1) + di * (i0 + 1) + dj * (j0 + 1) + dk * (k0)))
28  + conjugate[0] * conjugate[1] * distance[2]
29  * (*(a.ptr(N1) + di * (i0) + dj * (j0) + dk * (k0 + 1)))
30  + distance[0] * conjugate[1] * distance[2]
31  * (*(a.ptr(N1) + di * (i0 + 1) + dj * (j0) + dk * (k0 + 1)))
32  + conjugate[0] * distance[1] * distance[2]
33  * (*(a.ptr(N1) + di * (i0) + dj * (j0 + 1) + dk * (k0 + 1)))
34  + distance[0] * distance[1] * distance[2]
35  * (*(a.ptr(N1) + di * (i0 + 1) + dj * (j0 + 1)
36  + dk * (k0 + 1)));
37  }
38  interpolate_Tensor1(const Tensor1<T *, Dim> &A, const int Di, const int Dj,
39  const int Dk, const int I0, const int J0, const int K0,
40  const double Distance[3], const double Conjugate[3])
41  : a(A), di(Di), dj(Dj), dk(Dk), i0(I0), j0(J0), k0(K0),
42  distance(Distance), conjugate(Conjugate)
43  {}
44  };
45 
46  template <class T, int Dim, char i>
48  typename promote<T, double>::V, Dim, i>
50  const int &di, const int &dj, const int &dk, const int &i0,
51  const int &j0, const int &k0, const double distance[3],
52  const double conjugate[3])
53  {
54  using Tensor_Expr = interpolate_Tensor1<T, Dim, i>;
56  Tensor_Expr(a, di, dj, dk, i0, j0, k0, distance, conjugate));
57  }
58 }
FTensor::interpolate_Tensor1::dj
const int dj
Definition: interpolate_Tensor1.hpp:14
FTensor::interpolate_Tensor1::operator()
promote< T, double >::V operator()(const int N1) const
Definition: interpolate_Tensor1.hpp:18
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor1< T *, Dim >
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::interpolate_Tensor1::di
const int di
Definition: interpolate_Tensor1.hpp:14
FTensor::interpolate_Tensor1::i0
const int i0
Definition: interpolate_Tensor1.hpp:14
FTensor::Tensor1_Expr
Definition: Tensor1_Expr.hpp:27
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::interpolate_Tensor1::j0
const int j0
Definition: interpolate_Tensor1.hpp:14
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::interpolate
promote< T, double >::V interpolate(const Tensor0< T * > &a, const int &di, const int &dj, const int &dk, const int &i0, const int &j0, const int &k0, const double distance[3], const double conjugate[3])
Definition: interpolate_Tensor0.hpp:13
FTensor::interpolate_Tensor1::k0
const int k0
Definition: interpolate_Tensor1.hpp:14
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::interpolate_Tensor1
Definition: interpolate_Tensor1.hpp:11
FTensor::interpolate_Tensor1::conjugate
const double * conjugate
Definition: interpolate_Tensor1.hpp:15
FTensor::Index
Definition: Index.hpp:23
FTensor::interpolate_Tensor1::a
const Tensor1< T *, Dim > & a
Definition: interpolate_Tensor1.hpp:13
Tensor1_Expr
Definition: single.cpp:11
FTensor::interpolate_Tensor1::interpolate_Tensor1
interpolate_Tensor1(const Tensor1< T *, Dim > &A, const int Di, const int Dj, const int Dk, const int I0, const int J0, const int K0, const double Distance[3], const double Conjugate[3])
Definition: interpolate_Tensor1.hpp:38
FTensor::interpolate_Tensor1::dk
const int dk
Definition: interpolate_Tensor1.hpp:14
FTensor::interpolate_Tensor1::distance
const double * distance
Definition: interpolate_Tensor1.hpp:15