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/GrMhd/ValenciaDivClean/BoundaryConditions/BoundaryCondition.hpp"
18 #include "Evolution/Systems/GrMhd/ValenciaDivClean/ConservativeFromPrimitive.hpp"
19 #include "Evolution/Systems/GrMhd/ValenciaDivClean/Fluxes.hpp"
20 #include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
21 #include "Options/Options.hpp"
23 #include "PointwiseFunctions/AnalyticData/Tags.hpp"
24 #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
25 #include "PointwiseFunctions/Hydro/Tags.hpp"
26 #include "Time/Tags.hpp"
27 #include "Utilities/Gsl.hpp"
28 #include "Utilities/TMPL.hpp"
29 
30 /// \cond
31 namespace domain::Tags {
32 template <size_t Dim, typename Frame>
33 struct Coordinates;
34 } // namespace domain::Tags
35 /// \endcond
36 
38 /*!
39  * \brief Sets Dirichlet boundary conditions using the analytic solution or
40  * analytic data.
41  */
42 class DirichletAnalytic final : public BoundaryCondition {
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<3, 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, 3, Frame::Inertial>*> tilde_s,
82  const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_b,
83  const gsl::not_null<Scalar<DataVector>*> tilde_phi,
84 
85  const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
86  tilde_d_flux,
87  const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
88  tilde_tau_flux,
89  const gsl::not_null<tnsr::Ij<DataVector, 3, Frame::Inertial>*>
90  tilde_s_flux,
91  const gsl::not_null<tnsr::IJ<DataVector, 3, Frame::Inertial>*>
92  tilde_b_flux,
93  const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
94  tilde_phi_flux,
95 
97  const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> shift,
98  const gsl::not_null<tnsr::II<DataVector, 3, Frame::Inertial>*>
99  inv_spatial_metric,
100 
101  const std::optional<
102  tnsr::I<DataVector, 3, Frame::Inertial>>& /*face_mesh_velocity*/,
103  const tnsr::i<DataVector, 3, Frame::Inertial>& /*normal_covector*/,
104  const tnsr::I<DataVector, 3, Frame::Inertial>& /*normal_vector*/,
105  const tnsr::I<DataVector, 3, Frame::Inertial>& coords, 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,
113  tmpl::list<
127 
128  } else {
129  (void)time;
130  return analytic_solution_or_data.variables(
131  coords,
132  tmpl::list<
146  }
147  }();
148 
149  *lapse = get<gr::Tags::Lapse<DataVector>>(boundary_values);
150  *shift =
151  get<gr::Tags::Shift<3, Frame::Inertial, DataVector>>(boundary_values);
152  *inv_spatial_metric =
153  get<gr::Tags::InverseSpatialMetric<3, Frame::Inertial, DataVector>>(
154  boundary_values);
155 
156  ConservativeFromPrimitive::apply(
157  tilde_d, tilde_tau, tilde_s, tilde_b, tilde_phi,
161  get<hydro::Tags::Pressure<DataVector>>(boundary_values),
167  boundary_values),
169 
170  ComputeFluxes::apply(
171  tilde_d_flux, tilde_tau_flux, tilde_s_flux, tilde_b_flux,
172  tilde_phi_flux, *tilde_d, *tilde_tau, *tilde_s, *tilde_b, *tilde_phi,
173  *lapse, *shift,
176  boundary_values),
178  boundary_values),
179  get<hydro::Tags::Pressure<DataVector>>(boundary_values),
183 
184  return {};
185  }
186 };
187 } // namespace grmhd::ValenciaDivClean::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
get
constexpr Tag::type & get(Variables< TagList > &v) noexcept
Return Tag::type pointing into the contiguous array.
Definition: Variables.hpp:660
Options.hpp
hydro::Tags::DivergenceCleaningField
The divergence-cleaning field .
Definition: Tags.hpp:48
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.
grmhd::ValenciaDivClean::BoundaryConditions::DirichletAnalytic
Sets Dirichlet boundary conditions using the analytic solution or analytic data.
Definition: DirichletAnalytic.hpp:42
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
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
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
hydro::Tags::MagneticField
The magnetic field measured by an Eulerian observer, where is the normal to the spatial hypersurfac...
Definition: Tags.hpp:80
Tensor.hpp
optional
std::unique_ptr
Prefixes.hpp
grmhd::ValenciaDivClean::BoundaryConditions::BoundaryCondition
The base class off of which all boundary conditions must inherit.
Definition: BoundaryCondition.hpp:21
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
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
grmhd::ValenciaDivClean::BoundaryConditions
Boundary conditions for the GRMHD Valencia Divergence Cleaning system.
Definition: BoundaryCondition.hpp:19
string
gr::Tags::SqrtDetSpatialMetric
Definition: Tags.hpp:44