DiscontinuousGalerkin.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 #include <cstddef>
8 #include <tuple>
9 #include <utility>
10 #include <vector>
11 
13 #include "DataStructures/DataBox/PrefixHelpers.hpp"
15 #include "DataStructures/Tensor/EagerMath/Magnitude.hpp"
16 #include "Domain/InterfaceComputeTags.hpp"
17 #include "Domain/Structure/CreateInitialMesh.hpp"
21 #include "Domain/Structure/OrientationMap.hpp"
22 #include "Domain/Tags.hpp"
23 #include "Domain/TagsCharacteresticSpeeds.hpp"
24 #include "Domain/TagsTimeDependent.hpp"
25 #include "NumericalAlgorithms/DiscontinuousGalerkin/MortarHelpers.hpp"
26 #include "NumericalAlgorithms/DiscontinuousGalerkin/NormalDotFlux.hpp"
27 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
29 #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
30 #include "Utilities/Gsl.hpp"
31 #include "Utilities/TMPL.hpp"
32 
33 /// \cond
34 namespace Frame {
35 struct Inertial;
36 } // namespace Frame
37 namespace Parallel {
38 template <typename Metavariables>
39 class GlobalCache;
40 } // namespace Parallel
41 /// \endcond
42 
43 namespace Initialization {
44 namespace Actions {
45 /// \ingroup InitializationGroup
46 /// \brief Initialize items related to the discontinuous Galerkin method.
47 ///
48 /// Uses:
49 /// - DataBox:
50 /// * `Tags::Element<Dim>`
51 /// * `Tags::Mesh<Dim>`
52 /// * `Tags::Next<temporal_id_tag>`
53 /// * `Tags::Interface<Tags::InternalDirections<Dim>, Tags::Mesh<Dim - 1>>`
54 ///
55 /// DataBox changes:
56 /// - Adds:
57 /// * Tags::Interface<Tags::InternalDirections<Dim>,
58 /// normal_dot_fluxes_tag>
59 /// * Tags::Interface<Tags::BoundaryDirectionsInterior<Dim>,
60 /// normal_dot_fluxes_tag>
61 /// * Tags::Interface<Tags::BoundaryDirectionsExterior<Dim>,
62 /// normal_dot_fluxes_tag>
63 /// - Removes: nothing
64 /// - Modifies: nothing
65 ///
66 /// \note This action relies on the `SetupDataBox` aggregated initialization
67 /// mechanism, so `Actions::SetupDataBox` must be present in the
68 /// `Initialization` phase action list prior to this action.
69 template <typename Metavariables>
71  static constexpr size_t dim = Metavariables::system::volume_dim;
72  using boundary_scheme = typename Metavariables::boundary_scheme;
73  using normal_dot_fluxes_tag =
75  typename boundary_scheme::variables_tag>;
76 
77  template <typename Tag>
78  using interface_tag =
80 
81  template <typename Tag>
82  using interior_boundary_tag =
84  Tag>;
85 
86  template <typename Tag>
87  using external_boundary_tag =
89  Tag>;
90 
91  template <typename LocalSystem, bool IsInFluxConservativeForm =
92  LocalSystem::is_in_flux_conservative_form>
93  struct Impl {
94  using simple_tags =
98 
99  template <typename Tag>
100  using interface_compute_tag =
102  Tag>;
103 
104  template <typename Tag>
107 
108  template <typename Tag>
111 
113  typename LocalSystem::char_speeds_compute_tag, dim>;
114 
115  using compute_tags = db::AddComputeTags<
125 
126  template <typename TagsList>
127  static void initialize(
128  const gsl::not_null<db::DataBox<TagsList>*> box) noexcept {
129  const auto& internal_directions =
130  db::get<domain::Tags::InternalDirections<dim>>(*box);
131 
132  const auto& boundary_directions =
133  db::get<domain::Tags::BoundaryDirectionsInterior<dim>>(*box);
134 
136  normal_dot_fluxes_interface{};
137  for (const auto& direction : internal_directions) {
138  const auto& interface_num_points =
139  db::get<interface_tag<domain::Tags::Mesh<dim - 1>>>(*box)
140  .at(direction)
141  .number_of_grid_points();
142  normal_dot_fluxes_interface[direction].initialize(interface_num_points,
143  0.);
144  }
145 
147  normal_dot_fluxes_boundary_exterior{},
148  normal_dot_fluxes_boundary_interior{};
149  for (const auto& direction : boundary_directions) {
150  const auto& boundary_num_points =
152  .at(direction)
153  .number_of_grid_points();
154  normal_dot_fluxes_boundary_exterior[direction].initialize(
155  boundary_num_points, 0.);
156  normal_dot_fluxes_boundary_interior[direction].initialize(
157  boundary_num_points, 0.);
158  }
159  Initialization::mutate_assign<simple_tags>(
160  box, std::move(normal_dot_fluxes_interface),
161  std::move(normal_dot_fluxes_boundary_interior),
162  std::move(normal_dot_fluxes_boundary_exterior));
163  }
164  };
165 
166  template <typename LocalSystem>
167  struct Impl<LocalSystem, true> {
168  using simple_tags = db::AddSimpleTags<>;
169 
170  template <typename Tag>
171  using interface_compute_tag =
173  Tag>;
174 
175  template <typename Tag>
178 
179  template <typename Tag>
182 
184  typename LocalSystem::char_speeds_compute_tag, dim>;
185 
186  using compute_tags = db::AddComputeTags<
190  typename LocalSystem::variables_tag,
191  tmpl::size_t<dim>, Frame::Inertial>>,
193  typename LocalSystem::variables_tag, dim, Frame::Inertial>>,
200  typename LocalSystem::variables_tag,
201  tmpl::size_t<dim>, Frame::Inertial>>,
203  typename LocalSystem::variables_tag, dim, Frame::Inertial>>,
210  typename LocalSystem::variables_tag,
211  tmpl::size_t<dim>, Frame::Inertial>>,
213  typename LocalSystem::variables_tag, dim, Frame::Inertial>>,
217 
218  template <typename TagsList>
219  static auto initialize(
220  const gsl::not_null<db::DataBox<TagsList>*> /*box*/) noexcept {}
221  };
222 
223  using initialization_tags =
224  tmpl::list<domain::Tags::InitialExtents<Metavariables::volume_dim>>;
225 
226  using simple_tags =
227  typename Impl<typename Metavariables::system>::simple_tags;
228 
229  using compute_tags =
230  typename Impl<typename Metavariables::system>::compute_tags;
231 
232  template <typename DbTagsList, typename... InboxTags, typename ArrayIndex,
233  typename ActionList, typename ParallelComponent>
234  static auto apply(db::DataBox<DbTagsList>& box,
235  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
236  const Parallel::GlobalCache<Metavariables>& /*cache*/,
237  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
238  const ParallelComponent* const /*meta*/) noexcept {
240  return std::make_tuple(std::move(box));
241  }
242 };
243 } // namespace Actions
244 } // namespace Initialization
Tags::NormalDotFluxCompute
Prefix computing a boundary unit normal vector dotted into the flux from a flux on the boundary.
Definition: NormalDotFlux.hpp:78
utility
Frame::Inertial
Definition: IndexType.hpp:44
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
Tags.hpp
vector
db::add_tag_prefix
typename detail::add_tag_prefix_impl< Prefix, Tag, Args... >::type add_tag_prefix
Definition: PrefixHelpers.hpp:51
domain::Tags::MeshVelocity
The mesh velocity.
Definition: TagsTimeDependent.hpp:138
db::AddComputeTags
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:809
domain::Tags::Mesh
The computational grid of the Element in the DataBox.
Definition: Tags.hpp:107
domain::Tags::BoundaryDirectionsExterior
Definition: Tags.hpp:323
tuple
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:786
Tags::NormalDotFlux
Prefix indicating a boundary unit normal vector dotted into the flux.
Definition: Prefixes.hpp:96
Tags::Flux
Prefix indicating a flux.
Definition: Prefixes.hpp:40
domain::Tags::BoundaryDirectionsInterior
Definition: Tags.hpp:296
Initialization::Actions::DiscontinuousGalerkin::Impl
Definition: DiscontinuousGalerkin.hpp:93
domain::Tags::Slice
Compute tag for representing a compute item that slices data from the volume to a set of interfaces.
Definition: InterfaceComputeTags.hpp:115
DataBox.hpp
cstddef
Neighbors.hpp
array
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Element.hpp
db::AddSimpleTags
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:802
domain::Tags::CharSpeedCompute
Compute the characteristic speeds on the moving mesh given the characteristic speeds if the mesh were...
Definition: TagsCharacteresticSpeeds.hpp:28
Gsl.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::InterfaceCompute
Compute tag for representing items computed on a set of interfaces. Can be retrieved using Tags::Inte...
Definition: InterfaceComputeTags.hpp:67
Frame
Definition: IndexType.hpp:36
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
Prefixes.hpp
std::unordered_map
Parallel
Functionality for parallelization.
Definition: ElementReceiveInterpPoints.hpp:13
Initialization::Actions::DiscontinuousGalerkin
Initialize items related to the discontinuous Galerkin method.
Definition: DiscontinuousGalerkin.hpp:70
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecThirdOrderPiecewisePolynomial.hpp:13