InitializeDomain.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 
14 #include "Domain/CreateInitialElement.hpp"
15 #include "Domain/CreateInitialMesh.hpp"
16 #include "Domain/Domain.hpp"
17 #include "Domain/Element.hpp"
18 #include "Domain/ElementId.hpp"
19 #include "Domain/ElementMap.hpp"
21 #include "Domain/Mesh.hpp"
22 #include "Domain/MinimumGridSpacing.hpp"
23 #include "Domain/Tags.hpp"
25 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
26 #include "Utilities/Requires.hpp"
27 #include "Utilities/TMPL.hpp"
29 
30 /// \cond
31 template <size_t VolumeDim>
32 class ElementIndex;
33 namespace Frame {
34 struct Inertial;
35 } // namespace Frame
36 /// \endcond
37 
38 namespace dg {
39 namespace Actions {
40 /*!
41  * \ingroup InitializationGroup
42  * \brief Initialize items related to the basic structure of the element
43  *
44  * ConstGlobalCache:
45  * - Uses:
46  * - `Tags::Domain<Dim, Frame::Inertial>`
47  * DataBox:
48  * - Uses:
49  * - `Tags::InitialExtents<Dim>`
50  * - Adds:
51  * - `Tags::Mesh<Dim>`
52  * - `Tags::Element<Dim>`
53  * - `Tags::ElementMap<Dim, Frame::Inertial>`
54  * - `Tags::Coordinates<Dim, Frame::Logical>`
55  * - `Tags::Coordinates<Dim, Frame::Inertial>`
56  * - `Tags::InverseJacobian<
57  * Tags::ElementMap<Dim>, Tags::Coordinates<Dim, Frame::Logical>>`
58  * - `Tags::MinimumGridSpacing<Dim, Frame::Inertial>>`
59  * - Removes: nothing
60  * - Modifies: nothing
61  */
62 template <size_t Dim>
64  using initialization_tags = tmpl::list<::Tags::InitialExtents<Dim>>;
65 
66  template <typename DataBox, typename... InboxTags, typename Metavariables,
67  typename ActionList, typename ParallelComponent,
69  DataBox>> = nullptr>
70  static auto apply(DataBox& box,
71  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
73  const ElementIndex<Dim>& array_index,
74  const ActionList /*meta*/,
75  const ParallelComponent* const /*meta*/) noexcept {
76  using simple_tags =
79  using compute_tags = tmpl::append<db::AddComputeTags<
84  ::Tags::Coordinates<Dim, Frame::Logical>>,
86 
87  const auto& initial_extents = db::get<::Tags::InitialExtents<Dim>>(box);
88  const auto& domain = db::get<::Tags::Domain<Dim, Frame::Inertial>>(box);
89 
90  const ElementId<Dim> element_id{array_index};
91  const auto& my_block = domain.blocks()[element_id.block_id()];
93  initial_extents, element_id);
94  Element<Dim> element =
97  element_id, my_block.coordinate_map().get_clone()};
98 
99  return std::make_tuple(
101  compute_tags>(
102  std::move(box), std::move(mesh), std::move(element),
103  std::move(element_map)));
104  }
105 
106  template <typename DataBox, typename... InboxTags, typename Metavariables,
107  typename ArrayIndex, typename ActionList,
108  typename ParallelComponent,
110  DataBox>> = nullptr>
112  DataBox& /*box*/, const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
114  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
115  const ParallelComponent* const /*meta*/) noexcept {
116  ERROR(
117  "Dependencies not fulfilled. Did you forget to terminate the phase "
118  "after removing options?");
119  }
120 };
121 } // namespace Actions
122 } // namespace dg
Defines class tuples::TaggedTuple.
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
Definition: BlockId.hpp:16
Definition: ApplyBoundaryFluxesLocalTimeStepping.hpp:33
Holds the number of grid points, basis, and quadrature in each direction of the computational grid...
Definition: Mesh.hpp:49
Element< VolumeDim > create_initial_element(const ElementId< VolumeDim > &element_id, const Block< VolumeDim, TargetFrame > &block) noexcept
Creates an initial element of a Block.
Definition: CreateInitialElement.cpp:29
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:132
Initialize items related to the basic structure of the element.
Definition: InitializeDomain.hpp:63
The CoordinateMap for the Element from the Logical frame to the TargetFrame
Definition: ElementMap.hpp:38
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
Defines functions logical_coordinates and interface_logical_coordinates.
Computes the inverse Jacobian of the map held by MapTag at the coordinates held by SourceCoordsTag...
Definition: Tags.hpp:169
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:273
Defines classes and functions used for manipulating DataBox&#39;s.
The minimum coordinate distance between grid points.
Definition: MinimumGridSpacing.hpp:34
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1222
The logical coordinates in the Element.
Definition: LogicalCoordinates.hpp:64
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.
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:135
Defines the class template Mesh.
The coordinates in a given frame.
Definition: Tags.hpp:139
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
The Element associated with the DataBox.
Definition: Tags.hpp:108
Wraps the template metaprogramming library used (brigand)
The coordinates in the target frame of MapTag. The SourceCoordsTag&#39;s frame must be the source frame o...
Definition: Tags.hpp:151
Defines tags related to domain quantities.
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
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 coordinate map from logical to grid coordinate.
Definition: Tags.hpp:128
Definition: ComputeTimeDerivative.hpp:28
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1243
Defines class Element.