GrTagsForHydro.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> // IWYU pragma: keep
10 #include <vector>
11 
15 #include "DataStructures/Variables.hpp" // IWYU pragma: keep
16 #include "Domain/Mesh.hpp"
17 #include "Domain/Tags.hpp"
18 #include "Evolution/Initialization/Tags.hpp"
19 #include "Evolution/TypeTraits.hpp"
21 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
22 #include "PointwiseFunctions/AnalyticData/Tags.hpp"
23 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
24 #include "Utilities/Gsl.hpp"
25 #include "Utilities/TMPL.hpp"
26 #include "Utilities/TypeTraits.hpp"
27 
28 namespace Initialization {
29 namespace Actions {
30 /// \ingroup InitializationGroup
31 /// \brief Allocate and set general relativity quantities needed for evolution
32 /// of some hydro systems
33 ///
34 /// Uses:
35 /// - DataBox:
36 /// * `Tags::Mesh<Dim>`
37 ///
38 /// DataBox changes:
39 /// - Adds:
40 /// * system::spacetime_variables_tag
41 ///
42 /// - Removes: nothing
43 /// - Modifies: nothing
45  using initialization_tags = tmpl::list<Initialization::Tags::InitialTime>;
46 
47  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
48  typename ArrayIndex, typename ActionList,
49  typename ParallelComponent>
50  static auto apply(db::DataBox<DbTagsList>& box,
51  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
53  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
54  const ParallelComponent* const /*meta*/) noexcept {
55  using system = typename Metavariables::system;
56  static constexpr size_t dim = system::volume_dim;
57  using gr_tag = typename system::spacetime_variables_tag;
58  using simple_tags = db::AddSimpleTags<gr_tag>;
59  using compute_tags = db::AddComputeTags<>;
60 
61  const double initial_time = db::get<Initialization::Tags::InitialTime>(box);
62  using GrVars = typename gr_tag::type;
63 
64  const size_t num_grid_points =
65  db::get<::Tags::Mesh<dim>>(box).number_of_grid_points();
66  const auto& inertial_coords =
67  db::get<::Tags::Coordinates<dim, Frame::Inertial>>(box);
68 
69  // Set initial data from analytic solution
70  GrVars gr_vars{num_grid_points};
72  [ initial_time, &inertial_coords ](
73  std::true_type /*is_analytic_solution*/,
74  const gsl::not_null<GrVars*> local_gr_vars,
75  const auto& local_cache) noexcept {
76  using solution_tag = ::Tags::AnalyticSolutionBase;
77  local_gr_vars->assign_subset(
78  Parallel::get<solution_tag>(local_cache)
79  .variables(inertial_coords, initial_time,
80  typename GrVars::tags_list{}));
81  },
82  [&inertial_coords](std::false_type /*is_analytic_solution*/,
83  const gsl::not_null<GrVars*> local_gr_vars,
84  const auto& local_cache) noexcept {
85  using analytic_data_tag = ::Tags::AnalyticDataBase;
86  local_gr_vars->assign_subset(
87  Parallel::get<analytic_data_tag>(local_cache)
88  .variables(inertial_coords, typename GrVars::tags_list{}));
89  })(
90  evolution::is_analytic_solution<typename Metavariables::initial_data>{},
91  make_not_null(&gr_vars), cache);
92 
93  return std::make_tuple(
95  compute_tags>(std::move(box),
96  std::move(gr_vars)));
97  }
98 };
99 } // namespace Actions
100 } // namespace Initialization
Definition: ConservativeSystem.hpp:34
Overloader< Fs... > make_overloader(Fs... fs)
Create Overloader<Fs...>, see Overloader for details.
Definition: Overloader.hpp:109
Can be used to retrieve the analytic solution from the cache without having to know the template para...
Definition: Tags.hpp:40
Define prefixes for DataBox tags.
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:132
Allocate and set general relativity quantities needed for evolution of some hydro systems...
Definition: GrTagsForHydro.hpp:44
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
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Defines class Variables.
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:135
Defines the class template Mesh.
Can be used to retrieve the analytic solution from the cache without having to know the template para...
Definition: Tags.hpp:33
Wraps the template metaprogramming library used (brigand)
Defines functions and classes from the GSL.
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, but it may be necessary to perform the conversion explicitly when type deduction is desired.
Definition: Gsl.hpp:879
Defines tags related to domain quantities.
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines class template ConstGlobalCache.
Defines type traits, some of which are future STL type_traits header.
Definition: ComputeTimeDerivative.hpp:28
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1243