Identity.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Defines the class Identity.
6 
7 #pragma once
8 
9 #include <array>
10 #include <boost/optional.hpp>
11 #include <cstddef>
12 
14 #include "Utilities/TypeTraits.hpp"
15 
16 namespace PUP {
17 class er;
18 } // namespace PUP
19 
20 namespace CoordinateMaps {
21 
22 /// \ingroup CoordinateMapsGroup
23 /// Identity map from \f$\xi \rightarrow x\f$.
24 template <size_t Dim>
25 class Identity {
26  public:
27  static constexpr size_t dim = Dim;
28 
29  Identity() = default;
30  ~Identity() = default;
31  Identity(const Identity&) = default;
32  Identity(Identity&&) noexcept = default; // NOLINT
33  Identity& operator=(const Identity&) = default;
34  Identity& operator=(Identity&&) = default;
35 
36  template <typename T>
38  const std::array<T, Dim>& source_coords) const noexcept;
39 
40  boost::optional<std::array<double, Dim>> inverse(
41  const std::array<double, Dim>& target_coords) const noexcept;
42 
43  template <typename T>
44  tnsr::Ij<tt::remove_cvref_wrap_t<T>, Dim, Frame::NoFrame> jacobian(
45  const std::array<T, Dim>& source_coords) const noexcept;
46 
47  template <typename T>
48  tnsr::Ij<tt::remove_cvref_wrap_t<T>, Dim, Frame::NoFrame> inv_jacobian(
49  const std::array<T, Dim>& source_coords) const noexcept;
50 
51  // clang-tidy: google-runtime-references
52  void pup(PUP::er& /*p*/) {} // NOLINT
53 
54  bool is_identity() const noexcept { return true; }
55 };
56 
57 template <size_t Dim>
58 inline constexpr bool operator==(
59  const CoordinateMaps::Identity<Dim>& /*lhs*/,
60  const CoordinateMaps::Identity<Dim>& /*rhs*/) noexcept {
61  return true;
62 }
63 
64 template <size_t Dim>
65 inline constexpr bool operator!=(
67  const CoordinateMaps::Identity<Dim>& rhs) noexcept {
68  return not(lhs == rhs);
69 }
70 } // namespace CoordinateMaps
Definition: Strahlkorper.hpp:14
Identity map from .
Definition: Identity.hpp:25
Contains all coordinate maps.
Definition: Affine.cpp:14
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
Defines type traits, some of which are future STL type_traits header.