GrTagsForHydro.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <tuple>
8 #include <utility> // IWYU pragma: keep // for move
9 
11 #include "Domain/CoordinateMaps/Tags.hpp"
12 #include "Domain/FunctionsOfTime/Tags.hpp"
13 #include "Domain/Tags.hpp"
14 #include "Evolution/Initialization/InitialData.hpp"
15 #include "Parallel/GlobalCache.hpp"
16 #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
17 #include "Utilities/TMPL.hpp"
18 #include "Utilities/TaggedTuple.hpp"
19 
20 /// \cond
21 namespace Frame {
22 struct Grid;
23 struct Inertial;
24 } // namespace Frame
25 namespace Initialization {
26 namespace Tags {
27 struct InitialTime;
28 } // namespace Tags
29 } // namespace Initialization
30 namespace Tags {
31 struct AnalyticSolutionOrData;
32 } // namespace Tags
33 namespace domain {
34 namespace Tags {
35 template <size_t Dim, typename Frame>
36 struct Coordinates;
37 template <size_t VolumeDim>
38 struct Mesh;
39 } // namespace Tags
40 } // namespace domain
41 // IWYU pragma: no_forward_declare db::DataBox
42 /// \endcond
43 
44 namespace Initialization {
45 namespace Actions {
46 /// \ingroup InitializationGroup
47 /// \brief Allocate and set general relativity quantities needed for evolution
48 /// of some hydro systems
49 ///
50 /// Uses:
51 /// - DataBox:
52 /// * `Tags::Mesh<Dim>`
53 ///
54 /// DataBox changes:
55 /// - Adds:
56 /// * system::spacetime_variables_tag
57 ///
58 /// - Removes: nothing
59 /// - Modifies: nothing
60 ///
61 /// \note This action relies on the `SetupDataBox` aggregated initialization
62 /// mechanism, so `Actions::SetupDataBox` must be present in the
63 /// `Initialization` phase action list prior to this action.
64 template <typename System>
66  using initialization_tags = tmpl::list<Initialization::Tags::InitialTime>;
67 
68  static constexpr size_t dim = System::volume_dim;
69  using gr_tag = typename System::spacetime_variables_tag;
70 
71  using simple_tags = tmpl::list<gr_tag>;
72  using compute_tags = tmpl::list<>;
73 
74  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
75  typename ArrayIndex, typename ActionList,
76  typename ParallelComponent>
77  static auto apply(db::DataBox<DbTagsList>& box,
78  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
80  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
81  const ParallelComponent* const /*meta*/) noexcept {
82  const double initial_time = db::get<Initialization::Tags::InitialTime>(box);
83  using GrVars = typename gr_tag::type;
84 
85  const size_t num_grid_points =
86  db::get<domain::Tags::Mesh<dim>>(box).number_of_grid_points();
87  const auto inertial_coords =
90  box)(
92  db::get<domain::Tags::Coordinates<dim, Frame::Logical>>(box)),
93  initial_time, db::get<domain::Tags::FunctionsOfTime>(box));
94 
95  // Set initial data from analytic solution
96  GrVars gr_vars{num_grid_points};
97  gr_vars.assign_subset(evolution::initial_data(
98  Parallel::get<::Tags::AnalyticSolutionOrData>(cache), inertial_coords,
99  initial_time, typename GrVars::tags_list{}));
100  Initialization::mutate_assign<simple_tags>(make_not_null(&box),
101  std::move(gr_vars));
102 
103  return std::make_tuple(std::move(box));
104  }
105 };
106 } // namespace Actions
107 } // namespace Initialization
utility
Frame::Inertial
Definition: IndexType.hpp:44
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
Frame::Grid
Definition: IndexType.hpp:43
GlobalCache.hpp
Tags.hpp
tuple
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:791
evolution::initial_data
decltype(auto) initial_data(const SolutionOrData &solution_or_data, Coordinates &&coordinates, const double time, const tmpl::list< Tags... > tags) noexcept
Extract initial data either from analytic data or from an analytic solution at a specified time.
Definition: InitialData.hpp:17
Initialization::Actions::GrTagsForHydro
Allocate and set general relativity quantities needed for evolution of some hydro systems.
Definition: GrTagsForHydro.hpp:65
DataBox.hpp
cstddef
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
domain::CoordinateMaps::Tags::CoordinateMap
Definition: Tags.hpp:30
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:49
ActionTesting::cache
Parallel::GlobalCache< Metavariables > & cache(MockRuntimeSystem< Metavariables > &runner, const ArrayIndex &array_index) noexcept
Returns the GlobalCache of Component with index array_index.
Definition: MockRuntimeSystemFreeFunctions.hpp:382
Frame
Definition: IndexType.hpp:36
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
TMPL.hpp
domain::Tags::ElementMap
Definition: Tags.hpp:115