TagsCharacteresticSpeeds.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 #include <boost/optional.hpp>
8 #include <cstddef>
9 
10 #include "DataStructures/DataVector.hpp"
12 #include "DataStructures/Tensor/EagerMath/Magnitude.hpp" // For Tags::Normalized
14 #include "Domain/InterfaceHelpers.hpp"
15 #include "Domain/Tags.hpp"
16 #include "Domain/TagsTimeDependent.hpp"
17 #include "Utilities/Gsl.hpp"
18 #include "Utilities/TMPL.hpp"
19 
20 namespace domain {
21 namespace Tags {
22 /// Compute the characteristic speeds on the moving mesh given the
23 /// characteristic speeds if the mesh were stationary.
24 ///
25 /// \note Assumes that `typename CharSpeedsComputeTag::return_type` is a
26 /// `std::array<DataVector, NumberOfCharSpeeds>`
27 template <typename CharSpeedsComputeTag, size_t Dim>
28 struct CharSpeedCompute : CharSpeedsComputeTag::base, db::ComputeTag {
29  using base = typename CharSpeedsComputeTag::base;
30  using return_type = typename CharSpeedsComputeTag::return_type;
31 
32  template <typename... Ts, typename T, size_t NumberOfCharSpeeds>
33  static void function(
35  const boost::optional<tnsr::I<DataVector, Dim, Frame::Inertial>>&
36  grid_velocity,
37  const tnsr::i<DataVector, Dim, Frame::Inertial>& unit_normal_covector,
38  const Ts&... ts) noexcept {
39  // Note that while the CharSpeedsComputeTag almost certainly also needs the
40  // unit normal covector for computing the original characteristic speeds, we
41  // don't know which of the `ts` it is, and thus we need the unit normal
42  // covector to be passed explicitly.
43  CharSpeedsComputeTag::function(result, ts...);
44  if (static_cast<bool>(grid_velocity)) {
45  const Scalar<DataVector> normal_dot_velocity =
46  dot_product(*grid_velocity, unit_normal_covector);
47  for (size_t i = 0; i < result->size(); ++i) {
48  gsl::at(*result, i) -= get(normal_dot_velocity);
49  }
50  }
51  }
52 
53  using argument_tags =
54  tmpl::push_front<typename CharSpeedsComputeTag::argument_tags,
57  using volume_tags = get_volume_tags<CharSpeedsComputeTag>;
58 };
59 } // namespace Tags
60 } // namespace domain
domain::push_front
CoordinateMap< SourceFrame, TargetFrame, NewMap, Maps... > push_front(CoordinateMap< SourceFrame, TargetFrame, Maps... > old_map, NewMap new_map) noexcept
Creates a CoordinateMap by prepending the new map to the beginning of the old maps.
gsl::at
constexpr T & at(std::array< T, N > &arr, Size index)
Retrieve a entry from a container, with checks in Debug mode that the index being retrieved is valid.
Definition: Gsl.hpp:125
db::ComputeTag
Mark a struct as a compute tag by inheriting from this.
Definition: Tag.hpp:157
get
constexpr Tag::type & get(Variables< TagList > &v) noexcept
Return Tag::type pointing into the contiguous array.
Definition: Variables.hpp:638
Tags.hpp
domain::Tags::MeshVelocity< Dim, Frame::Inertial >
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
DotProduct.hpp
Tags::Normalized
Definition: Magnitude.hpp:137
cstddef
array
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
domain::Tags::CharSpeedCompute
Compute the characteristic speeds on the moving mesh given the characteristic speeds if the mesh were...
Definition: TagsCharacteresticSpeeds.hpp:28
Gsl.hpp
Tensor.hpp
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183