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 
49  DirichletAnalytic() = default;
50  DirichletAnalytic(DirichletAnalytic&&) noexcept = default;
51  DirichletAnalytic& operator=(DirichletAnalytic&&) noexcept = default;
52  DirichletAnalytic(const DirichletAnalytic&) = default;
53  DirichletAnalytic& operator=(const DirichletAnalytic&) = default;
54  ~DirichletAnalytic() override = default;
55 
56  explicit DirichletAnalytic(CkMigrateMessage* msg) noexcept;
57 
58  WRAPPED_PUPable_decl_base_template(
60 
61  auto get_clone() const noexcept -> std::unique_ptr<
63 
64  static constexpr evolution::BoundaryConditions::Type bc_type =
65  evolution::BoundaryConditions::Type::Ghost;
66 
67  void pup(PUP::er& p) override;
68 
69  using dg_interior_evolved_variables_tags = tmpl::list<>;
70  using dg_interior_temporary_tags =
71  tmpl::list<domain::Tags::Coordinates<Dim, Frame::Inertial>>;
72  using dg_interior_primitive_variables_tags = tmpl::list<>;
73  using dg_gridless_tags =
74  tmpl::list<::Tags::Time, ::Tags::AnalyticSolutionOrData>;
75 
76  template <typename AnalyticSolutionOrData>
78  const gsl::not_null<Scalar<DataVector>*> tilde_d,
79  const gsl::not_null<Scalar<DataVector>*> tilde_tau,
80  const gsl::not_null<tnsr::i<DataVector, Dim, Frame::Inertial>*> tilde_s,
81 
82  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
83  flux_tilde_d,
84  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
85  flux_tilde_tau,
86  const gsl::not_null<tnsr::Ij<DataVector, Dim, Frame::Inertial>*>
87  flux_tilde_s,
88 
90  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> shift,
91  const gsl::not_null<tnsr::ii<DataVector, Dim, Frame::Inertial>*>
93  const gsl::not_null<Scalar<DataVector>*> rest_mass_density,
94  const gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
95  const gsl::not_null<Scalar<DataVector>*> specific_enthalpy,
96  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
97  spatial_velocity,
98  const gsl::not_null<tnsr::II<DataVector, Dim, Frame::Inertial>*>
99  inv_spatial_metric,
100 
101  const std::optional<
102  tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
103  const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/,
104  const tnsr::I<DataVector, Dim, Frame::Inertial>& /*normal_vector*/,
105  const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
106  const double time,
107  const AnalyticSolutionOrData& analytic_solution_or_data) const noexcept {
108  auto boundary_values = [&analytic_solution_or_data, &coords,
109  &time]() noexcept {
110  if constexpr (std::is_base_of_v<MarkAsAnalyticSolution,
111  AnalyticSolutionOrData>) {
112  return analytic_solution_or_data.variables(
113  coords, time,
123  } else {
124  (void)time;
125  return analytic_solution_or_data.variables(
126  coords,
136  }
137  }();
138 
139  *lapse = get<gr::Tags::Lapse<>>(boundary_values);
140  *shift = get<gr::Tags::Shift<Dim>>(boundary_values);
141  *spatial_metric = get<gr::Tags::SpatialMetric<Dim>>(boundary_values);
142  *inv_spatial_metric =
143  get<gr::Tags::InverseSpatialMetric<Dim>>(boundary_values);
144  *rest_mass_density =
145  get<hydro::Tags::RestMassDensity<DataVector>>(boundary_values);
146  *specific_internal_energy =
147  get<hydro::Tags::SpecificInternalEnergy<DataVector>>(boundary_values);
148  *specific_enthalpy =
149  get<hydro::Tags::SpecificEnthalpy<DataVector>>(boundary_values);
150  *spatial_velocity =
151  get<hydro::Tags::SpatialVelocity<DataVector, Dim>>(boundary_values);
152 
153  const auto& pressure =
154  get<hydro::Tags::Pressure<DataVector>>(boundary_values);
155  const auto& lorentz_factor =
156  get<hydro::Tags::LorentzFactor<DataVector>>(boundary_values);
157  const auto& sqrt_det_spatial_metric =
158  get<gr::Tags::SqrtDetSpatialMetric<>>(boundary_values);
159 
161  tilde_d, tilde_tau, tilde_s, *rest_mass_density,
162  *specific_internal_energy, *specific_enthalpy, pressure,
163  *spatial_velocity, lorentz_factor, sqrt_det_spatial_metric,
164  *spatial_metric);
165  ComputeFluxes<Dim>::apply(flux_tilde_d, flux_tilde_tau, flux_tilde_s,
166  *tilde_d, *tilde_tau, *tilde_s, *lapse, *shift,
167  sqrt_det_spatial_metric, pressure,
168  *spatial_velocity);
169 
170  return {};
171  }
172 };
173 } // namespace RelativisticEuler::Valencia::BoundaryConditions
hydro::Tags::Pressure
The fluid pressure .
Definition: Tags.hpp:119
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
gr::Tags::InverseSpatialMetric
Inverse of the spatial metric.
Definition: Tags.hpp:33
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: ReadSpecPiecewisePolynomial.hpp:13
hydro::Tags::RestMassDensity
The rest-mass density .
Definition: Tags.hpp:125
string
gr::Tags::SqrtDetSpatialMetric
Definition: Tags.hpp:44