ProductOfSinusoids.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <array>
7 #include <cstddef>
8 #include <limits>
9
10 #include "DataStructures/DataBox/Prefixes.hpp" // IWYU pragma: keep
11 #include "DataStructures/Tensor/Tensor.hpp" // IWYU pragma: keep
12 #include "Elliptic/Systems/Poisson/Tags.hpp" // IWYU pragma: keep
13 #include "Options/Options.hpp"
14 #include "Utilities/TMPL.hpp"
16
17 /// \cond
18 class DataVector;
19 namespace PUP {
20 class er;
21 } // namespace PUP
22 /// \endcond
23
24 namespace Poisson {
25 namespace Solutions {
26 /*!
27  * \brief A product of sinusoids \f$u(\boldsymbol{x}) = \prod_i \sin(k_i x_i)\f$
28  *
29  * \details Solves the Poisson equation \f$-\Delta u(x)=f(x)\f$ for a source
30  * \f$f(x)=\boldsymbol{k}^2\prod_i \sin(k_i x_i)\f$.
31  */
32 template <size_t Dim>
34  public:
35  struct WaveNumbers {
37  static constexpr OptionString help{"The wave numbers of the sinusoids"};
38  };
39
40  using options = tmpl::list<WaveNumbers>;
41  static constexpr OptionString help{
42  "A product of sinusoids that are taken of a wave number times the "
43  "coordinate in each dimension."};
44
45  ProductOfSinusoids() = default;
46  ProductOfSinusoids(const ProductOfSinusoids&) noexcept = delete;
47  ProductOfSinusoids& operator=(const ProductOfSinusoids&) noexcept = delete;
48  ProductOfSinusoids(ProductOfSinusoids&&) noexcept = default;
49  ProductOfSinusoids& operator=(ProductOfSinusoids&&) noexcept = default;
50  ~ProductOfSinusoids() noexcept = default;
51
52  explicit ProductOfSinusoids(
53  const std::array<double, Dim>& wave_numbers) noexcept;
54
55  // @{
56  /// Retrieve variable at coordinates x
57  auto variables(const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
58  tmpl::list<Field> /*meta*/) const noexcept
60
61  auto variables(const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
62  tmpl::list<AuxiliaryField<Dim>> /*meta*/) const noexcept
64
65  auto variables(const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
66  tmpl::list<::Tags::Source<Field>> /*meta*/) const noexcept
68
69  auto variables(const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
70  tmpl::list<::Tags::Source<AuxiliaryField<Dim>>> /*meta*/) const
72  // @}
73
74  /// Retrieve a collection of variables at coordinates x
75  template <typename... Tags>
77  const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
78  tmpl::list<Tags...> /*meta*/) const noexcept {
79  static_assert(sizeof...(Tags) > 1,
80  "The generic template will recurse infinitely if only one "
81  "tag is being retrieved.");
82  return {tuples::get<Tags>(variables(x, tmpl::list<Tags>{}))...};
83  }
84
85  // clang-tidy: no pass by reference
86  void pup(PUP::er& p) noexcept; // NOLINT
87
88  const std::array<double, Dim>& wave_numbers() const noexcept {
89  return wave_numbers_;
90  }
91
92  private:
93  std::array<double, Dim> wave_numbers_{
95 };
96
97 template <size_t Dim>
98 bool operator==(const ProductOfSinusoids<Dim>& lhs,
99  const ProductOfSinusoids<Dim>& rhs) noexcept {
100  return lhs.wave_numbers() == rhs.wave_numbers();
101 }
102
103 template <size_t Dim>
104 bool operator!=(const ProductOfSinusoids<Dim>& lhs,
105  const ProductOfSinusoids<Dim>& rhs) noexcept {
106  return not(lhs == rhs);
107 }
108
109 } // namespace Solutions
110 } // namespace Poisson
Prefix indicating a source term.
Definition: Prefixes.hpp:66
A product of sinusoids .
Definition: ProductOfSinusoids.hpp:33
Definition: Strahlkorper.hpp:14
Defines class tuples::TaggedTuple.
The auxiliary field to formulate the first-order Poisson equation .
Definition: Tags.hpp:37
T signaling_NaN(T... args)
Defines classes and functions for making classes creatable from input files.
Items related to solving a Poisson equation .
Definition: Actions.hpp:6
Define prefixes for DataBox tags.
Definition: ProductOfSinusoids.hpp:35
tuples::TaggedTuple< Tags... > variables(const tnsr::I< DataVector, Dim, Frame::Inertial > &x, tmpl::list< Tags... >) const noexcept
Retrieve a collection of variables at coordinates x
Definition: ProductOfSinusoids.hpp:76
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:26
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines DataBox tags for the Poisson system.
Definition: DataBoxTag.hpp:29
Defines classes for Tensor.
Stores a collection of function values.
Definition: DataVector.hpp:46
Wraps the template metaprogramming library used (brigand)