RegularSphericalWave.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 ScalarWave::Solutions::RegularSphericalWave
6 
7 #pragma once
8 
9 #include <cstddef>
10 #include <memory>
11 
12 #include "DataStructures/Tensor/TypeAliases.hpp" // IWYU pragma: keep
13 #include "Options/Options.hpp"
15 #include "Utilities/TMPL.hpp"
17 // IWYU pragma: no_forward_declare Tensor
18 
19 /// \cond
20 class DataVector;
21 namespace ScalarWave {
22 struct Pi;
23 struct Psi;
24 template <size_t Dim>
25 struct Phi;
26 } // namespace ScalarWave
27 namespace Tags {
28 template <typename Tag>
29 struct dt;
30 } // namespace Tags
31 template <size_t VolumeDim>
32 class MathFunction;
33 namespace PUP {
34 class er;
35 } // namespace PUP
36 /// \endcond
37 
38 namespace ScalarWave {
39 namespace Solutions {
40 /*!
41  * \brief A 3D spherical wave solution to the Euclidean wave equation that is
42  * regular at the origin
43  *
44  * The solution is given by \f$\Psi(\vec{x},t) = \Psi(r,t) =
45  * \frac{F(r-t)-F(-r-t)}{r}\f$ describing an outgoing and an ingoing wave
46  * with profile \f$F(u)\f$. For small \f$r\f$ the solution is approximated by
47  * its Taylor expansion \f$\Psi(r,t)=2 F^\prime(-t) + \mathcal{O}(r^2)\f$. The
48  * outgoing and ingoing waves meet at the origin (and cancel each other) when
49  * \f$F^\prime(-t)=0\f$.
50  *
51  * The expansion is employed where \f$r\f$ lies within the cubic root of the
52  * machine epsilon. Inside this radius we expect the error due to the truncation
53  * of the Taylor expansion to be smaller than the numerical error made when
54  * evaluating the full \f$\Psi(r,t)\f$. This is because the truncation error
55  * scales as \f$r^2\f$ (since we keep the zeroth order, and the linear order
56  * vanishes as all odd orders do) and the numerical error scales as
57  * \f$\frac{\epsilon}{r}\f$, so they are comparable at
58  * \f$r\propto\epsilon^\frac{1}{3}\f$.
59  *
60  * \requires the profile \f$F(u)\f$ to have a length scale of order unity so
61  * that "small" \f$r\f$ means \f$r\ll 1\f$. This is without loss of generality
62  * because of the scale invariance of the wave equation. The profile could be a
63  * Gausssian centered at 0 with width 1, for instance.
64  */
66  public:
67  struct Profile {
69  static constexpr OptionString help = {
70  "The radial profile of the spherical wave."};
71  };
72 
73  using options = tmpl::list<Profile>;
74 
75  static constexpr OptionString help = {
76  "A spherical wave solution of the Euclidean wave equation that is "
77  "regular at the origin"};
78 
79  RegularSphericalWave() = default;
80  explicit RegularSphericalWave(
81  std::unique_ptr<MathFunction<1>> profile) noexcept;
82  RegularSphericalWave(const RegularSphericalWave&) noexcept = delete;
83  RegularSphericalWave& operator=(const RegularSphericalWave&) noexcept =
84  delete;
85  RegularSphericalWave(RegularSphericalWave&&) noexcept = default;
86  RegularSphericalWave& operator=(RegularSphericalWave&&) noexcept = default;
87  ~RegularSphericalWave() noexcept = default;
88 
90  variables(const tnsr::I<DataVector, 3>& x, double t,
92  ScalarWave::Psi> /*meta*/) const noexcept;
93 
96  variables(const tnsr::I<DataVector, 3>& x, double t,
98  Tags::dt<ScalarWave::Psi>> /*meta*/) const noexcept;
99 
100  // clang-tidy: no pass by reference
101  void pup(PUP::er& p) noexcept; // NOLINT
102 
103  private:
105 };
106 } // namespace Solutions
107 } // namespace ScalarWave
Definition: Strahlkorper.hpp:14
Defines class tuples::TaggedTuple.
Definition: Tags.hpp:29
Definition: MathFunction.hpp:27
Defines classes and functions for making classes creatable from input files.
Definition: MathFunction.hpp:35
Prefix indicating a time derivative.
Definition: Prefixes.hpp:28
A 3D spherical wave solution to the Euclidean wave equation that is regular at the origin...
Definition: RegularSphericalWave.hpp:65
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
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: RegularSphericalWave.hpp:67
Definition: Tags.hpp:18
Definition: Tags.hpp:23