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 
15 #include "DataStructures/Tensor/EagerMath/Magnitude.hpp"
16 #include "Domain/CreateInitialMesh.hpp"
17 #include "Domain/Direction.hpp"
18 #include "Domain/Element.hpp"
19 #include "Domain/InterfaceComputeTags.hpp"
20 #include "Domain/Mesh.hpp"
21 #include "Domain/Neighbors.hpp"
22 #include "Domain/OrientationMap.hpp"
23 #include "Domain/Tags.hpp"
24 #include "NumericalAlgorithms/DiscontinuousGalerkin/FluxCommunicationTypes.hpp"
25 #include "NumericalAlgorithms/DiscontinuousGalerkin/MortarHelpers.hpp"
26 #include "NumericalAlgorithms/DiscontinuousGalerkin/NormalDotFlux.hpp"
27 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
28 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
29 #include "Utilities/Gsl.hpp"
30 #include "Utilities/TMPL.hpp"
31 
32 /// \cond
33 namespace Frame {
34 struct Inertial;
35 } // namespace Frame
36 namespace Parallel {
37 template <typename Metavariables>
38 class ConstGlobalCache;
39 } // namespace Parallel
40 /// \endcond
41 
42 namespace Initialization {
43 namespace Actions {
44 /// \ingroup InitializationGroup
45 /// \brief Initialize items related to the discontinuous Galerkin method.
46 ///
47 /// Uses:
48 /// - DataBox:
49 /// * `Tags::Element<Dim>`
50 /// * `Tags::Mesh<Dim>`
51 /// * `Tags::Next<temporal_id_tag>`
52 /// * `Tags::Interface<Tags::InternalDirections<Dim>, Tags::Mesh<Dim - 1>>`
53 ///
54 /// DataBox changes:
55 /// - Adds:
56 /// * Tags::Interface<Tags::InternalDirections<Dim>,
57 /// typename flux_comm_types::normal_dot_fluxes_tag>
58 /// * Tags::Interface<Tags::BoundaryDirectionsInterior<Dim>,
59 /// typename flux_comm_types::normal_dot_fluxes_tag>
60 /// * Tags::Interface<Tags::BoundaryDirectionsExterior<Dim>,
61 /// typename flux_comm_types::normal_dot_fluxes_tag>
62 /// - Removes: nothing
63 /// - Modifies: nothing
64 template <typename Metavariables>
66  static constexpr size_t dim = Metavariables::system::volume_dim;
68 
69  template <typename Tag>
71 
72  template <typename Tag>
73  using interior_boundary_tag =
75 
76  template <typename Tag>
77  using external_boundary_tag =
79 
80  template <typename LocalSystem, bool IsInFluxConservativeForm =
81  LocalSystem::is_in_flux_conservative_form>
82  struct Impl {
83  using simple_tags = db::AddSimpleTags<
87  using compute_tags = db::AddComputeTags<>;
88 
89  template <typename TagsList>
90  static auto initialize(db::DataBox<TagsList>&& box) noexcept {
91  const auto& internal_directions =
92  db::get<::Tags::InternalDirections<dim>>(box);
93 
94  const auto& boundary_directions =
95  db::get<::Tags::BoundaryDirectionsInterior<dim>>(box);
96 
97  typename interface_tag<typename flux_comm_types::normal_dot_fluxes_tag>::
98  type normal_dot_fluxes_interface{};
99  for (const auto& direction : internal_directions) {
100  const auto& interface_num_points =
101  db::get<interface_tag<::Tags::Mesh<dim - 1>>>(box)
102  .at(direction)
103  .number_of_grid_points();
104  normal_dot_fluxes_interface[direction].initialize(interface_num_points,
105  0.);
106  }
107 
108  typename interior_boundary_tag<
110  normal_dot_fluxes_boundary_exterior{},
111  normal_dot_fluxes_boundary_interior{};
112  for (const auto& direction : boundary_directions) {
113  const auto& boundary_num_points =
115  .at(direction)
116  .number_of_grid_points();
117  normal_dot_fluxes_boundary_exterior[direction].initialize(
118  boundary_num_points, 0.);
119  normal_dot_fluxes_boundary_interior[direction].initialize(
120  boundary_num_points, 0.);
121  }
122 
124  simple_tags, compute_tags>(
125  std::move(box), std::move(normal_dot_fluxes_interface),
126  std::move(normal_dot_fluxes_boundary_interior),
127  std::move(normal_dot_fluxes_boundary_exterior));
128  }
129  };
130 
131  template <typename LocalSystem>
132  struct Impl<LocalSystem, true> {
133  using simple_tags = db::AddSimpleTags<>;
134 
135  template <typename Tag>
136  using interface_compute_tag =
138 
139  template <typename Tag>
142 
143  template <typename Tag>
146 
147  using char_speed_tag = typename LocalSystem::char_speeds_tag;
148 
149  using compute_tags = db::AddComputeTags<
152  typename LocalSystem::variables_tag,
153  tmpl::size_t<dim>, Frame::Inertial>>,
155  typename LocalSystem::variables_tag, dim, Frame::Inertial>>,
158  db::add_tag_prefix<::Tags::Flux,
159  typename LocalSystem::variables_tag,
160  tmpl::size_t<dim>, Frame::Inertial>>,
162  typename LocalSystem::variables_tag, dim, Frame::Inertial>>,
165  db::add_tag_prefix<::Tags::Flux,
166  typename LocalSystem::variables_tag,
167  tmpl::size_t<dim>, Frame::Inertial>>,
169  typename LocalSystem::variables_tag, dim, Frame::Inertial>>,
171 
172  template <typename TagsList>
173  static auto initialize(db::DataBox<TagsList>&& box) noexcept {
175  simple_tags, compute_tags>(
176  std::move(box));
177  }
178  };
179 
180  using initialization_tags =
181  tmpl::list<::Tags::InitialExtents<Metavariables::volume_dim>>;
182 
183  template <typename DbTagsList, typename... InboxTags, typename ArrayIndex,
184  typename ActionList, typename ParallelComponent>
185  static auto apply(db::DataBox<DbTagsList>& box,
186  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
188  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
189  const ParallelComponent* const /*meta*/) noexcept {
190  return std::make_tuple(
192  }
193 };
194 } // namespace Actions
195 } // namespace Initialization
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:616
Defines class template Direction.
Derived tag for representing a compute item which acts on Tags on an interface. Can be retrieved usin...
Definition: InterfaceComputeTags.hpp:117
Definition: ConservativeSystem.hpp:34
Define prefixes for DataBox tags.
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:132
Prefix computing a boundary unit normal vector dotted into the flux from a flux on the boundary...
Definition: NormalDotFlux.hpp:57
Defines class template Neighbors.
Definition: DiscontinuousGalerkin.hpp:82
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:273
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:1222
Prefix indicating a flux.
Definition: Prefixes.hpp:54
Indicates the Frame that a TensorIndexType is in.
Definition: IndexType.hpp:36
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Types related to flux communication.
Definition: FluxCommunicationTypes.hpp:36
Derived tag for representing a compute item which slices a Tag containing a Tensor or a Variables fro...
Definition: InterfaceComputeTags.hpp:156
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:135
Defines the class template Mesh.
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args) noexcept
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1623
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:1206
Wraps the template metaprogramming library used (brigand)
The computational grid of the Element in the DataBox.
Definition: Tags.hpp:119
Defines functions and classes from the GSL.
Defines tags related to domain quantities.
Definition: IndexType.hpp:44
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Initialize items related to the discontinuous Galerkin method.
Definition: DiscontinuousGalerkin.hpp:65
db::add_tag_prefix< Tags::NormalDotFlux, typename system::variables_tag > normal_dot_fluxes_tag
The DataBox tag for the normal fluxes of the evolved variables.
Definition: FluxCommunicationTypes.hpp:48
Tag which is either a SimpleTag for quantities on an interface, base tag to a compute item which acts...
Definition: Tags.hpp:263
Definition: ComputeTimeDerivative.hpp:28
constexpr T & at(std::array< T, N > &arr, Size index)
Retrieve a entry from a container, with checks in Debug mode that the index being retrieved is valid...
Definition: Gsl.hpp:124
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1243
Defines class Element.