FaceNormal.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Declares function unnormalized_face_normal
6 
7 #pragma once
8 
9 #include <algorithm>
10 #include <cstddef>
11 #include <string>
12 
15 #include "Domain/Tags.hpp" // IWYU pragma: keep
16 #include "Utilities/TMPL.hpp"
17 
18 /// \cond
19 template <typename, typename, size_t>
20 class CoordinateMapBase;
21 class DataVector;
22 template <size_t>
23 class Direction;
24 template <size_t Dim, typename Frame>
25 class ElementMap;
26 template <size_t>
27 class Mesh;
28 /// \endcond
29 
30 // @{
31 /*!
32  * \ingroup ComputationalDomainGroup
33  * \brief Compute the outward grid normal on a face of an Element
34  *
35  * \returns outward grid-frame one-form holding the normal
36  *
37  * \details
38  * Computes the grid-frame normal by taking the logical-frame unit
39  * one-form in the given Direction and mapping it to the grid frame
40  * with the given map.
41  *
42  * \example
43  * \snippet Test_FaceNormal.cpp face_normal_example
44  */
45 template <size_t VolumeDim, typename TargetFrame>
46 tnsr::i<DataVector, VolumeDim, TargetFrame> unnormalized_face_normal(
47  const Mesh<VolumeDim - 1>& interface_mesh,
49  const Direction<VolumeDim>& direction) noexcept;
50 
51 template <size_t VolumeDim, typename TargetFrame>
52 tnsr::i<DataVector, VolumeDim, TargetFrame> unnormalized_face_normal(
53  const Mesh<VolumeDim - 1>& interface_mesh,
55  const Direction<VolumeDim>& direction) noexcept;
56 // @}
57 
58 namespace Tags {
59 /// \ingroup DataBoxTags
60 /// \ingroup ComputationalDomain
61 /// The unnormalized face normal one form
62 template <size_t VolumeDim, typename Frame = ::Frame::Inertial>
64  static std::string name() noexcept { return "UnnormalizedFaceNormal"; }
65  static constexpr tnsr::i<DataVector, VolumeDim, Frame> (*function)(
66  const ::Mesh<VolumeDim - 1>&, const ::ElementMap<VolumeDim, Frame>&,
67  const ::Direction<VolumeDim>&) = unnormalized_face_normal;
68  using argument_tags =
69  tmpl::list<Mesh<VolumeDim - 1>, ElementMap<VolumeDim, Frame>,
71  using volume_tags = tmpl::list<ElementMap<VolumeDim, Frame>>;
72 };
73 
74 /// \ingroup DataBoxTagsGroup
75 /// \ingroup ComputationalDomainGroup
76 /// Specialisation of UnnormalizedFaceNormal for the external boundaries which
77 /// inverts the normals. Since ExternalBoundariesDirections are meant to
78 /// represent ghost elements, the normals should correspond to the normals in
79 /// said element, which are inverted with respect to the current element.
80 template <size_t VolumeDim, typename Frame>
82  UnnormalizedFaceNormal<VolumeDim, Frame>>
83  : db::PrefixTag,
85  Tags::Interface<Tags::BoundaryDirectionsExterior<VolumeDim>,
86  Tags::UnnormalizedFaceNormal<VolumeDim, Frame>> {
88 
89  static std::string name() noexcept {
90  return "BoundaryDirectionsExterior<UnnormalizedFaceNormal>";
91  }
92 
93  static auto function(
94  const db::item_type<Tags::Interface<dirs, Mesh<VolumeDim - 1>>>& meshes,
97  tnsr::i<DataVector, VolumeDim, Frame>>
98  normals{};
99  for (const auto& direction_and_mesh : meshes) {
100  const auto& direction = direction_and_mesh.first;
101  const auto& mesh = direction_and_mesh.second;
102  auto internal_face_normal =
103  unnormalized_face_normal(mesh, map, direction);
104  std::transform(internal_face_normal.begin(), internal_face_normal.end(),
105  internal_face_normal.begin(), std::negate<>());
106  normals[direction] = std::move(internal_face_normal);
107  }
108  return normals;
109  }
110 
111  using argument_tags = tmpl::list<Tags::Interface<dirs, Mesh<VolumeDim - 1>>,
113 };
114 } // namespace Tags
tnsr::i< DataVector, VolumeDim, TargetFrame > unnormalized_face_normal(const Mesh< VolumeDim - 1 > &interface_mesh, const ElementMap< VolumeDim, TargetFrame > &map, const Direction< VolumeDim > &direction) noexcept
Compute the outward grid normal on a face of an Element.
Definition: FaceNormal.cpp:40
The unnormalized face normal one form.
Definition: FaceNormal.hpp:63
Direction to an interface
Definition: Tags.hpp:364
Marks a DataBoxTag as being a compute item that executes a function.
Definition: DataBoxTag.hpp:155
Holds the number of grid points, basis, and quadrature in each direction of the computational grid...
Definition: Mesh.hpp:49
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:49
The CoordinateMap for the Element from the Logical frame to the TargetFrame
Definition: ElementMap.hpp:36
Derived tag for representing a compute item which acts on Tags on an interface. Can be retrieved usin...
Definition: Tags.hpp:440
A particular Side along a particular coordinate Axis.
Definition: Direction.hpp:23
Definition: DataBoxTag.hpp:29
Defines a list of useful type aliases for tensors.
Stores a collection of function values.
Definition: DataVector.hpp:46
Wraps the template metaprogramming library used (brigand)
The computational grid of the Element in the DataBox.
Definition: Tags.hpp:75
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 tags related to domain quantities.
Marks an item as being a prefix to another tag.
Definition: DataBoxTag.hpp:112
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
The set of directions which correspond to external boundaries. To be used to represent data which exi...
Definition: Tags.hpp:177
Tag which is either a SimpleTag for quantities on an interface, base tag to a compute item which acts...
Definition: Tags.hpp:217
The coordinate map from logical to grid coordinate.
Definition: Tags.hpp:84