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  static std::string name() noexcept { return "DirichletAnalytic"; }
47 
48  DirichletAnalytic() = default;
49  DirichletAnalytic(DirichletAnalytic&&) noexcept = default;
50  DirichletAnalytic& operator=(DirichletAnalytic&&) noexcept = default;
51  DirichletAnalytic(const DirichletAnalytic&) = default;
52  DirichletAnalytic& operator=(const DirichletAnalytic&) = default;
53  ~DirichletAnalytic() override = default;
54 
55  explicit DirichletAnalytic(CkMigrateMessage* msg) noexcept;
56 
57  WRAPPED_PUPable_decl_base_template(
59 
60  auto get_clone() const noexcept -> std::unique_ptr<
62 
63  static constexpr evolution::BoundaryConditions::Type bc_type =
64  evolution::BoundaryConditions::Type::Ghost;
65 
66  void pup(PUP::er& p) override;
67 
68  using dg_interior_evolved_variables_tags = tmpl::list<>;
69  using dg_interior_temporary_tags =
70  tmpl::list<domain::Tags::Coordinates<Dim, Frame::Inertial>,
72  using dg_gridless_tags =
73  tmpl::list<::Tags::Time, ::Tags::AnalyticSolutionOrData>;
74 
75  template <typename AnalyticSolutionOrData>
78  const gsl::not_null<tnsr::i<DataVector, Dim, Frame::Inertial>*> phi,
80  const gsl::not_null<Scalar<DataVector>*> gamma2,
81  const std::optional<
82  tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
83  const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/,
84  const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
85  const Scalar<DataVector>& interior_gamma2, const double time,
86  const AnalyticSolutionOrData& analytic_solution_or_data) const noexcept {
87  *gamma2 = interior_gamma2;
88  auto boundary_values = [&analytic_solution_or_data, &coords,
89  &time]() noexcept {
90  if constexpr (std::is_base_of_v<MarkAsAnalyticSolution,
91  AnalyticSolutionOrData>) {
92  return analytic_solution_or_data.variables(
93  coords, time,
95  ScalarWave::Psi>{});
96 
97  } else {
98  (void)time;
99  return analytic_solution_or_data.variables(
100  coords, tmpl::list<ScalarWave::Pi, ScalarWave::Phi<Dim>,
101  ScalarWave::Psi>{});
102  }
103  }();
104  *pi = get<ScalarWave::Pi>(boundary_values);
105  *phi = get<ScalarWave::Phi<Dim>>(boundary_values);
106  *psi = get<ScalarWave::Psi>(boundary_values);
107  return {};
108  }
109 };
110 } // 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 .
std::string
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: ReadSpecThirdOrderPiecewisePolynomial.hpp:13
string