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 :
8 : #include "DataStructures/DataBox/Tag.hpp"
9 : #include "DataStructures/DataVector.hpp"
10 : #include "DataStructures/Tensor/Tensor.hpp"
11 : #include "Evolution/Systems/CurvedScalarWave/Characteristics.hpp"
12 : #include "Evolution/Systems/GeneralizedHarmonic/Characteristics.hpp"
13 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
14 : #include "Utilities/Gsl.hpp"
15 : #include "Utilities/TMPL.hpp"
16 :
17 0 : namespace ScalarTensor::Tags {
18 0 : struct LargestCharacteristicSpeed : db::SimpleTag {
19 0 : using type = double;
20 : };
21 :
22 : /*!
23 : * \brief Computes the largest magnitude of the characteristic speeds.
24 : *
25 : * \details Compute the maximum of the largest characteristic speed of each
26 : * component system, i.e. the largest speed between ::gh and ::CurvedScalarWave.
27 : */
28 : template <typename Frame = Frame::Inertial>
29 1 : struct ComputeLargestCharacteristicSpeed : db::ComputeTag,
30 : LargestCharacteristicSpeed {
31 0 : static constexpr size_t Dim = 3_st;
32 0 : using argument_tags =
33 : tmpl::list<::gh::Tags::ConstraintGamma1, gr::Tags::Lapse<DataVector>,
34 : gr::Tags::Shift<DataVector, Dim, Frame>,
35 : gr::Tags::SpatialMetric<DataVector, Dim, Frame>,
36 : CurvedScalarWave::Tags::ConstraintGamma1>;
37 0 : using return_type = double;
38 0 : using base = LargestCharacteristicSpeed;
39 0 : static void function(const gsl::not_null<double*> speed,
40 : // GH arguments
41 : const Scalar<DataVector>& gamma_1,
42 : const Scalar<DataVector>& lapse,
43 : const tnsr::I<DataVector, Dim, Frame>& shift,
44 : const tnsr::ii<DataVector, Dim, Frame>& spatial_metric,
45 : // Scalar arguments
46 : const Scalar<DataVector>& gamma_1_scalar) {
47 : // Largest speed in for Generalized Harmonic
48 : double gh_largest_speed = 0.0;
49 : gh::Tags::ComputeLargestCharacteristicSpeed<Dim, Frame>::function(
50 : make_not_null(&gh_largest_speed), gamma_1, lapse, shift,
51 : spatial_metric);
52 : // Largest speed for CurvedScalarWave
53 : double scalar_largest_speed = 0.0;
54 : CurvedScalarWave::Tags::ComputeLargestCharacteristicSpeed<Dim>::function(
55 : make_not_null(&scalar_largest_speed), gamma_1_scalar, lapse, shift,
56 : spatial_metric);
57 : // Compute the maximum speed
58 : *speed = std::max(gh_largest_speed, scalar_largest_speed);
59 : }
60 : };
61 : } // namespace ScalarTensor::Tags
|