v0.14.0
Loading...
Searching...
No Matches
d_boundary_Tensor0.hpp
Go to the documentation of this file.
1/* Takes a derivative of a Tensor0<T*> yielding a Tensor1. It checks
2 whether we're at a boundary, and takes a one-sided derivative
3 there. */
4
5#pragma once
6
7namespace FTensor
8{
9 template <class T, int Dim, char i> class d_boundary_Tensor0
10 {
15
16 public:
17 typename promote<T, double>::V operator()(const int N) const
18 {
19 return boundary(N, 0)
20 ? (*(&a + d_ijk(N)) - a) * d_xyz(N)
21 : (boundary(N, 1)
22 ? (a - *(&a - d_ijk(N))) * d_xyz(N)
23 : (*(&a + d_ijk(N)) - *(&a - d_ijk(N))) * d_xyz(N) * 0.5);
24 }
26 const Tensor1<double, Dim> &D_xyz,
27 const Tensor2<bool, Dim, 2> &Boundary)
28 : a(A), d_ijk(D_ijk), d_xyz(D_xyz), boundary(Boundary)
29 {}
30 };
31
32 template <class T, int Dim, char i>
34 typename promote<T, double>::V, Dim, i>
36 const Tensor1<int, Dim> &d_ijk, const Tensor1<double, Dim> &d_xyz,
37 const Tensor2<bool, Dim, 2> &boundary)
38 {
39 using Tensor_Expr = d_boundary_Tensor0<T, Dim, i>;
41 Tensor_Expr(a, d_ijk, d_xyz, boundary));
42 }
43}
constexpr double a
const Tensor1< double, Dim > & d_xyz
promote< T, double >::V operator()(const int N) const
const Tensor1< int, Dim > & d_ijk
const Tensor2< bool, Dim, 2 > & boundary
d_boundary_Tensor0(const Tensor0< T * > &A, const Tensor1< int, Dim > &D_ijk, const Tensor1< double, Dim > &D_xyz, const Tensor2< bool, Dim, 2 > &Boundary)
FTensor::Index< 'i', SPACE_DIM > i
Tensors class implemented by Walter Landry.
Definition FTensor.hpp:51
const Tensor1_Expr< const d_boundary_Tensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d_boundary(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz, const Tensor2< bool, Dim, 2 > &boundary)
const int N
Definition speed_test.cpp:3