PlaneWave.hpp
Go to the documentation of this file.
2 // See LICENSE.txt for details.
3
4 /// \file
5 /// Defines WaveEquationSolutions::PlaneWave
6
7 #pragma once
8
9 #include <array>
10 #include <cstddef>
11 #include <memory>
12
14 #include "Options/Options.hpp"
15
16 #include "Utilities/MakeArray.hpp"
17 #include "Utilities/TMPL.hpp"
19
20 /// \cond
21 class DataVector;
22 namespace ScalarWave {
23 struct Pi;
24 struct Psi;
25 template <size_t Dim>
26 struct Phi;
27 } // namespace ScalarWave
28 namespace Tags {
29 template <typename Tag>
30 struct dt;
31 } // namespace Tags
32 template <size_t VolumeDim>
33 class MathFunction;
34
35 namespace PUP {
36 class er;
37 } // namespace PUP
38 /// \endcond
39
40 namespace ScalarWave {
41 namespace Solutions {
42 /*!
43  * \brief A plane wave solution to the Euclidean wave equation
44  *
45  * The solution is given by \f$\Psi(\vec{x},t) = F(u(\vec{x},t))\f$
46  * where the profile \f$F\f$ of the plane wave is an arbitrary one-dimensional
47  * function of \f$u = \vec{k} \cdot (\vec{x} - \vec{x_o}) - \omega t\f$
48  * with the wave vector \f$\vec{k}\f$, the frequency \f$\omega = ||\vec{k}||\f$
49  * and initial center of the profile \f$\vec{x_o}\f$.
50  *
51  * \tparam Dim the spatial dimension of the solution
52  */
53 template <size_t Dim>
54 class PlaneWave {
55  public:
56  struct WaveVector {
58  static constexpr OptionString help = {
59  "The direction of propagation of the wave."};
60  };
61
62  struct Center {
64  static constexpr OptionString help = {
65  "The initial center of the profile of the wave."};
66  static type default_value() noexcept { return make_array<Dim>(0.0); }
67  };
68
69  struct Profile {
71  static constexpr OptionString help = {"The profile of the wave."};
72  };
73
74  using options = tmpl::list<WaveVector, Center, Profile>;
75
76  static constexpr OptionString help = {
77  "A plane wave solution of the Euclidean wave equation"};
78
79  PlaneWave() = default;
81  std::unique_ptr<MathFunction<1>> profile) noexcept;
82  PlaneWave(const PlaneWave&) noexcept = delete;
83  PlaneWave& operator=(const PlaneWave&) noexcept = delete;
84  PlaneWave(PlaneWave&&) noexcept = default;
85  PlaneWave& operator=(PlaneWave&&) noexcept = default;
86  ~PlaneWave() noexcept = default;
87
88  /// The value of the scalar field
89  template <typename T>
90  Scalar<T> psi(const tnsr::I<T, Dim>& x, double t) const noexcept;
91
92  /// The time derivative of the scalar field
93  template <typename T>
94  Scalar<T> dpsi_dt(const tnsr::I<T, Dim>& x, double t) const noexcept;
95
96  /// The spatial derivatives of the scalar field
97  template <typename T>
98  tnsr::i<T, Dim> dpsi_dx(const tnsr::I<T, Dim>& x, double t) const noexcept;
99
100  /// The second time derivative of the scalar field
101  template <typename T>
102  Scalar<T> d2psi_dt2(const tnsr::I<T, Dim>& x, double t) const noexcept;
103
104  /// The second mixed derivatives of the scalar field
105  template <typename T>
106  tnsr::i<T, Dim> d2psi_dtdx(const tnsr::I<T, Dim>& x, double t) const noexcept;
107
108  /// The second spatial derivatives of the scalar field
109  template <typename T>
110  tnsr::ii<T, Dim> d2psi_dxdx(const tnsr::I<T, Dim>& x, double t) const
111  noexcept;
112
113  /// Retrieve the evolution variables at time t and spatial coordinates x
115  variables(const tnsr::I<DataVector, Dim>& x, double t,
117  ScalarWave::Psi> /*meta*/) const noexcept;
118
119  /// Retrieve the time derivative of the evolution variables at time t and
120  /// spatial coordinates x
121  ///
122  /// \note This function's expected use case is setting the past time
123  /// derivative values for Adams-Bashforth-like steppers.
126  variables(const tnsr::I<DataVector, Dim>& x, double t,
128  Tags::dt<ScalarWave::Psi>> /*meta*/) const noexcept;
129
130  // clang-tidy: no pass by reference
131  void pup(PUP::er& p) noexcept; // NOLINT
132
133  private:
134  template <typename T>
135  T u(const tnsr::I<T, Dim>& x, double t) const noexcept;
136
137  std::array<double, Dim> wave_vector_{};
138  std::array<double, Dim> center_{};
140  double omega_{};
141 };
142 } // namespace Solutions
143 } // namespace ScalarWave
Definition: Strahlkorper.hpp:14
Defines class tuples::TaggedTuple.
Definition: Tags.hpp:29
A plane wave solution to the Euclidean wave equation.
Definition: PlaneWave.hpp:54
Defines function make_array.
Definition: MathFunction.hpp:27
Defines classes and functions for making classes creatable from input files.
Definition: MathFunction.hpp:35
Definition: PlaneWave.hpp:62
Prefix indicating a time derivative.
Definition: Prefixes.hpp:28
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:27
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines base-class MathFunction.
Items related to evolving the scalar wave equation:
Definition: Equations.cpp:20
Definition: DataBoxTag.hpp:29
Definition: PlaneWave.hpp:69
Defines a list of useful type aliases for tensors.
Stores a collection of function values.
Definition: DataVector.hpp:46
Wraps the template metaprogramming library used (brigand)
Definition: Tags.hpp:18
Definition: Tags.hpp:23
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21