DirichletAnalytic.hpp
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/NewtonianEuler/BoundaryConditions/BoundaryCondition.hpp"
18 #include "Evolution/Systems/NewtonianEuler/ConservativeFromPrimitive.hpp"
19 #include "Evolution/Systems/NewtonianEuler/Fluxes.hpp"
20 #include "Evolution/Systems/NewtonianEuler/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>*> mass_density,
80  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
81  momentum_density,
82  const gsl::not_null<Scalar<DataVector>*> energy_density,
83
84  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
85  flux_mass_density,
86  const gsl::not_null<tnsr::IJ<DataVector, Dim, Frame::Inertial>*>
87  flux_momentum_density,
88  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
89  flux_energy_density,
90
91  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> velocity,
92  const gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
93
94  const std::optional<
95  tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
96  const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/,
97  const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
98  const double time,
99  const AnalyticSolutionOrData& analytic_solution_or_data) const noexcept {
100  auto boundary_values = [&analytic_solution_or_data, &coords,
101  &time]() noexcept {
102  if constexpr (std::is_base_of_v<MarkAsAnalyticSolution,
103  AnalyticSolutionOrData>) {
104  return analytic_solution_or_data.variables(
105  coords, time,
110
111  } else {
112  (void)time;
113  return analytic_solution_or_data.variables(
114  coords, tmpl::list<Tags::MassDensity<DataVector>,
118  }
119  }();
120
121  *mass_density = get<Tags::MassDensity<DataVector>>(boundary_values);
122  *velocity = get<Tags::Velocity<DataVector, Dim>>(boundary_values);
123  *specific_internal_energy =
124  get<Tags::SpecificInternalEnergy<DataVector>>(boundary_values);
125
126  ConservativeFromPrimitive<Dim>::apply(mass_density, momentum_density,
127  energy_density, *mass_density,
128  *velocity, *specific_internal_energy);
129  ComputeFluxes<Dim>::apply(flux_mass_density, flux_momentum_density,
130  flux_energy_density, *momentum_density,
131  *energy_density, *velocity,
132  get<Tags::Pressure<DataVector>>(boundary_values));
133
134  return {};
135  }
136 };
137 } // namespace NewtonianEuler::BoundaryConditions
NewtonianEuler::ComputeFluxes
Compute the fluxes of the conservative variables of the Newtonian Euler system.
Definition: Fluxes.hpp:55
std::string
CharmPupable.hpp
domain::BoundaryConditions::BoundaryCondition
Base class from which all system-specific base classes must inherit.
Definition: BoundaryCondition.hpp:18
get
constexpr Tag::type & get(Variables< TagList > &v) noexcept
Return Tag::type pointing into the contiguous array.
Definition: Variables.hpp:660
NewtonianEuler::BoundaryConditions
Boundary conditions for the Newtonian Euler hydrodynamics system.
Definition: BoundaryCondition.hpp:20
Options.hpp
NewtonianEuler::Tags::MassDensity
The mass density of the fluid.
Definition: Tags.hpp:26
NewtonianEuler::Tags::SpecificInternalEnergy
The specific internal energy of the fluid.
Definition: Tags.hpp:60
NewtonianEuler::BoundaryConditions::DirichletAnalytic
Sets Dirichlet boundary conditions using the analytic solution or analytic data.
Definition: DirichletAnalytic.hpp:42
NewtonianEuler::BoundaryConditions::BoundaryCondition
The base class off of which all boundary conditions must inherit.
Definition: BoundaryCondition.hpp:23
NewtonianEuler::Tags::Pressure
The fluid pressure.
Definition: Tags.hpp:66
memory
Variables.hpp
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
Tensor.hpp
optional
NewtonianEuler::Tags::Velocity
The macroscopic or flow velocity of the fluid.
Definition: Tags.hpp:51
NewtonianEuler::ConservativeFromPrimitive
Compute the conservative variables from the primitive variables.
Definition: ConservativeFromPrimitive.hpp:46
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