TimeDerivativeTerms.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
8 #include "DataStructures/DataBox/Tag.hpp"
9 #include "DataStructures/DataVector.hpp"
11 #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
12 #include "Utilities/Gsl.hpp"
13 #include "Utilities/TMPL.hpp"
14 
15 namespace TestHelpers::NewtonianEuler {
17  using type = Scalar<DataVector>;
18 };
19 
20 template <size_t Dim>
22  using type = tnsr::I<DataVector, Dim>;
23 };
24 
26  using type = Scalar<DataVector>;
27 };
28 
29 template <size_t Dim>
31  using type = tnsr::i<DataVector, Dim>;
32 };
33 
34 // Some source term where all three conservative quantities are sourced.
35 template <size_t Dim>
37  static constexpr size_t volume_dim = Dim;
38  using sourced_variables =
42 
43  using argument_tags =
44  tmpl::list<FirstArg, SecondArg<Dim>, ThirdArg, FourthArg<Dim>>;
45 
46  void apply(
47  const gsl::not_null<Scalar<DataVector>*> source_mass_density_cons,
48  const gsl::not_null<tnsr::I<DataVector, Dim>*> source_momentum_density,
49  const gsl::not_null<Scalar<DataVector>*> source_energy_density,
50  const Scalar<DataVector>& first_arg,
51  const tnsr::I<DataVector, Dim>& second_arg,
52  const Scalar<DataVector>& third_arg,
53  const tnsr::i<DataVector, Dim>& fourth_arg) const noexcept {
54  get(*source_mass_density_cons) = exp(get(first_arg));
55  for (size_t i = 0; i < Dim; ++i) {
56  source_momentum_density->get(i) =
57  (get(first_arg) - 1.5 * get(third_arg)) * second_arg.get(i);
58  }
59  get(*source_energy_density) =
60  get(dot_product(second_arg, fourth_arg)) + 3.0 * get(third_arg);
61  }
62 };
63 
64 // Some other source term where the mass density is not sourced (this is by
65 // far the most common type of non-trivial source term for NewtonianEuler.)
66 template <size_t Dim>
68  static constexpr size_t volume_dim = Dim;
69  using sourced_variables =
70  tmpl::list<::NewtonianEuler::Tags::MomentumDensity<Dim>,
72 
73  using argument_tags =
74  tmpl::list<FirstArg, SecondArg<Dim>, ThirdArg, FourthArg<Dim>>;
75 
76  void apply(
77  const gsl::not_null<tnsr::I<DataVector, Dim>*> source_momentum_density,
78  const gsl::not_null<Scalar<DataVector>*> source_energy_density,
79  const Scalar<DataVector>& first_arg,
80  const tnsr::I<DataVector, Dim>& second_arg,
81  const Scalar<DataVector>& third_arg,
82  const tnsr::i<DataVector, Dim>& fourth_arg) const noexcept {
83  for (size_t i = 0; i < Dim; ++i) {
84  source_momentum_density->get(i) =
85  (get(first_arg) - 1.5 * get(third_arg)) * second_arg.get(i);
86  }
87  get(*source_energy_density) =
88  get(dot_product(second_arg, fourth_arg)) + 3.0 * get(third_arg);
89  }
90 };
91 
92 template <typename SourceTermType>
94  static constexpr size_t volume_dim = SourceTermType::volume_dim;
95  using source_term_type = SourceTermType;
96 };
97 } // namespace TestHelpers::NewtonianEuler
TestHelpers::NewtonianEuler::SomeOtherSourceType
Definition: TimeDerivativeTerms.hpp:67
get
constexpr Tag::type & get(Variables< TagList > &v) noexcept
Return Tag::type pointing into the contiguous array.
Definition: Variables.hpp:639
TestHelpers::NewtonianEuler::SomeSourceType
Definition: TimeDerivativeTerms.hpp:36
db::SimpleTag
Tags for the DataBox inherit from this type.
Definition: Tag.hpp:23
TestHelpers::NewtonianEuler::SecondArg
Definition: TimeDerivativeTerms.hpp:21
NewtonianEuler::Tags::MassDensityCons
The mass density of the fluid (as a conservative variable).
Definition: Tags.hpp:31
TestHelpers::NewtonianEuler::ThirdArg
Definition: TimeDerivativeTerms.hpp:25
dot_product
void dot_product(const gsl::not_null< Scalar< DataType > * > dot_product, const Tensor< DataType, Symmetry< 1 >, index_list< Index >> &vector_a, const Tensor< DataType, Symmetry< 1 >, index_list< Index >> &vector_b) noexcept
Compute the Euclidean dot product of two vectors or one forms.
Definition: DotProduct.hpp:24
TestHelpers::NewtonianEuler::TestInitialData
Definition: TimeDerivativeTerms.hpp:93
cstddef
TestHelpers::NewtonianEuler::FirstArg
Definition: TimeDerivativeTerms.hpp:16
NewtonianEuler::Tags::EnergyDensity
The energy density of the fluid.
Definition: Tags.hpp:45
NewtonianEuler::Tags::MomentumDensity
The momentum density of the fluid.
Definition: Tags.hpp:37
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
Gsl.hpp
Tensor.hpp
TestHelpers::NewtonianEuler::FourthArg
Definition: TimeDerivativeTerms.hpp:30
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183