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 <tuple>
10 #include <unordered_map>
11 #include <utility>
12 #include <vector>
13 
20 #include "Domain/Structure/OrientationMap.hpp"
21 #include "Domain/Tags.hpp"
22 #include "Evolution/DiscontinuousGalerkin/MortarData.hpp"
23 #include "Evolution/DiscontinuousGalerkin/MortarTags.hpp"
25 #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
26 #include "Time/Tags.hpp"
27 #include "Time/TimeStepId.hpp"
28 #include "Utilities/TMPL.hpp"
29 
30 /// \cond
31 namespace Parallel {
32 template <typename Metavariables>
33 class GlobalCache;
34 } // namespace Parallel
35 namespace tuples {
36 template <class... Tags>
37 class TaggedTuple;
38 } // namespace tuples
39 /// \endcond
40 
42 /*!
43  * \brief Initialize mortars between elements for exchanging boundary correction
44  * terms.
45  *
46  * If the template parameter `AddFluxBoundaryConditionMortars`
47  * is set to `false` then the mortar data for flux boundary conditions are not
48  * initialized and other boundary conditions can be applied. In this case, the
49  * `Tags::Mortar*` tags have no entries for external boundary directions.
50  *
51  * Uses:
52  * - DataBox:
53  * - `Tags::Element<Dim>`
54  * - `Tags::Mesh<Dim>`
55  * - `BoundaryScheme::receive_temporal_id`
56  * - `Tags::Interface<Tags::InternalDirections<Dim>, Tags::Mesh<Dim - 1>>`
57  * - `Tags::Interface<
58  * Tags::BoundaryDirectionsInterior<Dim>, Tags::Mesh<Dim - 1>>`
59  *
60  * DataBox changes:
61  * - Adds:
62  * - `Tags::MortarData<Dim>`
63  * - `Tags::MortarMesh<Dim>`
64  * - `Tags::MortarSize<Dim>`
65  * - `Tags::MortarNextTemporalId<Dim>`
66  * - Removes: nothing
67  * - Modifies: nothing
68  */
69 template <size_t Dim, bool AddFluxBoundaryConditionMortars = true>
70 struct Mortars {
72 
73  template <typename MappedType>
75 
76  public:
77  using initialization_tags = tmpl::list<::domain::Tags::InitialExtents<Dim>>;
78 
79  using simple_tags =
80  tmpl::list<Tags::MortarData<Dim>, Tags::MortarMesh<Dim>,
82  using compute_tags = tmpl::list<>;
83 
84  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
85  typename ArrayIndex, typename ActionList,
86  typename ParallelComponent>
87  static auto apply(db::DataBox<DbTagsList>& box,
88  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
89  const Parallel::GlobalCache<Metavariables>& /*cache*/,
90  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
91  const ParallelComponent* const /*meta*/) noexcept {
92  if constexpr (db::tag_is_retrievable_v<::domain::Tags::InitialExtents<Dim>,
93  db::DataBox<DbTagsList>>) {
94  auto [mortar_data, mortar_meshes, mortar_sizes,
95  mortar_next_temporal_ids] =
96  apply_impl(db::get<::domain::Tags::InitialExtents<Dim>>(box),
97  Spectral::Quadrature::GaussLobatto,
99  db::get<::Tags::TimeStepId>(box),
105  ::domain::Tags::Mesh<Dim - 1>>>(box));
106  ::Initialization::mutate_assign<simple_tags>(
107  make_not_null(&box), std::move(mortar_data), std::move(mortar_meshes),
108  std::move(mortar_sizes), std::move(mortar_next_temporal_ids));
109  return std::make_tuple(std::move(box));
110  } else {
111  ERROR(
112  "Missing a tag in the DataBox. Did you forget to terminate the "
113  "phase after removing options? The missing tag is "
114  "'domain::Tags::InitialExtents<Dim>'.");
115  return std::forward_as_tuple(std::move(box));
116  }
117  }
118 
119  private:
121  MortarMap<Mesh<Dim - 1>>,
124  apply_impl(
125  const std::vector<std::array<size_t, Dim>>& initial_extents,
126  Spectral::Quadrature quadrature, const Element<Dim>& element,
127  const TimeStepId& next_temporal_id,
128  const std::unordered_map<Direction<Dim>, Mesh<Dim - 1>>& interface_meshes,
130  boundary_meshes) noexcept;
131 };
132 } // namespace evolution::dg::Initialization
DataBoxTag.hpp
utility
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
std::pair
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:969
domain::Tags::BoundaryDirectionsInterior
Definition: Tags.hpp:296
Direction
Definition: Direction.hpp:23
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:70
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::MortarMesh
Mesh on the mortars, indexed by (Direction, ElementId) pairs.
Definition: MortarTags.hpp:35
Spectral::Quadrature
Quadrature
The choice of quadrature method to compute integration weights.
Definition: Spectral.hpp:90
TimeStepId
Definition: TimeStepId.hpp:25
Element.hpp
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:47
TimeStepId.hpp
domain::Tags::Interface
Tag which is either a SimpleTag for quantities on an interface, base tag to a compute item which acts...
Definition: Tags.hpp:365
domain::Tags::InternalDirections
Definition: Tags.hpp:269
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:56
Prefixes.hpp
unordered_map
Parallel
Contains functions that forward to Charm++ parallel functions.
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:45