VortexPerturbation.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <limits>
8 
10 #include "Domain/Tags.hpp"
11 #include "Evolution/Systems/NewtonianEuler/TagsDeclarations.hpp"
12 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
13 #include "Time/Tags.hpp"
14 #include "Utilities/MakeArray.hpp"
15 #include "Utilities/TMPL.hpp"
16 
17 // IWYU pragma: no_forward_declare Tensor
18 
19 /// \cond
20 class DataVector;
21 
22 namespace NewtonianEuler {
23 namespace Solutions {
24 template <size_t Dim>
25 struct IsentropicVortex;
26 } // namespace Solutions
27 } // namespace NewtonianEuler
28 
29 namespace gsl {
30 template <typename T>
31 class not_null;
32 } // namespace gsl
33 /// \endcond
34 
35 namespace NewtonianEuler {
36 namespace Sources {
37 
38 /*!
39  * \brief Source generating a modified isentropic vortex.
40  *
41  * If Solutions::IsentropicVortex is modifed so that the flow velocity along
42  * the \f$z-\f$axis is not a constant but a function of \f$z\f$, the new vortex
43  * will be a solution to the 3-D Newtonian Euler equations with a source term,
44  *
45  * \f{align*}
46  * \partial_t\rho + \partial_i F^i(\rho) &= S(\rho)\\
47  * \partial_t S^i + \partial_j F^{j}(S^i) &= S(S^i)\\
48  * \partial_t e + \partial_i F^i(e) &= S(e),
49  * \f}
50  *
51  * where \f$F^i(u)\f$ is the volume flux of the conserved quantity \f$u\f$
52  * (see ComputeFluxes), and
53  *
54  * \f{align*}
55  * S(\rho) &= \rho \dfrac{dv_z}{dz}\\
56  * S(S_x) &= S_x \dfrac{dv_z}{dz}\\
57  * S(S_y) &= S_y \dfrac{dv_z}{dz}\\
58  * S(S_z) &= 2S_z \dfrac{dv_z}{dz}\\
59  * S(e) &= \left(e + p + v_z S_z\right)\dfrac{dv_z}{dz},
60  * \f}
61  *
62  * where \f$\rho\f$ is the mass density of the vortex, \f$S_i\f$ is
63  * its momentum density, \f$e\f$ is its energy density,
64  * \f$v_z = v_z(z)\f$ is the \f$z-\f$component of its velocity,
65  * and \f$p\f$ is its pressure. These quantities are readily obtained
66  * from the primitive variables, whose expressions are those in
67  * Solutions::IsentropicVortex
68  */
69 template <size_t Dim>
71  VortexPerturbation() noexcept = default;
72  VortexPerturbation(const VortexPerturbation& /*rhs*/) = default;
73  VortexPerturbation& operator=(const VortexPerturbation& /*rhs*/) = default;
74  VortexPerturbation(VortexPerturbation&& /*rhs*/) noexcept = default;
75  VortexPerturbation& operator=(VortexPerturbation&& /*rhs*/) noexcept =
76  default;
77  ~VortexPerturbation() = default;
78 
79  // clang-tidy: google-runtime-references
80  void pup(PUP::er& /*p*/) noexcept {} // NOLINT
81 
82  using sourced_variables =
83  tmpl::conditional_t<Dim == 3,
84  tmpl::list<Tags::MassDensityCons<DataVector>,
87  tmpl::list<>>;
88 
89  using argument_tags = tmpl::conditional_t<
90  Dim == 3,
91  tmpl::list<::Tags::AnalyticSolution<
94  tmpl::list<>>;
95 
96  // Overload required for 2d simulations, where no variable is sourced.
97  void apply() const noexcept;
98 
99  // Function to be used in 3d.
100  void apply(gsl::not_null<Scalar<DataVector>*> source_mass_density_cons,
101  gsl::not_null<tnsr::I<DataVector, Dim>*> source_momentum_density,
102  gsl::not_null<Scalar<DataVector>*> source_energy_density,
103  const NewtonianEuler::Solutions::IsentropicVortex<Dim>& vortex,
104  const tnsr::I<DataVector, Dim>& x, double time) const noexcept;
105 };
106 } // namespace Sources
107 } // namespace NewtonianEuler
The momentum density of the fluid.
Definition: Tags.hpp:43
Implementations from the Guideline Support Library.
Definition: ConservativeFromPrimitive.hpp:10
Defines function make_array.
Newtonian isentropic vortex in Cartesian coordinates.
Definition: EvolveNewtonianEulerFwd.hpp:13
Tag for the current time as a double.
Definition: Tags.hpp:72
Source generating a modified isentropic vortex.
Definition: VortexPerturbation.hpp:70
The energy density of the fluid.
Definition: Tags.hpp:52
Defines a list of useful type aliases for tensors.
The coordinates in a given frame.
Definition: Tags.hpp:139
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args) noexcept
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1623
Stores a collection of function values.
Definition: DataVector.hpp:42
Wraps the template metaprogramming library used (brigand)
Defines tags related to domain quantities.
The analytic solution, with the type of the analytic solution set as the template parameter...
Definition: Tags.hpp:49
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Defines tags related to Time quantities.
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12
Items related to evolving the Newtonian Euler system.
Definition: EvolveNewtonianEulerFwd.hpp:8