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/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 
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>*> mass_density,
79  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
80  momentum_density,
81  const gsl::not_null<Scalar<DataVector>*> energy_density,
82 
83  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
84  flux_mass_density,
85  const gsl::not_null<tnsr::IJ<DataVector, Dim, Frame::Inertial>*>
86  flux_momentum_density,
87  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
88  flux_energy_density,
89 
90  const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> velocity,
91  const gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
92 
93  const std::optional<
94  tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
95  const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/,
96  const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
97  const double time,
98  const AnalyticSolutionOrData& analytic_solution_or_data) const noexcept {
99  auto boundary_values = [&analytic_solution_or_data, &coords,
100  &time]() noexcept {
101  if constexpr (std::is_base_of_v<MarkAsAnalyticSolution,
102  AnalyticSolutionOrData>) {
103  return analytic_solution_or_data.variables(
104  coords, time,
109 
110  } else {
111  (void)time;
112  return analytic_solution_or_data.variables(
113  coords, tmpl::list<Tags::MassDensity<DataVector>,
117  }
118  }();
119 
120  *mass_density = get<Tags::MassDensity<DataVector>>(boundary_values);
121  *velocity = get<Tags::Velocity<DataVector, Dim>>(boundary_values);
122  *specific_internal_energy =
123  get<Tags::SpecificInternalEnergy<DataVector>>(boundary_values);
124 
125  ConservativeFromPrimitive<Dim>::apply(mass_density, momentum_density,
126  energy_density, *mass_density,
127  *velocity, *specific_internal_energy);
128  ComputeFluxes<Dim>::apply(flux_mass_density, flux_momentum_density,
129  flux_energy_density, *momentum_density,
130  *energy_density, *velocity,
131  get<Tags::Pressure<DataVector>>(boundary_values));
132 
133  return {};
134  }
135 };
136 } // namespace NewtonianEuler::BoundaryConditions
NewtonianEuler::ComputeFluxes
Compute the fluxes of the conservative variables of the Newtonian Euler system.
Definition: Fluxes.hpp:55
CharmPupable.hpp
domain::BoundaryConditions::BoundaryCondition
Base class from which all system-specific base classes must inherit.
Definition: BoundaryCondition.hpp:18
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
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:791
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
Definition: ReadSpecPiecewisePolynomial.hpp:13
string