CharacteristicHelpers.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <array>
7 #include <cstddef>
8 #include <limits>
9 #include <string>
10 #include <type_traits>
11 #include <unordered_map>
12 #include <utility>
13
14 #include "DataStructures/Tags.hpp"
17 #include "Evolution/Systems/NewtonianEuler/Characteristics.hpp"
18 #include "Evolution/Systems/NewtonianEuler/SoundSpeedSquared.hpp"
19 #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
20 #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
21 #include "Utilities/Gsl.hpp"
22 #include "Utilities/TMPL.hpp"
23 #include "Utilities/TaggedTuple.hpp"
24
25 namespace NewtonianEuler::Limiters {
26
27 /*!
28  * \brief Compute the transform matrices between the conserved variables and
29  * the characteristic variables of the NewtonianEuler system.
30  *
31  * Wraps calls to NewtonianEuler::right_eigenvectors and
32  * NewtonianEuler::left_eigenvectors.
33  */
34 template <size_t VolumeDim, size_t ThermodynamicDim>
35 std::pair<Matrix, Matrix> right_and_left_eigenvectors(
36  const Scalar<double>& mean_density,
37  const tnsr::I<double, VolumeDim>& mean_momentum,
38  const Scalar<double>& mean_energy,
40  equation_of_state,
41  const tnsr::i<double, VolumeDim>& unit_normal) noexcept;
42
43 /// @{
44 /// \brief Compute characteristic fields from conserved fields
45 ///
46 /// Note that these functions apply the same transformation to every grid point
47 /// in the element, using the same matrix from left_eigenvectors.
48 /// This is in contrast to the characteristic transformation used in the
49 /// GeneralizedHarmonic upwind flux, which is computed pointwise.
50 ///
51 /// By using a fixed matrix of eigenvectors computed from the cell-averaged
52 /// fields, we ensure we can consistently transform back from the characteristic
53 /// variables even after applying the limiter (the limiter changes the pointwise
54 /// values but preserves the cell averages).
55 template <size_t VolumeDim>
61  char_means,
62  const tuples::TaggedTuple<
66  const Matrix& left) noexcept;
67
68 template <size_t VolumeDim>
70  gsl::not_null<Scalar<DataVector>*> char_v_minus,
71  gsl::not_null<tnsr::I<DataVector, VolumeDim>*> char_v_momentum,
72  gsl::not_null<Scalar<DataVector>*> char_v_plus,
73  const Scalar<DataVector>& cons_mass_density,
74  const tnsr::I<DataVector, VolumeDim>& cons_momentum_density,
75  const Scalar<DataVector>& cons_energy_density, const Matrix& left) noexcept;
76
77 template <size_t VolumeDim>
80  Variables<tmpl::list<NewtonianEuler::Tags::VMinus,
83  char_vars,
84  const Variables<tmpl::list<NewtonianEuler::Tags::MassDensityCons,
87  const Matrix& left) noexcept;
88 /// @}
89
90 /// \brief Compute conserved fields from characteristic fields
91 ///
92 /// Note that this function applies the same transformation to every grid point
93 /// in the element, using the same matrix from right_eigenvectors.
94 /// This is in contrast to the characteristic transformation used in the
95 /// GeneralizedHarmonic upwind flux, which is computed pointwise.
96 ///
97 /// By using a fixed matrix of eigenvectors computed from the cell-averaged
98 /// fields, we ensure we can consistently transform back from the characteristic
99 /// variables even after applying the limiter (the limiter changes the pointwise
100 /// values but preserves the cell averages).
101 template <size_t VolumeDim>
102 void conserved_fields_from_characteristic_fields(
103  gsl::not_null<Scalar<DataVector>*> cons_mass_density,
104  gsl::not_null<tnsr::I<DataVector, VolumeDim>*> cons_momentum_density,
105  gsl::not_null<Scalar<DataVector>*> cons_energy_density,
106  const Scalar<DataVector>& char_v_minus,
107  const tnsr::I<DataVector, VolumeDim>& char_v_momentum,
108  const Scalar<DataVector>& char_v_plus, const Matrix& right) noexcept;
109
110 } // namespace NewtonianEuler::Limiters
Matrix
A dynamically sized matrix of doubles with column-major storage.
Definition: Matrix.hpp:19
NewtonianEuler::Tags::VMomentum
Definition: Tags.hpp:94
utility
EquationsOfState::EquationOfState
Base class for equations of state depending on whether or not the system is relativistic,...
Definition: EquationOfState.hpp:63
NewtonianEuler::Tags::VMinus
The characteristic fields of the NewtonianEuler system.
Definition: Tags.hpp:90
std::pair
Tags::Mean
Given the Tag holding a Tensor<DataVector, ...>, swap the DataVector with a double.
Definition: Tags.hpp:23
NewtonianEuler::Tags::MassDensityCons
The mass density of the fluid (as a conservative variable).
Definition: Tags.hpp:31
cstddef
array
NewtonianEuler::Tags::VPlus
Definition: Tags.hpp:97
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
NewtonianEuler::Tags::EnergyDensity
The energy density of the fluid.
Definition: Tags.hpp:45
Variables.hpp
NewtonianEuler::Tags::MomentumDensity
The momentum density of the fluid.
Definition: Tags.hpp:37
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
limits
Gsl.hpp
Tensor.hpp
unordered_map
type_traits
TMPL.hpp
CurvedScalarWave::characteristic_fields
Variables< tmpl::list< Tags::VPsi, Tags::VZero< SpatialDim >, Tags::VPlus, Tags::VMinus > > characteristic_fields(const Scalar< DataVector > &gamma_2, const tnsr::II< DataVector, SpatialDim, Frame::Inertial > &inverse_spatial_metric, const Scalar< DataVector > &psi, const Scalar< DataVector > &pi, const tnsr::i< DataVector, SpatialDim, Frame::Inertial > &phi, const tnsr::i< DataVector, SpatialDim, Frame::Inertial > &unit_normal_one_form) noexcept
Computes characteristic fields from evolved fields.
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13
string