v0.14.0
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 
7 namespace FTensor
8 {
9  template <class T, int Dim, char i> class d_boundary_Tensor0
10  {
11  const Tensor0<T *> &a;
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>
35  d_boundary(const Tensor0<T *> &a, const Index<i, Dim> index,
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 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor1< int, Dim >
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor2< bool, Dim, 2 >
FTensor::d_boundary_Tensor0::a
const Tensor0< T * > & a
Definition: d_boundary_Tensor0.hpp:11
FTensor::Tensor1_Expr
Definition: Tensor1_Expr.hpp:27
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::d_boundary
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)
Definition: d_boundary_Tensor0.hpp:35
FTensor::Tensor0< T * >
Definition: Tensor0.hpp:19
FTensor::d_boundary_Tensor0::d_ijk
const Tensor1< int, Dim > & d_ijk
Definition: d_boundary_Tensor0.hpp:12
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
N
const int N
Definition: speed_test.cpp:3
FTensor::d_boundary_Tensor0::d_boundary_Tensor0
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)
Definition: d_boundary_Tensor0.hpp:25
Tensor1_Expr
Definition: single.cpp:11
FTensor::d_boundary_Tensor0::d_xyz
const Tensor1< double, Dim > & d_xyz
Definition: d_boundary_Tensor0.hpp:13
FTensor::d_boundary_Tensor0::operator()
promote< T, double >::V operator()(const int N) const
Definition: d_boundary_Tensor0.hpp:17
FTensor::d_boundary_Tensor0::boundary
const Tensor2< bool, Dim, 2 > & boundary
Definition: d_boundary_Tensor0.hpp:14
FTensor::d_boundary_Tensor0
Definition: d_boundary_Tensor0.hpp:9