v0.14.0
src
ftensor
src
FTensor
Tensor1
dTensor1.hpp
Go to the documentation of this file.
1
/* Takes a derivative of a Tensor1, yielding a Tensor2. */
2
3
// template<class T, int Dim, char i, char j>
4
// class dTensor1
5
// {
6
// const Tensor1<T*,Dim> &a;
7
// const int di,dj,dk;
8
// const double dx,dy,dz;
9
// public:
10
// typename promote<T,double>::V operator()(const int N1, const int N2) const
11
// {
12
// return N2==0 ? (*(a.ptr(N1)+di)-*(a.ptr(N1)-di))*dx*0.5
13
// : (N2==1 ? (*(a.ptr(N1)+dj)-*(a.ptr(N1)-dj))*dy*0.5
14
// : (*(a.ptr(N1)+dk)-*(a.ptr(N1)-dk))*dz*0.5);
15
// }
16
// dTensor1(const Tensor1<T*,Dim> &A,
17
// const int Di, const int Dj, const int Dk,
18
// const double Dx, const double Dy, const double Dz):
19
// a(A), di(Di), dj(Dj), dk(Dk), dx(Dx), dy(Dy), dz(Dz) {}
20
// };
21
22
// template<class T, int Dim, char i, char j>
23
// const Tensor2_Expr<const dTensor1<T,Dim,i,j>,
24
// typename promote<T,double>::V,Dim,3,i,j>
25
// d(const Tensor1<T*,Dim> &a, const Index<i,Dim> index1, const Index<j,3>
26
// index2,
27
// const int &di, const int &dj, const int &dk,
28
// const double &dx, const double &dy, const double &dz)
29
// {
30
// typedef dTensor1<T,Dim,i,j> TensorExpr;
31
// return Tensor2_Expr<TensorExpr,typename promote<T,double>::V,Dim,3,i,j>
32
// (TensorExpr(a,di,dj,dk,dx,dy,dz));
33
// }
34
35
#pragma once
36
37
namespace
FTensor
38
{
39
template
<
class
T,
int
Dim0,
int
Dim1,
char
i,
char
j>
class
dTensor1
40
{
41
const
Tensor1<T *, Dim0>
&
a
;
42
const
Tensor1<int, Dim1>
&
d_ijk
;
43
const
Tensor1<double, Dim1>
&
d_xyz
;
44
45
public
:
46
typename
promote<T, double>::V
operator()
(
const
int
N1,
const
int
N2)
const
47
{
48
return
(*(
a
.ptr(N1) +
d_ijk
(N2)) - *(
a
.ptr(N1) -
d_ijk
(N2))) *
d_xyz
(N2)
49
* 0.5;
50
}
51
dTensor1
(
const
Tensor1<T *, Dim0>
&
A
,
const
Tensor1<int, Dim1>
&D_ijk,
52
const
Tensor1<double, Dim1>
&D_xyz)
53
:
a
(
A
),
d_ijk
(D_ijk),
d_xyz
(D_xyz)
54
{}
55
};
56
57
template
<
class
T,
int
Dim0,
int
Dim1,
char
i,
char
j>
58
const
Tensor2_Expr<const dTensor1<T, Dim0, Dim1, i, j>,
59
typename
promote<T, double>::V
, Dim0, Dim1,
i
,
j
>
60
d
(
const
Tensor1<T *, Dim0>
&
a
,
const
Index<i, Dim0>
index1,
61
const
Index<j, Dim1>
index2,
const
Tensor1<int, Dim1>
&d_ijk,
62
const
Tensor1<double, Dim1>
&d_xyz)
63
{
64
using
TensorExpr =
dTensor1<T, Dim0, Dim1, i, j>
;
65
return
Tensor2_Expr<TensorExpr, typename promote<T, double>::V
, Dim0, Dim1,
66
i
,
j
>(TensorExpr(
a
, d_ijk, d_xyz));
67
}
68
}
FTensor::dTensor1::d_ijk
const Tensor1< int, Dim1 > & d_ijk
Definition:
dTensor1.hpp:42
FTensor
JSON compatible output.
Definition:
Christof_constructor.hpp:6
FTensor::dTensor1::dTensor1
dTensor1(const Tensor1< T *, Dim0 > &A, const Tensor1< int, Dim1 > &D_ijk, const Tensor1< double, Dim1 > &D_xyz)
Definition:
dTensor1.hpp:51
FTensor::Tensor1< T *, Dim0 >
FTensor::dTensor1::d_xyz
const Tensor1< double, Dim1 > & d_xyz
Definition:
dTensor1.hpp:43
FTensor::Tensor2_Expr
Definition:
Tensor2_Expr.hpp:26
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
FTensor::dTensor1::a
const Tensor1< T *, Dim0 > & a
Definition:
dTensor1.hpp:41
A
constexpr AssemblyType A
Definition:
operators_tests.cpp:30
FTensor::dTensor1
Definition:
dTensor1.hpp:39
a
constexpr double a
Definition:
approx_sphere.cpp:30
FTensor::dTensor1::operator()
promote< T, double >::V operator()(const int N1, const int N2) const
Definition:
dTensor1.hpp:46
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
j
FTensor::Index< 'j', 3 > j
Definition:
matrix_function.cpp:19
Generated by
Doxygen
1.8.17 and hosted at