v0.14.0
dTensor0.hpp
Go to the documentation of this file.
1 /* Takes a derivative of a Tensor0<T*> yielding a Tensor1. */
2 
3 #pragma once
4 
5 namespace FTensor
6 {
7  template <class T, int Dim, char i> class dTensor0
8  {
9  const Tensor0<T *> &a;
12 
13  public:
14  typename promote<T, double>::V operator()(const int N) const
15  {
16  return (*(&a + d_ijk(N)) - *(&a - d_ijk(N))) * d_xyz(N) * 0.5;
17  }
18  dTensor0(const Tensor0<T *> &A, const Tensor1<int, Dim> &D_ijk,
19  const Tensor1<double, Dim> &D_xyz)
20  : a(A), d_ijk(D_ijk), d_xyz(D_xyz)
21  {}
22  };
23 
24  template <class T, int Dim, char i>
26  Dim, i>
27  d(const Tensor0<T *> &a, const Index<i, Dim> index,
28  const Tensor1<int, Dim> &d_ijk, const Tensor1<double, Dim> &d_xyz)
29  {
30  using Tensor_Expr = dTensor0<T, Dim, i>;
32  Tensor_Expr(a, d_ijk, d_xyz));
33  }
34 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::dTensor0::dTensor0
dTensor0(const Tensor0< T * > &A, const Tensor1< int, Dim > &D_ijk, const Tensor1< double, Dim > &D_xyz)
Definition: dTensor0.hpp:18
FTensor::Tensor1< int, Dim >
FTensor::dTensor0::d_ijk
const Tensor1< int, Dim > & d_ijk
Definition: dTensor0.hpp:10
FTensor::d
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: dTensor0.hpp:27
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::dTensor0::operator()
promote< T, double >::V operator()(const int N) const
Definition: dTensor0.hpp:14
FTensor::Tensor1_Expr
Definition: Tensor1_Expr.hpp:27
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::dTensor0::a
const Tensor0< T * > & a
Definition: dTensor0.hpp:9
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::dTensor0
Definition: dTensor0.hpp:7
FTensor::Index
Definition: Index.hpp:23
N
const int N
Definition: speed_test.cpp:3
FTensor::dTensor0::d_xyz
const Tensor1< double, Dim > & d_xyz
Definition: dTensor0.hpp:11
Tensor1_Expr
Definition: single.cpp:11