Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <memory>
8 : #include <optional>
9 : #include <pup.h>
10 : #include <string>
11 :
12 : #include "DataStructures/Tensor/TypeAliases.hpp"
13 : #include "Domain/BoundaryConditions/BoundaryCondition.hpp"
14 : #include "Evolution/BoundaryConditions/Type.hpp"
15 : #include "Evolution/Systems/NewtonianEuler/BoundaryConditions/BoundaryCondition.hpp"
16 : #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
17 : #include "Options/String.hpp"
18 : #include "PointwiseFunctions/Hydro/Tags.hpp"
19 : #include "Utilities/TMPL.hpp"
20 :
21 : /// \cond
22 : class DataVector;
23 : namespace gsl {
24 : template <class T>
25 : class not_null;
26 : } // namespace gsl
27 : /// \endcond
28 :
29 : namespace NewtonianEuler::BoundaryConditions {
30 : /*!
31 : * \brief Reflecting boundary conditions for Newtonian hydrodynamics.
32 : *
33 : * Ghost (exterior) data 'mirrors' interior volume data with respect to the
34 : * boundary interface. i.e. reverses the normal component of velocity while
35 : * using same values for other scalar quantities.
36 : *
37 : * In the frame instantaneously moving with the same velocity as face mesh, the
38 : * reflection condition reads
39 : *
40 : * \f{align*}
41 : * \vec{u}_\text{ghost} = \vec{u}_\text{int} - 2 (\vec{u}_\text{int} \cdot
42 : * \hat{n}) \hat{n}
43 : * \f}
44 : *
45 : * where \f$\vec{u}\f$ is the fluid velocity in the moving frame, "int" stands
46 : * for interior, and \f$\hat{n}\f$ is the outward normal vector on the boundary
47 : * interface.
48 : *
49 : * Substituting \f$\vec{u} = \vec{v} - \vec{v}_m\f$, we get
50 : *
51 : * \f{align*}
52 : * v_\text{ghost}^i &= v_\text{int}^i - 2[(v_\text{int}^j-v_m^j)n_j]n^i
53 : * \f}
54 : *
55 : * where \f$v\f$ is the fluid velocity and \f$v_m\f$ is face mesh velocity.
56 : *
57 : */
58 : template <size_t Dim>
59 1 : class Reflection final : public BoundaryCondition<Dim> {
60 : public:
61 0 : using options = tmpl::list<>;
62 0 : static constexpr Options::String help{
63 : "Reflecting boundary conditions for Newtonian hydrodynamics."};
64 :
65 0 : Reflection() = default;
66 0 : Reflection(Reflection&&) = default;
67 0 : Reflection& operator=(Reflection&&) = default;
68 0 : Reflection(const Reflection&) = default;
69 0 : Reflection& operator=(const Reflection&) = default;
70 0 : ~Reflection() override = default;
71 :
72 0 : explicit Reflection(CkMigrateMessage* msg);
73 :
74 0 : WRAPPED_PUPable_decl_base_template(
75 : domain::BoundaryConditions::BoundaryCondition, Reflection);
76 :
77 0 : auto get_clone() const -> std::unique_ptr<
78 : domain::BoundaryConditions::BoundaryCondition> override;
79 :
80 0 : static constexpr evolution::BoundaryConditions::Type bc_type =
81 : evolution::BoundaryConditions::Type::Ghost;
82 :
83 0 : void pup(PUP::er& p) override;
84 :
85 0 : using dg_interior_evolved_variables_tags = tmpl::list<>;
86 0 : using dg_interior_temporary_tags = tmpl::list<>;
87 0 : using dg_interior_primitive_variables_tags =
88 : tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
89 : hydro::Tags::SpatialVelocity<DataVector, Dim>,
90 : hydro::Tags::SpecificInternalEnergy<DataVector>,
91 : hydro::Tags::Pressure<DataVector>>;
92 0 : using dg_gridless_tags = tmpl::list<>;
93 :
94 0 : std::optional<std::string> dg_ghost(
95 : gsl::not_null<Scalar<DataVector>*> mass_density,
96 : gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
97 : momentum_density,
98 : gsl::not_null<Scalar<DataVector>*> energy_density,
99 :
100 : gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
101 : flux_mass_density,
102 : gsl::not_null<tnsr::IJ<DataVector, Dim, Frame::Inertial>*>
103 : flux_momentum_density,
104 : gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
105 : flux_energy_density,
106 :
107 : gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> velocity,
108 : gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
109 :
110 : const std::optional<tnsr::I<DataVector, Dim, Frame::Inertial>>&
111 : face_mesh_velocity,
112 : const tnsr::i<DataVector, Dim, Frame::Inertial>&
113 : outward_directed_normal_covector,
114 :
115 : const Scalar<DataVector>& interior_mass_desity,
116 : const tnsr::I<DataVector, Dim, Frame::Inertial>& interior_velocity,
117 : const Scalar<DataVector>& interior_specific_internal_energy,
118 : const Scalar<DataVector>& interior_pressure) const;
119 : };
120 :
121 : } // namespace NewtonianEuler::BoundaryConditions
|