Tags.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <string>
8 
11 #include "DataStructures/Tensor/EagerMath/Magnitude.hpp"
12 #include "DataStructures/Variables.hpp" // IWYU pragma: keep
13 #include "Domain/FaceNormal.hpp"
16 #include "Utilities/TMPL.hpp"
17 
18 /// \cond
19 // IWYU pragma: no_forward_declare Variables
20 // IWYU pragma: no_forward_declare Tags::Flux
21 /// \endcond
22 
23 namespace Tags {
24 
25 /// \ingroup ConservativeGroup
26 /// \ingroup DataBoxTagsGroup
27 /// \brief Prefix computing a boundary unit normal vector dotted into
28 /// the flux from a flux on the boundary.
29 template <typename Tag, size_t VolumeDim, typename Fr>
30 struct ComputeNormalDotFlux : db::add_tag_prefix<NormalDotFlux, Tag>,
33 
34  private:
36  using normal_tag =
38 
39  public:
40  static auto function(const db::item_type<flux_tag>& flux,
41  const db::item_type<normal_tag>& normal) noexcept {
42  using tags_list = typename db::item_type<Tag>::tags_list;
43  auto result = make_with_value<
45 
46  tmpl::for_each<tags_list>([&result, &flux,
47  &normal ](auto local_tag) noexcept {
48  using tensor_tag = tmpl::type_from<decltype(local_tag)>;
49  auto& result_tensor = get<NormalDotFlux<tensor_tag>>(result);
50  const auto& flux_tensor =
51  get<Flux<tensor_tag, tmpl::size_t<VolumeDim>, Fr>>(flux);
52  for (auto it = result_tensor.begin(); it != result_tensor.end(); ++it) {
53  const auto result_indices = result_tensor.get_tensor_index(it);
54  for (size_t d = 0; d < VolumeDim; ++d) {
55  *it += normal.get(d) * flux_tensor.get(prepend(result_indices, d));
56  }
57  }
58  });
59  return result;
60  }
61  using argument_tags = tmpl::list<flux_tag, normal_tag>;
62 };
63 } // namespace Tags
Prefix< DataBox_detail::dispatch_add_tag_prefix_impl< Prefix, Tag, Args... >, Args... > add_tag_prefix
Wrap Tag in Prefix<_, Args...>, also wrapping variables tags if Tag is a Tags::Variables.
Definition: DataBoxTag.hpp:533
Definition: Variables.hpp:46
The normalized (co)vector represented by Tag.
Definition: Magnitude.hpp:93
Marks a DataBoxTag as being a compute item that executes a function.
Definition: DataBoxTag.hpp:155
Define prefixes for DataBox tags.
constexpr std::array< T, Dim+1 > prepend(const std::array< T, Dim > &a, T value) noexcept
Construct an array from an existing array prepending a value.
Definition: StdArrayHelpers.hpp:132
Prefix computing a boundary unit normal vector dotted into the flux from a flux on the boundary...
Definition: Tags.hpp:30
std::remove_const_t< R > make_with_value(const T &input, const ValueType &value) noexcept
Given an object of type T, create an object of type R whose elements are initialized to value...
Definition: MakeWithValue.hpp:42
Defines class Variables.
Definition: DataBoxTag.hpp:29
Declares function unnormalized_face_normal.
Wraps the template metaprogramming library used (brigand)
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that is returned by the Tag. If it is a base tag then a TagList must be passed as a seco...
Definition: DataBoxTag.hpp:410
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines arithmetic operators for std::array and other helpful functions.
Defines make_with_value.