SphericalRadiation.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <memory>
7 #include <optional>
8 #include <pup.h>
9 #include <string>
10 #include <type_traits>
11 
13 #include "DataStructures/DataVector.hpp"
16 #include "Evolution/BoundaryConditions/Type.hpp"
17 #include "Evolution/Systems/ScalarWave/BoundaryConditions/BoundaryCondition.hpp"
19 #include "Options/Options.hpp"
21 #include "PointwiseFunctions/AnalyticData/Tags.hpp"
22 #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
23 #include "Time/Tags.hpp"
24 #include "Utilities/Gsl.hpp"
25 #include "Utilities/TMPL.hpp"
26 
27 /// \cond
28 namespace domain::Tags {
29 template <size_t Dim, typename Frame>
30 struct Coordinates;
31 } // namespace domain::Tags
32 namespace Options {
33 template <typename T>
34 struct create_from_yaml;
35 } // namespace Options
36 /// \endcond
37 
39 namespace detail {
40 /// The type of spherical radiation boundary condition to impose
41 enum class SphericalRadiationType {
42  /// Impose \f$(\partial_t + \partial_r)\Psi=0\f$
43  Sommerfeld,
44  /// Impose \f$(\partial_t + \partial_r + r^{-1})\Psi=0\f$
45  BaylissTurkel
46 };
47 
48 SphericalRadiationType convert_spherical_radiation_type_from_yaml(
49  const Options::Option& options);
50 } // namespace detail
51 
52 /*!
53  * \brief Impose spherical radiation boundary conditions.
54  *
55  * These can be imposed in one of two forms:
56  *
57  * \f{align*}{
58  * \Pi=\partial_r\Psi,
59  * \f}
60  *
61  * referred to as a Sommerfeld condition, or
62  *
63  * \f{align*}{
64  * \Pi=\partial_r\Psi + \frac{1}{r}\Psi
65  * \f}
66  *
67  * referred to as a Bayliss-Turkel condition.
68  *
69  * The Bayliss-Turkel condition produces fewer reflections than the Sommerfeld
70  * condition.
71  *
72  * \warning These are implemented assuming the outer boundary is spherical and
73  * centered at the origin of the radiation because the code sets
74  * \f$\Pi=n^i\Phi_i\f$, where \f$n^i\f$ is the outward pointing unit normal
75  * vector. It might be possible to generalize the condition to non-spherical
76  * boundaries by using \f$x^i/r\f$ instead of \f$n^i\f$, but this hasn't been
77  * tested.
78  */
79 template <size_t Dim>
80 class SphericalRadiation final : public BoundaryCondition<Dim> {
81  public:
82  struct TypeOptionTag {
83  using type = detail::SphericalRadiationType;
84  static std::string name() noexcept { return "Type"; }
85  static constexpr Options::String help{
86  "Whether to impose Sommerfeld or first-order Bayliss-Turkel spherical "
87  "radiation boundary conditions."};
88  };
89 
90  using options = tmpl::list<TypeOptionTag>;
91  static constexpr Options::String help{
92  "Spherical radiation boundary conditions setting the value of Psi, Phi, "
93  "and Pi either using the Sommerfeld or first-order Bayliss-Turkel "
94  "method."};
95 
96  SphericalRadiation() = default;
97  SphericalRadiation(detail::SphericalRadiationType type) noexcept;
98  SphericalRadiation(SphericalRadiation&&) noexcept = default;
99  SphericalRadiation& operator=(SphericalRadiation&&) noexcept = default;
100  SphericalRadiation(const SphericalRadiation&) = default;
101  SphericalRadiation& operator=(const SphericalRadiation&) = default;
102  ~SphericalRadiation() override = default;
103 
104  explicit SphericalRadiation(CkMigrateMessage* msg) noexcept;
105 
106  WRAPPED_PUPable_decl_base_template(
107  domain::BoundaryConditions::BoundaryCondition, SphericalRadiation);
108 
109  auto get_clone() const noexcept -> std::unique_ptr<
110  domain::BoundaryConditions::BoundaryCondition> override;
111 
112  static constexpr evolution::BoundaryConditions::Type bc_type =
113  evolution::BoundaryConditions::Type::Ghost;
114 
115  void pup(PUP::er& p) override;
116 
117  using dg_interior_evolved_variables_tags = tmpl::list<Phi<Dim>, Psi>;
118  using dg_interior_temporary_tags =
119  tmpl::list<domain::Tags::Coordinates<Dim, Frame::Inertial>,
120  Tags::ConstraintGamma2>;
121  using dg_gridless_tags = tmpl::list<>;
122 
123  std::optional<std::string> dg_ghost(
124  gsl::not_null<Scalar<DataVector>*> pi_ext,
125  gsl::not_null<tnsr::i<DataVector, Dim, Frame::Inertial>*> phi_ext,
126  gsl::not_null<Scalar<DataVector>*> psi_ext,
127  gsl::not_null<Scalar<DataVector>*> gamma2_ext,
128  const std::optional<
129  tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
130  const tnsr::i<DataVector, Dim, Frame::Inertial>& normal_covector,
131  const tnsr::i<DataVector, Dim, Frame::Inertial>& phi,
132  const Scalar<DataVector>& psi,
133  const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
134  const Scalar<DataVector>& gamma2) const noexcept;
135 
136  private:
137  detail::SphericalRadiationType type_{
138  detail::SphericalRadiationType::Sommerfeld};
139 };
140 } // namespace ScalarWave::BoundaryConditions
141 
142 template <>
144  ScalarWave::BoundaryConditions::detail::SphericalRadiationType> {
145  template <typename Metavariables>
146  static typename ScalarWave::BoundaryConditions::detail::SphericalRadiationType
147  create(const Options::Option& options) {
148  return ScalarWave::BoundaryConditions::detail::
149  convert_spherical_radiation_type_from_yaml(options);
150  }
151 };
std::string
CharmPupable.hpp
evolution
Functionality for evolving hyperbolic partial differential equations.
Definition: RunEventsAndDenseTriggers.hpp:30
Options.hpp
ScalarWave::Phi
Definition: Tags.hpp:31
Tags.hpp
Options::Option
Definition: Options.hpp:108
ScalarWave::BoundaryConditions::SphericalRadiation
Impose spherical radiation boundary conditions.
Definition: SphericalRadiation.hpp:80
ScalarWave::BoundaryConditions::BoundaryCondition
The base class off of which all boundary conditions must inherit.
Definition: BoundaryCondition.hpp:27
Options
Utilities for parsing input files.
Definition: MinmodType.hpp:8
ScalarWave::BoundaryConditions::SphericalRadiation::TypeOptionTag
Definition: SphericalRadiation.hpp:82
Options::create_from_yaml
Definition: MinmodType.hpp:11
ScalarWave::BoundaryConditions
Boundary conditions for the scalar wave system.
Definition: BoundaryCondition.hpp:24
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
GeneralizedHarmonic::phi
void phi(gsl::not_null< tnsr::iaa< DataType, SpatialDim, Frame > * > phi, const Scalar< DataType > &lapse, const tnsr::i< DataType, SpatialDim, Frame > &deriv_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::iJ< DataType, SpatialDim, Frame > &deriv_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ijj< DataType, SpatialDim, Frame > &deriv_spatial_metric) noexcept
Computes the auxiliary variable used by the generalized harmonic formulation of Einstein's equations...
memory
Variables.hpp
tnsr
Type aliases to construct common Tensors.
Definition: TypeAliases.hpp:31
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
Gsl.hpp
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Frame
Definition: IndexType.hpp:36
Tensor.hpp
ScalarWave
Items related to evolving the scalar wave equation.
Definition: BoundaryCondition.hpp:24
ScalarWave::Psi
Definition: Tags.hpp:20
optional
Prefixes.hpp
gsl
Implementations from the Guideline Support Library.
Definition: ReadSpecPiecewisePolynomial.hpp:11
type_traits
TMPL.hpp
domain::Tags
Tags for the domain.
Definition: FaceNormal.hpp:107
string