Interface.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <utility>
8 
11 #include "DataStructures/Tensor/EagerMath/Magnitude.hpp"
12 #include "Domain/FaceNormal.hpp"
15 #include "Utilities/TMPL.hpp"
16 
17 namespace Elliptic {
18 namespace Initialization {
19 
20 /*!
21  * \brief Initializes the DataBox tags related to data on the element faces
22  *
23  * With:
24  * - `face<Tag>` =
25  * `Tags::Interface<Tags::InternalDirections<volume_dim>, Tag>` **and**
26  * `Tags::Interface<Tags::BoundaryDirectionsInterior<volume_dim>, Tag>`
27  * - `ext<Tag>` =
28  * `Tags::Interface<Tags::BoundaryDirectionsExterior<volume_dim>, Tag>`
29  *
30  * Uses:
31  * - System:
32  * - `volume_dim`
33  * - `variables_tag`
34  * - `gradient_tags`
35  * - `magnitude_tag`
36  * - DataBox:
37  * - All items needed by the added compute tags
38  *
39  * DataBox:
40  * - Adds:
41  * - `Tags::InternalDirections<volume_dim>`
42  * - `Tags::BoundaryDirectionsInterior<volume_dim>`
43  * - `face<Tags::Direction<volume_dim>>`
44  * - `face<Tags::Mesh<volume_dim - 1>>`
45  * - `face<variables_tag>` (as a compute tag)
46  * - `face<db::add_tag_prefix<Tags::deriv, db::variables_tag_with_tags_list<
47  * variables_tag, gradient_tags>, tmpl::size_t<volume_dim>, Frame::Inertial>>`
48  * - `face<Tags::Coordinates<volume_dim, Frame::Inertial>>`
49  * - `face<Tags::UnnormalizedFaceNormal<volume_dim>>`
50  * - `face<magnitude_tag<Tags::UnnormalizedFaceNormal<volume_dim>>>`
51  * - `face<Tags::Normalized<Tags::UnnormalizedFaceNormal<volume_dim>>>`
52  * - `Tags::BoundaryDirectionsExterior<volume_dim>`
53  * - `ext<Tags::Direction<volume_dim>>`
54  * - `ext<Tags::Mesh<volume_dim - 1>>`
55  * - `ext<variables_tag>` (as a simple tag)
56  * - `ext<db::add_tag_prefix<Tags::deriv, db::variables_tag_with_tags_list<
57  * variables_tag, gradient_tags>, tmpl::size_t<volume_dim>, Frame::Inertial>>`
58  * - `ext<Tags::UnnormalizedFaceNormal<volume_dim>>`
59  * - `ext<magnitude_tag<Tags::UnnormalizedFaceNormal<volume_dim>>>`
60  * - `ext<Tags::Normalized<Tags::UnnormalizedFaceNormal<volume_dim>>>`
61  */
62 template <typename System>
63 struct Interface {
64  static constexpr size_t volume_dim = System::volume_dim;
65  template <typename Directions>
66  using face_tags = tmpl::list<
67  Directions,
71  Tags::Slice<Directions, db::add_tag_prefix<
72  Tags::deriv,
74  typename System::variables_tag,
75  typename System::gradient_tags>,
76  tmpl::size_t<volume_dim>, Frame::Inertial>>,
79  Tags::InterfaceComputeItem<Directions,
81  Tags::InterfaceComputeItem<Directions,
82  typename System::template magnitude_tag<
83  Tags::UnnormalizedFaceNormal<volume_dim>>>,
85  Directions,
87 
88  using exterior_face_tags = tmpl::list<
92  Tags::InterfaceComputeItem<Tags::BoundaryDirectionsExterior<volume_dim>,
94  // We slice the gradients to the exterior faces, too. This may need to be
95  // reconsidered when boundary conditions are reworked.
97  Tags::BoundaryDirectionsExterior<volume_dim>,
99  Tags::deriv,
100  db::variables_tag_with_tags_list<typename System::variables_tag,
101  typename System::gradient_tags>,
102  tmpl::size_t<volume_dim>, Frame::Inertial>>,
103  Tags::InterfaceComputeItem<Tags::BoundaryDirectionsExterior<volume_dim>,
104  Tags::UnnormalizedFaceNormal<volume_dim>>,
105  Tags::InterfaceComputeItem<Tags::BoundaryDirectionsExterior<volume_dim>,
106  typename System::template magnitude_tag<
107  Tags::UnnormalizedFaceNormal<volume_dim>>>,
109  Tags::BoundaryDirectionsExterior<volume_dim>,
110  Tags::Normalized<Tags::UnnormalizedFaceNormal<volume_dim>>>>;
111 
112  using simple_tags = db::AddSimpleTags<
113  // We rely on the variable data on exterior faces being updated manually.
114  // This may need to be reconsidered when boundary conditions are reworked.
116  typename System::variables_tag>>;
117  using compute_tags =
118  tmpl::append<face_tags<Tags::InternalDirections<volume_dim>>,
119  face_tags<Tags::BoundaryDirectionsInterior<volume_dim>>,
120  exterior_face_tags>;
121 
122  template <typename TagsList>
123  static auto initialize(db::DataBox<TagsList>&& box) noexcept {
124  const auto& mesh = db::get<Tags::Mesh<volume_dim>>(box);
127  external_boundary_vars{};
128 
129  for (const auto& direction :
130  db::get<Tags::Element<volume_dim>>(box).external_boundaries()) {
131  external_boundary_vars[direction] =
133  mesh.slice_away(direction.dimension()).number_of_grid_points()};
134  }
135 
136  return db::create_from<db::RemoveTags<>, simple_tags, compute_tags>(
137  std::move(box), std::move(external_boundary_vars));
138  }
139 };
140 
141 } // namespace Initialization
142 } // namespace Elliptic
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
Items for initializing the DataBoxes of parallel components.
Definition: ConservativeSystem.hpp:21
The normalized (co)vector represented by Tag.
Definition: Magnitude.hpp:93
The unnormalized face normal one form.
Definition: FaceNormal.hpp:68
Direction to an interface
Definition: Tags.hpp:364
Definition: ComputeOperatorAction.hpp:28
Computes the coordinates in the frame Frame on the faces defined by Direction. Intended to be prefixe...
Definition: Tags.hpp:392
Computes the VolumeDim-1 dimensional mesh on an interface from the volume mesh. Tags::InterfaceComput...
Definition: Tags.hpp:375
Derived tag for representing a compute item which acts on Tags on an interface. Can be retrieved usin...
Definition: Tags.hpp:440
Defines classes and functions used for manipulating DataBox&#39;s.
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1227
Initializes the DataBox tags related to data on the element faces.
Definition: Interface.hpp:63
Defines functions computing partial derivatives.
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
typename DataBox_detail::variables_tag_with_tags_list_impl< DataBox_detail::tag_type< Tag > >::template f< Tag, NewTagsList > variables_tag_with_tags_list
Change the tags contained in a possibly prefixed Variables tag.
Definition: DataBoxTag.hpp:576
Derived tag for representing a compute item which slices a Tag containing a Variables from the volume...
Definition: Tags.hpp:479
Declares function unnormalized_face_normal.
The Element associated with the DataBox.
Definition: Tags.hpp:64
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:1211
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
Definition: IndexType.hpp:44
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
Defines functions and tags for taking a divergence.