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/GeneralizedHarmonic/BoundaryConditions/BoundaryCondition.hpp"
18 #include "Evolution/Systems/GeneralizedHarmonic/ConstraintDamping/Tags.hpp"
19 #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
20 #include "Options/Options.hpp"
22 #include "PointwiseFunctions/AnalyticData/Tags.hpp"
23 #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
24 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
25 #include "Time/Tags.hpp"
26 #include "Utilities/Gsl.hpp"
27 #include "Utilities/TMPL.hpp"
28 
29 /// \cond
30 namespace domain::Tags {
31 template <size_t Dim, typename Frame>
32 struct Coordinates;
33 } // namespace domain::Tags
34 /// \endcond
35 
37 /*!
38  * \brief Sets Dirichlet boundary conditions using the analytic solution or
39  * analytic data.
40  */
41 template <size_t Dim>
42 class DirichletAnalytic final : public BoundaryCondition<Dim> {
43  public:
44  using options = tmpl::list<>;
45  static constexpr Options::String help{
46  "DirichletAnalytic boundary conditions setting the value of the "
47  "spacetime metric and its derivatives Phi and Pi to the analytic "
48  "solution or analytic data."};
49  static std::string name() noexcept { return "DirichletAnalytic"; }
50 
51  DirichletAnalytic() = default;
52  DirichletAnalytic(DirichletAnalytic&&) noexcept = default;
53  DirichletAnalytic& operator=(DirichletAnalytic&&) noexcept = default;
54  DirichletAnalytic(const DirichletAnalytic&) = default;
55  DirichletAnalytic& operator=(const DirichletAnalytic&) = default;
56  ~DirichletAnalytic() override = default;
57 
58  explicit DirichletAnalytic(CkMigrateMessage* msg) noexcept;
59 
60  WRAPPED_PUPable_decl_base_template(
62 
63  auto get_clone() const noexcept -> std::unique_ptr<
65 
66  static constexpr evolution::BoundaryConditions::Type bc_type =
67  evolution::BoundaryConditions::Type::Ghost;
68 
69  void pup(PUP::er& p) override;
70 
71  using dg_interior_evolved_variables_tags = tmpl::list<>;
72  using dg_interior_temporary_tags = tmpl::list<
76  using dg_gridless_tags =
77  tmpl::list<::Tags::Time, ::Tags::AnalyticSolutionOrData>;
78 
79  template <typename AnalyticSolutionOrData>
81  const gsl::not_null<tnsr::aa<DataVector, Dim, Frame::Inertial>*>
83  const gsl::not_null<tnsr::aa<DataVector, Dim, Frame::Inertial>*> pi,
84  const gsl::not_null<tnsr::iaa<DataVector, Dim, Frame::Inertial>*> phi,
85  const gsl::not_null<Scalar<DataVector>*> gamma1,
86  const gsl::not_null<Scalar<DataVector>*> gamma2,
88  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> shift,
89  const std::optional<
90  tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
91  const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/,
92  const tnsr::I<DataVector, Dim, Frame::Inertial>& /*normal_vector*/,
93  const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
94  const Scalar<DataVector>& interior_gamma1,
95  const Scalar<DataVector>& interior_gamma2, const double time,
96  const AnalyticSolutionOrData& analytic_solution_or_data) const noexcept {
97  *gamma1 = interior_gamma1;
98  *gamma2 = interior_gamma2;
99  auto boundary_values = [&analytic_solution_or_data, &coords,
100  &time]() noexcept {
101  if constexpr (std::is_base_of_v<MarkAsAnalyticSolution,
102  AnalyticSolutionOrData>) {
103  return analytic_solution_or_data.variables(
104  coords, time,
105  tmpl::list<
109 
110  } else {
111  (void)time;
112  return analytic_solution_or_data.variables(
113  coords,
114  tmpl::list<
118  }
119  }();
120 
122  get<gr::Tags::SpacetimeMetric<Dim, Frame::Inertial, DataVector>>(
123  boundary_values);
124  *pi = get<GeneralizedHarmonic::Tags::Pi<Dim, Frame::Inertial>>(
125  boundary_values);
126  *phi = get<GeneralizedHarmonic::Tags::Phi<Dim, Frame::Inertial>>(
127  boundary_values);
128 
129  // Now compute lapse and shift...
130  lapse_and_shift(lapse, shift, *spacetime_metric);
131  return {};
132  }
133 
134  private:
135  void lapse_and_shift(
137  gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> shift,
138  const tnsr::aa<DataVector, Dim, Frame::Inertial>& spacetime_metric)
139  const noexcept;
140 };
141 } // namespace GeneralizedHarmonic::BoundaryConditions
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
domain::Tags::Coordinates< Dim, Frame::Inertial >
Options.hpp
GeneralizedHarmonic::BoundaryConditions
Boundary conditions for the generalized harmonic system.
Definition: BoundaryCondition.hpp:20
gr::lapse
Scalar< DataType > lapse(const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute lapse from shift and spacetime metric.
GeneralizedHarmonic::Tags::Pi
Conjugate momentum to the spacetime metric.
Definition: Tags.hpp:29
gr::Tags::SpacetimeMetric
Definition: Tags.hpp:17
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
GeneralizedHarmonic::ConstraintDamping::Tags::ConstraintGamma2
Constraint dammping parameter for the generalized harmonic system (cf. ).
Definition: Tags.hpp:70
Variables.hpp
gr::shift
tnsr::I< DataType, SpatialDim, Frame > shift(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric, const tnsr::II< DataType, SpatialDim, Frame > &inverse_spatial_metric) noexcept
Compute shift from spacetime metric and inverse spatial metric.
GeneralizedHarmonic::Tags::Phi
Auxiliary variable which is analytically the spatial derivative of the spacetime metric.
Definition: Tags.hpp:40
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
GeneralizedHarmonic::BoundaryConditions::DirichletAnalytic
Sets Dirichlet boundary conditions using the analytic solution or analytic data.
Definition: DirichletAnalytic.hpp:42
gr::spacetime_metric
void spacetime_metric(gsl::not_null< tnsr::aa< DataType, Dim, Frame > * > spacetime_metric, const Scalar< DataType > &lapse, const tnsr::I< DataType, Dim, Frame > &shift, const tnsr::ii< DataType, Dim, Frame > &spatial_metric) noexcept
Computes the spacetime metric from the spatial metric, lapse, and shift.
Tensor.hpp
GeneralizedHarmonic::BoundaryConditions::BoundaryCondition
The base class off of which all boundary conditions must inherit.
Definition: BoundaryCondition.hpp:23
optional
GeneralizedHarmonic::ConstraintDamping::Tags::ConstraintGamma1
Constraint dammping parameter for the generalized harmonic system (cf. ).
Definition: Tags.hpp:62
std::unique_ptr
Prefixes.hpp
type_traits
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