InitializeInterpolationTarget.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 <unordered_set>
9 
12 #include "Domain/Domain.hpp"
13 #include "Domain/Tags.hpp" // IWYU pragma: keep
14 #include "NumericalAlgorithms/Interpolation/Tags.hpp" // IWYU pragma: keep
15 #include "Utilities/Requires.hpp"
16 #include "Utilities/TMPL.hpp"
18 #include "Utilities/TypeTraits.hpp"
19 
20 /// \cond
21 // IWYU pragma: no_forward_declare db::DataBox
22 namespace Parallel {
23 template <typename Metavariables>
24 class ConstGlobalCache;
25 } // namespace Parallel
26 namespace Tags {
27 template <typename TagsList>
28 struct Variables;
29 } // namespace Tags
30 /// \endcond
31 
32 namespace intrp {
33 
34 /// Holds Actions for Interpolator and InterpolationTarget.
35 namespace Actions {
36 
37 // The purpose of the functions and metafunctions in this
38 // namespace is to allow InterpolationTarget::compute_target_points
39 // to omit an initialize function and a initialization_tags
40 // type alias if it doesn't add anything to the DataBox.
41 namespace initialize_interpolation_target_detail {
42 
43 // Sets type to initialization_tags, or
44 // to empty list if initialization_tags is not defined.
45 template <typename T, typename = cpp17::void_t<>>
46 struct initialization_tags {
47  using type = tmpl::list<>;
48 };
49 
50 template <typename T>
51 struct initialization_tags<
52  T, cpp17::void_t<typename T::compute_target_points::initialization_tags>> {
53  using type = typename T::compute_target_points::initialization_tags;
54 };
55 
56 // Tests whether T::compute_target_points has a non-empty
57 // initialization_tags member.
58 template <typename T>
59 constexpr bool has_empty_initialization_tags_v =
60  tmpl::size<typename initialization_tags<T>::type>::value == 0;
61 
62 // Calls initialization function only if initialization_tags is defined
63 // and non-empty; otherwise just moves the box.
64 template <
65  typename InterpolationTargetTag, typename DbTags, typename Metavariables,
67  nullptr>
68 auto make_tuple_of_box(
69  db::DataBox<DbTags>&& box,
70  const Parallel::ConstGlobalCache<Metavariables>& cache) noexcept {
71  return std::make_tuple(
72  InterpolationTargetTag::compute_target_points::initialize(std::move(box),
73  cache));
74 }
75 
76 template <
77  typename InterpolationTargetTag, typename DbTags, typename Metavariables,
79 auto make_tuple_of_box(
80  db::DataBox<DbTags>&& box,
81  const Parallel::ConstGlobalCache<Metavariables>& /*cache*/) noexcept {
82  return std::make_tuple(std::move(box));
83 }
84 
85 } // namespace initialize_interpolation_target_detail
86 
87 /// \ingroup ActionsGroup
88 /// \brief Initializes an InterpolationTarget
89 ///
90 /// Uses: nothing
91 ///
92 /// DataBox changes:
93 /// - Adds:
94 /// - `Tags::IndicesOfFilledInterpPoints`
95 /// - `Tags::TemporalIds<Metavariables>`
96 /// - `::Tags::Domain<VolumeDim, Frame>`
97 /// - `::Tags::Variables<typename
98 /// InterpolationTargetTag::vars_to_interpolate_to_target>`
99 /// - Removes: nothing
100 /// - Modifies: nothing
101 ///
102 /// For requirements on InterpolationTargetTag, see InterpolationTarget
103 template <typename InterpolationTargetTag>
105  /// For requirements on Metavariables, see InterpolationTarget
106  template <typename Metavariables>
107  using return_tag_list_initial = tmpl::list<
109  ::Tags::Domain<Metavariables::domain_dim,
110  typename Metavariables::domain_frame>,
112  typename InterpolationTargetTag::vars_to_interpolate_to_target>>;
113  template <typename Metavariables>
114  using return_tag_list =
115  tmpl::append<return_tag_list_initial<Metavariables>,
116  typename initialize_interpolation_target_detail::
117  initialization_tags<InterpolationTargetTag>::type>;
118  template <typename... InboxTags, typename Metavariables, typename ArrayIndex,
119  typename ActionList, typename ParallelComponent>
120  static auto apply(
121  const db::DataBox<tmpl::list<>>& /*box*/,
122  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
124  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
125  const ParallelComponent* const /*meta*/,
127  domain) noexcept {
128  auto box = db::create<
133  typename InterpolationTargetTag::vars_to_interpolate_to_target>>{});
134 
135  return initialize_interpolation_target_detail::make_tuple_of_box<
136  InterpolationTargetTag>(std::move(box), cache);
137  }
138 };
139 
140 } // namespace Actions
141 } // namespace intrp
tmpl::list< Tags::IndicesOfFilledInterpPoints, Tags::TemporalIds< Metavariables >, ::Tags::Domain< Metavariables::domain_dim, typename Metavariables::domain_frame >, ::Tags::Variables< typename InterpolationTargetTag::vars_to_interpolate_to_target > > return_tag_list_initial
For requirements on Metavariables, see InterpolationTarget.
Definition: InitializeInterpolationTarget.hpp:112
Definition: Variables.hpp:46
Defines class tuples::TaggedTuple.
Definition: BlockId.hpp:16
void void_t
Given a set of types, returns void
Definition: TypeTraits.hpp:214
Definition: AddTemporalIdsToInterpolationTarget.hpp:17
constexpr auto create(Args &&... args)
Create a new DataBox.
Definition: DataBox.hpp:1259
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
Keeps track of which points have been filled with interpolated data.
Definition: Tags.hpp:31
Defines the type alias Requires.
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args)
Apply the function f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1595
Defines class template Domain.
temporal_ids on which to interpolate.
Definition: InterpolationTargetWedgeSectionTorus.hpp:29
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines classes and functions used for manipulating DataBox&#39;s.
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Definition: DataBoxTag.hpp:29
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:38
tmpl::filter< TagList, tmpl::not_< tmpl::bind< db::is_compute_item, tmpl::_1 > >> get_items
Get all the Tags that are items from the TagList
Definition: DataBox.hpp:1807
The Domain.
Definition: Tags.hpp:55
Wraps the template metaprogramming library used (brigand)
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that is returned by the Tag. If it is a base tag then a TagList must be passed as a seco...
Definition: DataBoxTag.hpp:410
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
C++ STL code present in C++17.
Definition: Array.hpp:16
Definition: SolvePoissonProblem.hpp:38
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines type traits, some of which are future STL type_traits header.
Initializes an InterpolationTarget.
Definition: InitializeInterpolationTarget.hpp:104
Definition: ComputeTimeDerivative.hpp:28