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/CreateInitialMesh.hpp"
20 #include "Domain/Domain.hpp"
21 #include "Domain/Element.hpp"
22 #include "Domain/ElementId.hpp"
23 #include "Domain/ElementMap.hpp"
25 #include "Domain/Mesh.hpp"
26 #include "Domain/MinimumGridSpacing.hpp"
27 #include "Domain/Tags.hpp"
28 #include "Domain/TagsTimeDependent.hpp"
29 #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 ElementIndex;
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::Frid>`
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::MeshVelocity<Dim, Frame::Inertial>`
73  * - `domain::Tags::DivMeshVelocity`
74  * - `domain::Tags::MinimumGridSpacing<Dim, Frame::Inertial>>`
75  * - Removes: nothing
76  * - Modifies: nothing
77  */
78 template <size_t Dim>
79 struct Domain {
80  using initialization_tags =
81  tmpl::list<::domain::Tags::InitialExtents<Dim>,
84  using const_global_cache_tags = tmpl::list<::domain::Tags::Domain<Dim>>;
85 
86  template <
87  typename DataBox, typename... InboxTags, typename Metavariables,
88  typename ActionList, typename ParallelComponent,
89  Requires<tmpl::all<initialization_tags,
90  tmpl::bind<db::tag_is_retrievable, tmpl::_1,
91  tmpl::pin<DataBox>>>::value> = nullptr>
92  static auto apply(DataBox& box,
93  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
95  const ElementIndex<Dim>& array_index,
96  const ActionList /*meta*/,
97  const ParallelComponent* const /*meta*/) noexcept {
98  using simple_tags = db::AddSimpleTags<
104 
105  using compute_tags = db::AddComputeTags<
107  // Compute tags for Frame::Grid quantities
109  ::domain::Tags::ElementMap<Dim, Frame::Grid>,
112  ::domain::Tags::ElementMap<Dim, Frame::Grid>,
113  ::domain::Tags::Coordinates<Dim, Frame::Logical>>,
114  // Compute tags for Frame::Inertial quantities
117  Frame::Inertial>>,
118 
123  // Compute tags for other mesh quantities
125 
126  const auto& initial_extents =
127  db::get<::domain::Tags::InitialExtents<Dim>>(box);
128  const auto& initial_refinement =
129  db::get<::domain::Tags::InitialRefinementLevels<Dim>>(box);
130  const auto& domain = db::get<::domain::Tags::Domain<Dim>>(box);
131 
132  const ElementId<Dim> element_id{array_index};
133  const auto& my_block = domain.blocks()[element_id.block_id()];
135  initial_extents, element_id);
137  element_id, my_block, initial_refinement);
138  ElementMap<Dim, Frame::Grid> element_map{
139  element_id, my_block.is_time_dependent()
140  ? my_block.moving_mesh_logical_to_grid_map().get_clone()
141  : my_block.stationary_map().get_to_grid_frame()};
142 
143  const auto& initial_functions_of_time =
144  db::get<::domain::Tags::InitialFunctionsOfTime<Dim>>(box);
145 
148  functions_of_time{};
149  for (const auto& name_and_function : initial_functions_of_time) {
150  functions_of_time.insert(std::make_pair(
151  name_and_function.first, name_and_function.second->get_clone()));
152  }
153 
156  grid_to_inertial_map;
157  if (my_block.is_time_dependent()) {
158  grid_to_inertial_map =
159  my_block.moving_mesh_grid_to_inertial_map().get_clone();
160  } else {
161  grid_to_inertial_map =
162  ::domain::make_coordinate_map_base<Frame::Grid, Frame::Inertial>(
164  }
165 
166  return std::make_tuple(::Initialization::merge_into_databox<
167  Domain, simple_tags, compute_tags,
168  ::Initialization::MergePolicy::Overwrite>(
169  std::move(box), std::move(mesh), std::move(element),
170  std::move(element_map), std::move(grid_to_inertial_map),
171  std::move(functions_of_time)));
172  }
173 
174  template <
175  typename DataBox, typename... InboxTags, typename Metavariables,
176  typename ArrayIndex, typename ActionList, typename ParallelComponent,
177  Requires<not tmpl::all<initialization_tags,
178  tmpl::bind<db::tag_is_retrievable, tmpl::_1,
179  tmpl::pin<DataBox>>>::value> = nullptr>
181  DataBox& /*box*/, const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
183  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
184  const ParallelComponent* const /*meta*/) noexcept {
185  ERROR(
186  "Dependencies not fulfilled. Did you forget to terminate the phase "
187  "after removing options?");
188  }
189 };
190 } // namespace Initialization
191 } // namespace dg
192 } // namespace evolution
The computational grid of the Element in the DataBox.
Definition: Tags.hpp:105
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
Definition: IndexType.hpp:43
Computes the Inertial mesh velocity from CoordinatesVelocityAndJacobians
Definition: TagsTimeDependent.hpp:147
The logical coordinates in the Element.
Definition: LogicalCoordinates.hpp:67
Definition: ConservativeSystem.hpp:50
The initial refinement level per dimension for all elements in each block of the initial computationa...
Definition: Tags.hpp:82
Definition: BlockId.hpp:16
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:44
The functions of time obtained from a domain creator.
Definition: Tags.hpp:26
Functionality related to discontinuous Galerkin schemes.
Definition: ApplyBoundaryFluxesLocalTimeStepping.hpp:33
Holds the number of grid points, basis, and quadrature in each direction of the computational grid...
Definition: Mesh.hpp:50
The coordinate map from logical to grid coordinate.
Definition: Tags.hpp:113
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:28
Computes the Logical to Inertial inverse Jacobian from CoordinatesVelocityAndJacobians ...
Definition: TagsTimeDependent.hpp:109
The coordinates in a given frame.
Definition: Tags.hpp:128
The coordinate map from source to target coordinates.
Definition: Tags.hpp:30
The coordinates in the target frame of MapTag. The SourceCoordsTag&#39;s frame must be the source frame o...
Definition: Tags.hpp:140
Defines class ElementId.
Defines the type alias Requires.
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:133
The CoordinateMap for the Element from the Logical frame to the TargetFrame
Definition: ElementMap.hpp:33
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:21
tmpl::any< typename DataBoxType::tags_list, std::is_base_of< tmpl::pin< Tag >, tmpl::_1 > > tag_is_retrievable
Equal to true if Tag can be retrieved from a DataBox of type DataBoxType.
Definition: DataBox.hpp:74
Computes the Inertial coordinates from CoordinatesVelocityAndJacobians
Definition: TagsTimeDependent.hpp:86
Defines functions logical_coordinates and interface_logical_coordinates.
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
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:1231
A spectral element with knowledge of its neighbors.
Definition: Element.hpp:29
Indicates the Frame that a TensorIndexType is in.
Definition: IndexType.hpp:36
Defines class template Domain.
Computes the inverse Jacobian of the map held by MapTag at the coordinates held by SourceCoordsTag...
Definition: Tags.hpp:172
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:136
Defines the class template Mesh.
Defines class CoordinateMap.
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:1633
Identity map from .
Definition: Identity.hpp:28
Computes the Inertial coordinates, the inverse Jacobian from the Grid to the Inertial frame...
Definition: TagsTimeDependent.hpp:51
Wraps the template metaprogramming library used (brigand)
The divergence of the frame velocity.
Definition: TagsDomain.hpp:26
Defines tags related to domain quantities.
Initialize items related to the basic structure of the element.
Definition: DgDomain.hpp:79
The Element associated with the DataBox.
Definition: Tags.hpp:95
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
Definition: IndexType.hpp:44
Definition: Test_ActionTesting.cpp:365
A class for indexing a Charm array by Element.
Definition: ElementIndex.hpp:53
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines class template ConstGlobalCache.
The minimum coordinate distance between grid points.
Definition: MinimumGridSpacing.hpp:35
Functionality for evolving hyperbolic partial differential equations.
Definition: AddMeshVelocitySourceTerms.hpp:28
The functions of time.
Definition: Tags.hpp:37
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1252
Defines class Element.
Defines the class Identity.