Lorentzian.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <cstddef>
7
8 #include "DataStructures/DataBox/Prefixes.hpp" // IWYU pragma: keep
9 #include "DataStructures/Tensor/Tensor.hpp" // IWYU pragma: keep
10 #include "Elliptic/Systems/Poisson/Tags.hpp" // IWYU pragma: keep
11 #include "Options/Options.hpp"
12 #include "Utilities/TMPL.hpp"
14
15 /// \cond
16 class DataVector;
17 namespace PUP {
18 class er;
19 } // namespace PUP
20 /// \endcond
21
22 namespace Poisson {
23 namespace Solutions {
24
25 /*!
26  * \brief A Lorentzian solution to the Poisson equation
27  *
28  * \details This implements the Lorentzian solution
29  * \f$u(\boldsymbol{x})=\left(1+r^2\right)^{-\frac{1}{2}}\f$ to the
30  * three-dimensional Poisson equation
31  * \f$-\Delta u(\boldsymbol{x})=f(\boldsymbol{x})\f$, where
32  * \f$r^2=x^2+y^2+z^2\f$. The corresponding source is
33  * \f$f(\boldsymbol{x})=3\left(1+r^2\right)^{-\frac{5}{2}}\f$.
34  *
35  * \note Corresponding 1D and 2D solutions are not implemented yet.
36  */
37 template <size_t Dim>
38 class Lorentzian {
39  static_assert(
40  Dim == 3,
41  "This solution is currently implemented in 3 spatial dimensions only");
42
43  public:
44  using options = tmpl::list<>;
45  static constexpr OptionString help{
46  "A Lorentzian solution to the Poisson equation."};
47
48  Lorentzian() = default;
49  Lorentzian(const Lorentzian&) noexcept = delete;
50  Lorentzian& operator=(const Lorentzian&) noexcept = delete;
51  Lorentzian(Lorentzian&&) noexcept = default;
52  Lorentzian& operator=(Lorentzian&&) noexcept = default;
53  ~Lorentzian() noexcept = default;
54
55  // @{
56  /// Retrieve variable at coordinates x
57  static auto variables(const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
58  tmpl::list<Field> /*meta*/) noexcept
60
61  static auto variables(const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
62  tmpl::list<::Tags::Source<Field>> /*meta*/) noexcept
64
65  static auto variables(
66  const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
67  tmpl::list<::Tags::Source<AuxiliaryField<Dim>>> /*meta*/) noexcept
69  // @}
70
71  /// Retrieve a collection of variables at coordinates x
72  template <typename... Tags>
74  const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
75  tmpl::list<Tags...> /*meta*/) noexcept {
76  static_assert(sizeof...(Tags) > 1,
77  "The generic template will recurse infinitely if only one "
78  "tag is being retrieved.");
79  return {tuples::get<Tags>(variables(x, tmpl::list<Tags>{}))...};
80  }
81
82  // clang-tidy: no pass by reference
83  void pup(PUP::er& p) noexcept; // NOLINT
84 };
85
86 template <size_t Dim>
87 bool operator==(const Lorentzian<Dim>& /*lhs*/,
88  const Lorentzian<Dim>& /*rhs*/) noexcept;
89
90 template <size_t Dim>
91 bool operator!=(const Lorentzian<Dim>& lhs,
92  const Lorentzian<Dim>& rhs) noexcept;
93
94 } // namespace Solutions
95 } // namespace Poisson
Prefix indicating a source term.
Definition: Prefixes.hpp:66
Definition: Strahlkorper.hpp:14
Defines class tuples::TaggedTuple.
The auxiliary field to formulate the first-order Poisson equation .
Definition: Tags.hpp:37
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.
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)
static tuples::TaggedTuple< Tags... > variables(const tnsr::I< DataVector, Dim, Frame::Inertial > &x, tmpl::list< Tags... >) noexcept
Retrieve a collection of variables at coordinates x
Definition: Lorentzian.hpp:73
A Lorentzian solution to the Poisson equation.
Definition: Lorentzian.hpp:38