CubicScale.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 #include <boost/optional.hpp>
8 #include <cstddef>
9 #include <limits>
10 #include <string>
11 #include <unordered_map>
12 
14 #include "Utilities/TypeTraits.hpp"
15 /// \cond
16 class FunctionOfTime;
17 namespace PUP {
18 class er;
19 } // namespace PUP
20 /// \endcond
21 
22 namespace domain {
23 namespace CoordMapsTimeDependent {
24 /*!
25  * \ingroup CoordMapsTimeDependentGroup
26  * \brief CubicScale map defined by \f$x = a(t)*\xi+(b(t)-a(t))\xi^3/X^2\f$,
27  * where \f$X\f$ is the outer boundary.
28  *
29  * The map scales the coordinates \f$\xi\f$ near the center by a factor
30  * \f$a(t)\f$, while the coordinates near the outer boundary \f$X\f$, are scaled
31  * by a factor \f$b(t)\f$. Here \f$a(t)\f$ and \f$b(t)\f$ are FunctionsOfTime.
32  *
33  * Currently, only a 1-D implementation.
34  */
35 class CubicScale {
36  public:
37  static constexpr size_t dim = 1;
38 
39  explicit CubicScale(double outer_boundary) noexcept;
40  CubicScale() = default;
41 
42  template <typename T>
44  const std::array<T, 1>& source_coords, double time,
46  noexcept;
47 
48  /// Returns boost::none if the point is outside the range of the map.
49  template <typename T>
50  boost::optional<std::array<tt::remove_cvref_wrap_t<T>, 1>> inverse(
51  const std::array<T, 1>& target_coords, double time,
53  noexcept;
54 
55  template <typename T>
56  std::array<tt::remove_cvref_wrap_t<T>, 1> frame_velocity(
57  const std::array<T, 1>& source_coords, double time,
59  noexcept;
60 
61  template <typename T>
62  tnsr::Ij<tt::remove_cvref_wrap_t<T>, 1, Frame::NoFrame> inv_jacobian(
63  const std::array<T, 1>& source_coords, double time,
65  noexcept;
66 
67  template <typename T>
68  tnsr::Ij<tt::remove_cvref_wrap_t<T>, 1, Frame::NoFrame> jacobian(
69  const std::array<T, 1>& source_coords, double time,
71  noexcept;
72 
73  template <typename T>
74  tnsr::Iaa<tt::remove_cvref_wrap_t<T>, 1, Frame::NoFrame> hessian(
75  const std::array<T, 1>& source_coords, double time,
77  noexcept;
78 
79  // clang-tidy: google-runtime-references
80  void pup(PUP::er& p) noexcept; // NOLINT
81 
82  bool is_identity() const noexcept { return false; }
83 
84  private:
85  friend bool operator==(const CubicScale& lhs, const CubicScale& rhs) noexcept;
86 
87  std::string f_of_t_a_ = "expansion_a";
88  std::string f_of_t_b_ = "expansion_b";
89  double outer_boundary_{std::numeric_limits<double>::signaling_NaN()};
90 };
91 
92 inline bool operator!=(const CoordMapsTimeDependent::CubicScale& lhs,
93  const CoordMapsTimeDependent::CubicScale& rhs) noexcept {
94  return not(lhs == rhs);
95 }
96 
97 } // namespace CoordMapsTimeDependent
98 } // namespace domain
Definition: Strahlkorper.hpp:14
Definition: BlockId.hpp:16
T signaling_NaN(T... args)
Defines a list of useful type aliases for tensors.
Represents an index that is not in a known frame, e.g. some internal intermediate frame that is irrel...
Definition: IndexType.hpp:48
Base class for FunctionsOfTime.
Definition: FunctionOfTime.hpp:13
Defines type traits, some of which are future STL type_traits header.
CubicScale map defined by , where is the outer boundary.
Definition: CubicScale.hpp:35