DgDomain.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 <memory>
9 #include <tuple>
10 #include <utility>
11 #include <vector>
12 
17 #include "Domain/CoordinateMaps/Tags.hpp"
18 #include "Domain/CreateInitialElement.hpp"
19 #include "Domain/Domain.hpp"
20 #include "Domain/ElementMap.hpp"
22 #include "Domain/MinimumGridSpacing.hpp"
23 #include "Domain/Structure/CreateInitialMesh.hpp"
26 #include "Domain/Tags.hpp"
27 #include "Domain/TagsTimeDependent.hpp"
28 #include "Evolution/TagsDomain.hpp"
31 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
32 #include "Utilities/Requires.hpp"
33 #include "Utilities/TMPL.hpp"
34 #include "Utilities/TaggedTuple.hpp"
35 
36 /// \cond
37 template <size_t VolumeDim>
38 class ElementId;
39 namespace Frame {
40 struct Inertial;
41 } // namespace Frame
42 /// \endcond
43 
44 namespace evolution {
45 namespace dg {
46 namespace Initialization {
47 /*!
48  * \ingroup InitializationGroup
49  * \brief Initialize items related to the basic structure of the element
50  *
51  * ConstGlobalCache:
52  * - Uses:
53  * - `domain::Tags::Domain<Dim, Frame::Inertial>`
54  * DataBox:
55  * - Uses:
56  * - `domain::Tags::InitialExtents<Dim>`
57  * - `domain::Tags::InitialFunctionsOfTime<Dim>`
58  * - Adds:
59  * - `domain::Tags::Mesh<Dim>`
60  * - `domain::Tags::Element<Dim>`
61  * - `domain::Tags::ElementMap<Dim, Frame::Inertial>`
62  * - `domain::CoordinateMaps::Tags::CoordinateMap<Dim, Frame::Grid,
63  * Frame::Inertial>`
64  * - `domain::Tags::FunctionsOfTime`
65  * - `domain::Tags::CoordinatesMeshVelocityAndJacobiansCompute<
66  * CoordinateMap<Dim, Frame::Grid, Frame::Inertial>>`
67  * - `domain::Tags::Coordinates<Dim, Frame::Logical>`
68  * - `domain::Tags::Coordinates<Dim, Frame::Grid>`
69  * - `domain::Tags::Coordinates<Dim, Frame::Inertial>`
70  * - `domain::Tags::InverseJacobian<Dim, Frame::Logical, Frame::Grid>`
71  * - `domain::Tags::InverseJacobian<Dim, Frame::Logical, Frame::Inertial>`
72  * - `domain::Tags::DetInvJacobian<Frame::Logical, Frame::Inertial>`
73  * - `domain::Tags::MeshVelocity<Dim, Frame::Inertial>`
74  * - `domain::Tags::DivMeshVelocity`
75  * - `domain::Tags::MinimumGridSpacing<Dim, Frame::Inertial>>`
76  * - Removes: nothing
77  * - Modifies: nothing
78  */
79 template <size_t Dim>
80 struct Domain {
81  using initialization_tags =
82  tmpl::list<::domain::Tags::InitialExtents<Dim>,
85  using const_global_cache_tags = tmpl::list<::domain::Tags::Domain<Dim>>;
86 
87  template <
88  typename DataBox, typename... InboxTags, typename Metavariables,
89  typename ActionList, typename ParallelComponent,
90  Requires<tmpl::all<initialization_tags,
91  tmpl::bind<db::tag_is_retrievable, tmpl::_1,
92  tmpl::pin<DataBox>>>::value> = nullptr>
93  static auto apply(DataBox& box,
94  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
96  const ElementId<Dim>& array_index,
97  const ActionList /*meta*/,
98  const ParallelComponent* const /*meta*/) noexcept {
99  using simple_tags = db::AddSimpleTags<
105 
106  using compute_tags = db::AddComputeTags<
108  // Compute tags for Frame::Grid quantities
115  // Compute tags for Frame::Inertial quantities
118  Frame::Inertial>>,
119 
126  // Compute tags for other mesh quantities
128 
129  const auto& initial_extents =
130  db::get<::domain::Tags::InitialExtents<Dim>>(box);
131  const auto& initial_refinement =
132  db::get<::domain::Tags::InitialRefinementLevels<Dim>>(box);
133  const auto& domain = db::get<::domain::Tags::Domain<Dim>>(box);
134 
135  const ElementId<Dim> element_id{array_index};
136  const auto& my_block = domain.blocks()[element_id.block_id()];
138  initial_extents, element_id);
140  element_id, my_block, initial_refinement);
141  ElementMap<Dim, Frame::Grid> element_map{
142  element_id, my_block.is_time_dependent()
143  ? my_block.moving_mesh_logical_to_grid_map().get_clone()
144  : my_block.stationary_map().get_to_grid_frame()};
145 
146  const auto& initial_functions_of_time =
147  db::get<::domain::Tags::InitialFunctionsOfTime<Dim>>(box);
148 
151  functions_of_time{};
152  for (const auto& name_and_function : initial_functions_of_time) {
153  functions_of_time.insert(std::make_pair(
154  name_and_function.first, name_and_function.second->get_clone()));
155  }
156 
159  grid_to_inertial_map;
160  if (my_block.is_time_dependent()) {
161  grid_to_inertial_map =
162  my_block.moving_mesh_grid_to_inertial_map().get_clone();
163  } else {
164  grid_to_inertial_map =
165  ::domain::make_coordinate_map_base<Frame::Grid, Frame::Inertial>(
167  }
168 
169  return std::make_tuple(::Initialization::merge_into_databox<
170  Domain, simple_tags, compute_tags,
171  ::Initialization::MergePolicy::Overwrite>(
172  std::move(box), std::move(mesh), std::move(element),
173  std::move(element_map), std::move(grid_to_inertial_map),
174  std::move(functions_of_time)));
175  }
176 
177  template <
178  typename DataBox, typename... InboxTags, typename Metavariables,
179  typename ArrayIndex, typename ActionList, typename ParallelComponent,
180  Requires<not tmpl::all<initialization_tags,
181  tmpl::bind<db::tag_is_retrievable, tmpl::_1,
182  tmpl::pin<DataBox>>>::value> = nullptr>
183  static std::tuple<DataBox&&> apply(
184  DataBox& /*box*/, const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
186  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
187  const ParallelComponent* const /*meta*/) noexcept {
188  ERROR(
189  "Dependencies not fulfilled. Did you forget to terminate the phase "
190  "after removing options?");
191  }
192 };
193 } // namespace Initialization
194 } // namespace dg
195 } // namespace evolution
Parallel::ConstGlobalCache
Definition: ElementReceiveInterpPoints.hpp:16
Identity.hpp
std::string
DataBoxTag.hpp
utility
Frame::Inertial
Definition: IndexType.hpp:44
domain::CoordinateMapBase
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:45
evolution
Functionality for evolving hyperbolic partial differential equations.
Definition: AddMeshVelocityNonconservative.hpp:29
domain::Tags::FunctionsOfTime
The functions of time.
Definition: Tags.hpp:37
domain::Tags::DetInvJacobianCompute
Definition: Tags.hpp:209
domain::Tags::Coordinates
Definition: Tags.hpp:129
Frame::Grid
Definition: IndexType.hpp:43
Tags.hpp
vector
domain::Tags::Element
Definition: Tags.hpp:96
Domain.hpp
domain::Tags::CoordinatesMeshVelocityAndJacobiansCompute
Computes the Inertial coordinates, the inverse Jacobian from the Grid to the Inertial frame,...
Definition: TagsTimeDependent.hpp:51
db::AddComputeTags
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1171
domain::Tags::Mesh
The computational grid of the Element in the DataBox.
Definition: Tags.hpp:106
domain::Tags::ElementToInertialInverseJacobian
Computes the Logical to Inertial inverse Jacobian from CoordinatesVelocityAndJacobians
Definition: TagsTimeDependent.hpp:109
tuple
CoordinateMap.hpp
dg
Functionality related to discontinuous Galerkin schemes.
Definition: ComputeNonconservativeBoundaryFluxes.hpp:23
Element
Definition: Element.hpp:29
domain::Tags::InverseJacobianCompute
Definition: Tags.hpp:176
ElementId
An ElementId uniquely labels an Element.
Definition: ElementId.hpp:49
ElementId.hpp
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
evolution::domain::Tags::DivMeshVelocityCompute
The divergence of the frame velocity.
Definition: TagsDomain.hpp:26
DataBox.hpp
cstddef
domain::Tags::InitialFunctionsOfTime
The functions of time obtained from a domain creator.
Definition: Tags.hpp:26
db::tag_is_retrievable
tmpl::any< typename DataBoxType::tags_list, std::is_base_of< tmpl::pin< Tag >, tmpl::_1 > > tag_is_retrievable
Definition: DataBox.hpp:74
evolution::dg::Initialization::Domain
Initialize items related to the basic structure of the element.
Definition: DgDomain.hpp:80
array
LogicalCoordinates.hpp
domain::Tags::LogicalCoordinates
Definition: LogicalCoordinates.hpp:78
ElementMap
The CoordinateMap for the Element from the Logical frame to the TargetFrame
Definition: ElementMap.hpp:33
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
domain::Tags::InertialFromGridCoordinatesCompute
Computes the Inertial coordinates from CoordinatesVelocityAndJacobians
Definition: TagsTimeDependent.hpp:86
domain::Tags::MappedCoordinates
Definition: Tags.hpp:141
memory
domain::Tags::InertialMeshVelocityCompute
Computes the Inertial mesh velocity from CoordinatesVelocityAndJacobians
Definition: TagsTimeDependent.hpp:147
domain::CoordinateMaps::Tags::CoordinateMap
Definition: Tags.hpp:30
Element.hpp
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:50
db::AddSimpleTags
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1150
domain::CoordinateMaps::Identity
Definition: Identity.hpp:28
domain::Tags::InitialRefinementLevels
Definition: Tags.hpp:83
Frame
Definition: IndexType.hpp:36
Requires.hpp
domain::Initialization::create_initial_element
Element< VolumeDim > create_initial_element(const ElementId< VolumeDim > &element_id, const Block< VolumeDim > &block, const std::vector< std::array< size_t, VolumeDim >> &initial_refinement_levels) noexcept
Creates an initial element of a Block.
Definition: CreateInitialElement.cpp:27
Frame::Logical
Definition: IndexType.hpp:42
Initialization::merge_into_databox
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:133
Requires
typename Requires_detail::requires_impl< B >::template_error_type_failed_to_meet_requirements_on_template_parameters Requires
Express requirements on the template parameters of a function or class, replaces std::enable_if_t
Definition: Requires.hpp:67
Mesh.hpp
std::unique_ptr
std::unordered_map
domain::Initialization::create_initial_mesh
Mesh< Dim > create_initial_mesh(const std::vector< std::array< size_t, Dim >> &initial_extents, const ElementId< Dim > &element_id, const OrientationMap< Dim > &orientation) noexcept
Construct the initial Mesh of an Element.
Definition: CreateInitialMesh.cpp:20
TMPL.hpp
ConstGlobalCache.hpp
domain::Tags::MinimumGridSpacing
Definition: MinimumGridSpacing.hpp:35
domain::Tags::ElementMap
Definition: Tags.hpp:114