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/RelativisticEuler/Valencia/BoundaryConditions/BoundaryCondition.hpp"
18 #include "Evolution/Systems/RelativisticEuler/Valencia/ConservativeFromPrimitive.hpp"
19 #include "Evolution/Systems/RelativisticEuler/Valencia/Fluxes.hpp"
20 #include "Evolution/Systems/RelativisticEuler/Valencia/Tags.hpp"
21 #include "Options/Options.hpp"
23 #include "PointwiseFunctions/AnalyticData/Tags.hpp"
24 #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.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 using either analytic solution or "
47  "analytic data."};
48  static std::string name() noexcept { return "DirichletAnalytic"; }
49 
50  DirichletAnalytic() = default;
51  DirichletAnalytic(DirichletAnalytic&&) noexcept = default;
52  DirichletAnalytic& operator=(DirichletAnalytic&&) noexcept = default;
53  DirichletAnalytic(const DirichletAnalytic&) = default;
54  DirichletAnalytic& operator=(const DirichletAnalytic&) = default;
55  ~DirichletAnalytic() override = default;
56 
57  explicit DirichletAnalytic(CkMigrateMessage* msg) noexcept;
58 
59  WRAPPED_PUPable_decl_base_template(
61 
62  auto get_clone() const noexcept -> std::unique_ptr<
64 
65  static constexpr evolution::BoundaryConditions::Type bc_type =
66  evolution::BoundaryConditions::Type::Ghost;
67 
68  void pup(PUP::er& p) override;
69 
70  using dg_interior_evolved_variables_tags = tmpl::list<>;
71  using dg_interior_temporary_tags =
72  tmpl::list<domain::Tags::Coordinates<Dim, Frame::Inertial>>;
73  using dg_interior_primitive_variables_tags = tmpl::list<>;
74  using dg_gridless_tags =
75  tmpl::list<::Tags::Time, ::Tags::AnalyticSolutionOrData>;
76 
77  template <typename AnalyticSolutionOrData>
79  const gsl::not_null<Scalar<DataVector>*> tilde_d,
80  const gsl::not_null<Scalar<DataVector>*> tilde_tau,
81  const gsl::not_null<tnsr::i<DataVector, Dim, Frame::Inertial>*> tilde_s,
82 
83  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
84  flux_tilde_d,
85  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
86  flux_tilde_tau,
87  const gsl::not_null<tnsr::Ij<DataVector, Dim, Frame::Inertial>*>
88  flux_tilde_s,
89 
91  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> shift,
92  const gsl::not_null<tnsr::ii<DataVector, Dim, Frame::Inertial>*>
94  const gsl::not_null<Scalar<DataVector>*> rest_mass_density,
95  const gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
96  const gsl::not_null<Scalar<DataVector>*> specific_enthalpy,
97  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
98  spatial_velocity,
99 
100  const std::optional<
101  tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
102  const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/,
103  const tnsr::I<DataVector, Dim, Frame::Inertial>& /*normal_vector*/,
104  const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
105  const double time,
106  const AnalyticSolutionOrData& analytic_solution_or_data) const noexcept {
107  auto boundary_values = [&analytic_solution_or_data, &coords,
108  &time]() noexcept {
109  if constexpr (std::is_base_of_v<MarkAsAnalyticSolution,
110  AnalyticSolutionOrData>) {
111  return analytic_solution_or_data.variables(
112  coords, time,
121  } else {
122  (void)time;
123  return analytic_solution_or_data.variables(
124  coords,
133  }
134  }();
135 
136  *lapse = get<gr::Tags::Lapse<>>(boundary_values);
137  *shift = get<gr::Tags::Shift<Dim>>(boundary_values);
138  *spatial_metric = get<gr::Tags::SpatialMetric<Dim>>(boundary_values);
139  *rest_mass_density =
140  get<hydro::Tags::RestMassDensity<DataVector>>(boundary_values);
141  *specific_internal_energy =
142  get<hydro::Tags::SpecificInternalEnergy<DataVector>>(boundary_values);
143  *specific_enthalpy =
144  get<hydro::Tags::SpecificEnthalpy<DataVector>>(boundary_values);
145  *spatial_velocity =
146  get<hydro::Tags::SpatialVelocity<DataVector, Dim>>(boundary_values);
147 
148  const auto& pressure =
149  get<hydro::Tags::Pressure<DataVector>>(boundary_values);
150  const auto& lorentz_factor =
151  get<hydro::Tags::LorentzFactor<DataVector>>(boundary_values);
152  const auto& sqrt_det_spatial_metric =
153  get<gr::Tags::SqrtDetSpatialMetric<>>(boundary_values);
154 
156  tilde_d, tilde_tau, tilde_s, *rest_mass_density,
157  *specific_internal_energy, *specific_enthalpy, pressure,
158  *spatial_velocity, lorentz_factor, sqrt_det_spatial_metric,
159  *spatial_metric);
160  ComputeFluxes<Dim>::apply(flux_tilde_d, flux_tilde_tau, flux_tilde_s,
161  *tilde_d, *tilde_tau, *tilde_s, *lapse, *shift,
162  sqrt_det_spatial_metric, pressure,
163  *spatial_velocity);
164 
165  return {};
166  }
167 };
168 } // namespace RelativisticEuler::Valencia::BoundaryConditions
hydro::Tags::Pressure
The fluid pressure .
Definition: Tags.hpp:119
std::string
CharmPupable.hpp
domain::BoundaryConditions::BoundaryCondition
Base class from which all system-specific base classes must inherit.
Definition: BoundaryCondition.hpp:18
hydro::Tags::SpecificInternalEnergy
The specific internal energy .
Definition: Tags.hpp:173
gr::Tags::SpatialMetric
Definition: Tags.hpp:26
Options.hpp
RelativisticEuler::Valencia::BoundaryConditions
Boundary conditions for the relativistic Euler 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.
hydro::Tags::LorentzFactor
The Lorentz factor , where is the spatial velocity of the fluid.
Definition: Tags.hpp:64
hydro::Tags::SpecificEnthalpy
The relativistic specific enthalpy .
Definition: Tags.hpp:167
RelativisticEuler::Valencia::ConservativeFromPrimitive
Compute the conservative variables from primitive variables.
Definition: ConservativeFromPrimitive.hpp:50
memory
gr::Tags::Shift
Definition: Tags.hpp:48
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.
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
RelativisticEuler::Valencia::ComputeFluxes
The fluxes of the conservative variables.
Definition: Fluxes.hpp:47
Gsl.hpp
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
hydro::Tags::SpatialVelocity
The spatial velocity of the fluid, where . Here is the spatial part of the 4-velocity of the fluid,...
Definition: Tags.hpp:142
Tensor.hpp
gr::spatial_metric
tnsr::ii< DataType, SpatialDim, Frame > spatial_metric(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute spatial metric from spacetime metric.
optional
std::unique_ptr
Prefixes.hpp
type_traits
gr::Tags::Lapse
Definition: Tags.hpp:52
TMPL.hpp
domain::Tags
Tags for the domain.
Definition: FaceNormal.hpp:107
RelativisticEuler::Valencia::BoundaryConditions::BoundaryCondition
The base class off of which all boundary conditions must inherit.
Definition: BoundaryCondition.hpp:23
RelativisticEuler::Valencia::BoundaryConditions::DirichletAnalytic
Sets Dirichlet boundary conditions using the analytic solution or analytic data.
Definition: DirichletAnalytic.hpp:42
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecThirdOrderPiecewisePolynomial.hpp:13
hydro::Tags::RestMassDensity
The rest-mass density .
Definition: Tags.hpp:125
string
gr::Tags::SqrtDetSpatialMetric
Definition: Tags.hpp:44