Mortars.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 #include <boost/functional/hash.hpp>
8 #include <cstddef>
9 #include <optional>
10 #include <tuple>
11 #include <unordered_map>
12 #include <utility>
13 #include <vector>
14 
22 #include "Domain/Structure/OrientationMap.hpp"
23 #include "Domain/Tags.hpp"
24 #include "Evolution/DiscontinuousGalerkin/Initialization/QuadratureTag.hpp"
25 #include "Evolution/DiscontinuousGalerkin/MortarData.hpp"
26 #include "Evolution/DiscontinuousGalerkin/MortarTags.hpp"
27 #include "Evolution/DiscontinuousGalerkin/NormalVectorTags.hpp"
29 #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
30 #include "Time/Tags.hpp"
31 #include "Time/TimeStepId.hpp"
32 #include "Utilities/TMPL.hpp"
33 
34 /// \cond
35 namespace Parallel {
36 template <typename Metavariables>
37 class GlobalCache;
38 } // namespace Parallel
39 namespace tuples {
40 template <class... Tags>
41 class TaggedTuple;
42 } // namespace tuples
43 /// \endcond
44 
46 /*!
47  * \brief Initialize mortars between elements for exchanging boundary correction
48  * terms.
49  *
50  * Uses:
51  * - DataBox:
52  * - `Tags::Element<Dim>`
53  * - `Tags::Mesh<Dim>`
54  * - `BoundaryScheme::receive_temporal_id`
55  *
56  * DataBox changes:
57  * - Adds:
58  * - `Tags::MortarData<Dim>`
59  * - `Tags::MortarMesh<Dim>`
60  * - `Tags::MortarSize<Dim>`
61  * - `Tags::MortarNextTemporalId<Dim>`
62  * - `evolution::dg::Tags::NormalCovectorAndMagnitude<Dim>`
63  * - Removes: nothing
64  * - Modifies: nothing
65  */
66 template <size_t Dim>
67 struct Mortars {
69 
70  template <typename MappedType>
72 
73  public:
74  using initialization_tags = tmpl::list<::domain::Tags::InitialExtents<Dim>,
76 
77  using simple_tags =
78  tmpl::list<Tags::MortarData<Dim>, Tags::MortarMesh<Dim>,
81  using compute_tags = tmpl::list<>;
82 
83  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
84  typename ArrayIndex, typename ActionList,
85  typename ParallelComponent>
86  static auto apply(db::DataBox<DbTagsList>& box,
87  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
88  const Parallel::GlobalCache<Metavariables>& /*cache*/,
89  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
90  const ParallelComponent* const /*meta*/) noexcept {
91  if constexpr (db::tag_is_retrievable_v<::domain::Tags::InitialExtents<Dim>,
92  db::DataBox<DbTagsList>>) {
93  auto [mortar_data, mortar_meshes, mortar_sizes, mortar_next_temporal_ids,
94  normal_covector_quantities] =
95  apply_impl(db::get<::domain::Tags::InitialExtents<Dim>>(box),
96  db::get<evolution::dg::Tags::Quadrature>(box),
98  db::get<::Tags::TimeStepId>(box),
100  ::Initialization::mutate_assign<simple_tags>(
101  make_not_null(&box), std::move(mortar_data), std::move(mortar_meshes),
102  std::move(mortar_sizes), std::move(mortar_next_temporal_ids),
103  std::move(normal_covector_quantities));
104  return std::make_tuple(std::move(box));
105  } else {
106  ERROR(
107  "Missing a tag in the DataBox. Did you forget to terminate the "
108  "phase after removing options? The missing tag is "
109  "'domain::Tags::InitialExtents<Dim>'.");
110  return std::forward_as_tuple(std::move(box));
111  }
112  }
113 
114  private:
115  static std::tuple<
119  DirectionMap<Dim, std::optional<Variables<tmpl::list<
122  apply_impl(const std::vector<std::array<size_t, Dim>>& initial_extents,
123  Spectral::Quadrature quadrature, const Element<Dim>& element,
124  const TimeStepId& next_temporal_id,
125  const Mesh<Dim>& volume_mesh) noexcept;
126 };
127 } // namespace evolution::dg::Initialization
DataBoxTag.hpp
utility
evolution::dg::Tags::Quadrature
The quadrature points to use initially.
Definition: QuadratureTag.hpp:29
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
std::pair
evolution::dg::Tags::NormalCovectorAndMagnitude
The normal covector and its magnitude for all internal faces of an element.
Definition: NormalVectorTags.hpp:35
Tags.hpp
vector
domain::Tags::Element
Definition: Tags.hpp:97
domain::Tags::Mesh
The computational grid of the Element in the DataBox.
Definition: Tags.hpp:107
evolution::dg::Initialization
Functionality for initializing the discontinuous Galerkin to evolve hyperbolic partial differential e...
Definition: Mortars.cpp:23
tuple
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:753
Spectral::MortarSize
MortarSize
The portion of an element covered by a mortar.
Definition: Projection.hpp:18
Element
Definition: Element.hpp:29
ElementId< Dim >
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
DataBox.hpp
evolution::dg::Initialization::Mortars
Initialize mortars between elements for exchanging boundary correction terms.
Definition: Mortars.hpp:67
cstddef
Neighbors.hpp
domain::Tags::InitialExtents
Definition: Tags.hpp:70
array
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
evolution::dg::Tags::MagnitudeOfNormal
The magnitude of the unnormalized normal covector to the interface.
Definition: NormalVectorTags.hpp:18
evolution::dg::Tags::MortarMesh
Mesh on the mortars, indexed by (Direction, ElementId) pairs.
Definition: MortarTags.hpp:36
Spectral::Quadrature
Quadrature
The choice of quadrature method to compute integration weights.
Definition: Spectral.hpp:90
TimeStepId
Definition: TimeStepId.hpp:25
Variables.hpp
Element.hpp
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:48
DirectionMap
Definition: DirectionMap.hpp:15
TimeStepId.hpp
optional
evolution::dg::Tags::NormalCovector
The normal covector to the interface.
Definition: NormalVectorTags.hpp:24
make_not_null
gsl::not_null< T * > make_not_null(T *ptr) noexcept
Construct a not_null from a pointer. Often this will be done as an implicit conversion,...
Definition: Gsl.hpp:880
Direction.hpp
Mesh.hpp
evolution::dg::Tags::MortarNextTemporalId
The next temporal id at which to receive data on the specified mortar.
Definition: MortarTags.hpp:57
Prefixes.hpp
unordered_map
Parallel
Functionality for parallelization.
Definition: ElementReceiveInterpPoints.hpp:13
TMPL.hpp
evolution::dg::Tags::MortarSize
Size of a mortar, relative to the element face. That is, the part of the face that it covers.
Definition: MortarTags.hpp:46