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 
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<3, 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, 3, Frame::Inertial>*> tilde_s,
81  const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_b,
82  const gsl::not_null<Scalar<DataVector>*> tilde_phi,
83 
84  const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
85  tilde_d_flux,
86  const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
87  tilde_tau_flux,
88  const gsl::not_null<tnsr::Ij<DataVector, 3, Frame::Inertial>*>
89  tilde_s_flux,
90  const gsl::not_null<tnsr::IJ<DataVector, 3, Frame::Inertial>*>
91  tilde_b_flux,
92  const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
93  tilde_phi_flux,
94 
96  const gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> shift,
97  const gsl::not_null<tnsr::II<DataVector, 3, Frame::Inertial>*>
98  inv_spatial_metric,
99 
100  const std::optional<
101  tnsr::I<DataVector, 3, Frame::Inertial>>& /*face_mesh_velocity*/,
102  const tnsr::i<DataVector, 3, Frame::Inertial>& /*normal_covector*/,
103  const tnsr::I<DataVector, 3, Frame::Inertial>& /*normal_vector*/,
104  const tnsr::I<DataVector, 3, Frame::Inertial>& coords, const double time,
105  const AnalyticSolutionOrData& analytic_solution_or_data) const noexcept {
106  auto boundary_values = [&analytic_solution_or_data, &coords,
107  &time]() noexcept {
108  if constexpr (std::is_base_of_v<MarkAsAnalyticSolution,
109  AnalyticSolutionOrData>) {
110  return analytic_solution_or_data.variables(
111  coords, time,
112  tmpl::list<
126 
127  } else {
128  (void)time;
129  return analytic_solution_or_data.variables(
130  coords,
131  tmpl::list<
145  }
146  }();
147 
148  *lapse = get<gr::Tags::Lapse<DataVector>>(boundary_values);
149  *shift =
150  get<gr::Tags::Shift<3, Frame::Inertial, DataVector>>(boundary_values);
151  *inv_spatial_metric =
152  get<gr::Tags::InverseSpatialMetric<3, Frame::Inertial, DataVector>>(
153  boundary_values);
154 
155  ConservativeFromPrimitive::apply(
156  tilde_d, tilde_tau, tilde_s, tilde_b, tilde_phi,
160  get<hydro::Tags::Pressure<DataVector>>(boundary_values),
166  boundary_values),
168 
169  ComputeFluxes::apply(
170  tilde_d_flux, tilde_tau_flux, tilde_s_flux, tilde_b_flux,
171  tilde_phi_flux, *tilde_d, *tilde_tau, *tilde_s, *tilde_b, *tilde_phi,
172  *lapse, *shift,
175  boundary_values),
177  boundary_values),
178  get<hydro::Tags::Pressure<DataVector>>(boundary_values),
182 
183  return {};
184  }
185 };
186 } // namespace grmhd::ValenciaDivClean::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
hydro::Tags::DivergenceCleaningField
The divergence-cleaning field .
Definition: Tags.hpp:48
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:791
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:22
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: ReadSpecPiecewisePolynomial.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:20
string
gr::Tags::SqrtDetSpatialMetric
Definition: Tags.hpp:44