Line data Source code
1 1 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : /// \file
5 : /// Defines a tensor product of one-dimensional MathFunctions
6 :
7 : #pragma once
8 :
9 : #include <array>
10 : #include <cstddef>
11 : #include <memory>
12 :
13 : #include "DataStructures/Tensor/TypeAliases.hpp"
14 : #include "PointwiseFunctions/MathFunctions/MathFunction.hpp"
15 :
16 : namespace MathFunctions {
17 :
18 : /// \ingroup MathFunctionsGroup
19 : /// \brief a tensor product of one-dimensional MathFunctions
20 : template <size_t Dim>
21 1 : class TensorProduct {
22 : public:
23 0 : TensorProduct(double scale,
24 : std::array<std::unique_ptr<MathFunction<1, Frame::Inertial>>,
25 : Dim>&& functions);
26 0 : TensorProduct() = default;
27 0 : TensorProduct(const TensorProduct& other);
28 0 : TensorProduct(TensorProduct&&) = default;
29 0 : TensorProduct& operator=(const TensorProduct& other);
30 0 : TensorProduct& operator=(TensorProduct&&) = default;
31 0 : ~TensorProduct() = default;
32 :
33 : /// The value of the function
34 : template <typename T>
35 1 : Scalar<T> operator()(const tnsr::I<T, Dim>& x) const;
36 :
37 : /// The partial derivatives of the function
38 : template <typename T>
39 1 : tnsr::i<T, Dim> first_derivatives(const tnsr::I<T, Dim>& x) const;
40 :
41 : /// The second partial derivatives of the function
42 : template <typename T>
43 1 : tnsr::ii<T, Dim> second_derivatives(const tnsr::I<T, Dim>& x) const;
44 :
45 : private:
46 : template <size_t LocalDim>
47 : // NOLINTNEXTLINE(readability-redundant-declaration)
48 0 : friend bool operator==(const TensorProduct<LocalDim>& lhs,
49 : const TensorProduct<LocalDim>& rhs);
50 : template <size_t LocalDim>
51 : // NOLINTNEXTLINE(readability-redundant-declaration)
52 0 : friend bool operator!=(const TensorProduct<LocalDim>& lhs,
53 : const TensorProduct<LocalDim>& rhs);
54 0 : double scale_{1.0};
55 0 : std::array<std::unique_ptr<MathFunction<1, Frame::Inertial>>, Dim> functions_;
56 : };
57 : } // namespace MathFunctions
|