DirichletAnalytic.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 /// \endcond
33 
35 /*!
36  * \brief Sets Dirichlet boundary conditions using the analytic solution or
37  * analytic data.
38  */
39 template <size_t Dim>
40 class DirichletAnalytic final : public BoundaryCondition<Dim> {
41  public:
42  using options = tmpl::list<>;
43  static constexpr Options::String help{
44  "DirichletAnalytic boundary conditions setting the value of Psi, Phi, "
45  "and Pi to the analytic solution or analytic data."};
46 
47  DirichletAnalytic() = default;
48  DirichletAnalytic(DirichletAnalytic&&) noexcept = default;
49  DirichletAnalytic& operator=(DirichletAnalytic&&) noexcept = default;
50  DirichletAnalytic(const DirichletAnalytic&) = default;
51  DirichletAnalytic& operator=(const DirichletAnalytic&) = default;
52  ~DirichletAnalytic() override = default;
53 
54  explicit DirichletAnalytic(CkMigrateMessage* msg) noexcept;
55 
56  WRAPPED_PUPable_decl_base_template(
58 
59  auto get_clone() const noexcept -> std::unique_ptr<
61 
62  static constexpr evolution::BoundaryConditions::Type bc_type =
63  evolution::BoundaryConditions::Type::Ghost;
64 
65  void pup(PUP::er& p) override;
66 
67  using dg_interior_evolved_variables_tags = tmpl::list<>;
68  using dg_interior_temporary_tags =
69  tmpl::list<domain::Tags::Coordinates<Dim, Frame::Inertial>,
71  using dg_gridless_tags =
72  tmpl::list<::Tags::Time, ::Tags::AnalyticSolutionOrData>;
73 
74  template <typename AnalyticSolutionOrData>
77  const gsl::not_null<tnsr::i<DataVector, Dim, Frame::Inertial>*> phi,
79  const gsl::not_null<Scalar<DataVector>*> gamma2,
80  const std::optional<
81  tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
82  const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/,
83  const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
84  const Scalar<DataVector>& interior_gamma2, const double time,
85  const AnalyticSolutionOrData& analytic_solution_or_data) const noexcept {
86  *gamma2 = interior_gamma2;
87  auto boundary_values = [&analytic_solution_or_data, &coords,
88  &time]() noexcept {
89  if constexpr (std::is_base_of_v<MarkAsAnalyticSolution,
90  AnalyticSolutionOrData>) {
91  return analytic_solution_or_data.variables(
92  coords, time,
94  ScalarWave::Psi>{});
95 
96  } else {
97  (void)time;
98  return analytic_solution_or_data.variables(
99  coords, tmpl::list<ScalarWave::Pi, ScalarWave::Phi<Dim>,
100  ScalarWave::Psi>{});
101  }
102  }();
103  *pi = get<ScalarWave::Pi>(boundary_values);
104  *phi = get<ScalarWave::Phi<Dim>>(boundary_values);
105  *psi = get<ScalarWave::Psi>(boundary_values);
106  return {};
107  }
108 };
109 } // namespace ScalarWave::BoundaryConditions
ScalarWave::Tags::ConstraintGamma2
Definition: Tags.hpp:37
GeneralizedHarmonic::pi
void pi(gsl::not_null< tnsr::aa< DataType, SpatialDim, Frame > * > pi, const Scalar< DataType > &lapse, const Scalar< DataType > &dt_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::I< DataType, SpatialDim, Frame > &dt_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ii< DataType, SpatialDim, Frame > &dt_spatial_metric, const tnsr::iaa< DataType, SpatialDim, Frame > &phi) noexcept
Computes the conjugate momentum of the spacetime metric .
CharmPupable.hpp
domain::BoundaryConditions::BoundaryCondition
Base class from which all system-specific base classes must inherit.
Definition: BoundaryCondition.hpp:18
Options.hpp
ScalarWave::Phi
Definition: Tags.hpp:31
ScalarWave::BoundaryConditions::DirichletAnalytic
Sets Dirichlet boundary conditions using the analytic solution or analytic data.
Definition: DirichletAnalytic.hpp:40
Tags.hpp
ScalarWave::BoundaryConditions::BoundaryCondition
The base class off of which all boundary conditions must inherit.
Definition: BoundaryCondition.hpp:27
ScalarWave::BoundaryConditions
Boundary conditions for the scalar wave system.
Definition: BoundaryCondition.hpp:24
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
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
Tensor.hpp
ScalarWave::Psi
Definition: Tags.hpp:20
optional
std::unique_ptr
Prefixes.hpp
type_traits
ScalarWave::Pi
Definition: Tags.hpp:25
TMPL.hpp
domain::Tags
Tags for the domain.
Definition: FaceNormal.hpp:107
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13
string