Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <optional>
8 : #include <tuple>
9 : #include <unordered_set>
10 :
11 : #include "DataStructures/DataBox/DataBox.hpp"
12 : #include "DataStructures/TaggedTuple.hpp"
13 : #include "DataStructures/VariablesTag.hpp"
14 : #include "Parallel/AlgorithmExecution.hpp"
15 : #include "ParallelAlgorithms/Interpolation/Tags.hpp"
16 : #include "Utilities/Requires.hpp"
17 : #include "Utilities/TMPL.hpp"
18 : #include "Utilities/TypeTraits.hpp"
19 : #include "Utilities/TypeTraits/CreateGetTypeAliasOrDefault.hpp"
20 : #include "Utilities/TypeTraits/CreateIsCallable.hpp"
21 :
22 : /// \cond
23 :
24 : namespace Parallel {
25 : template <typename Metavariables>
26 : class GlobalCache;
27 : } // namespace Parallel
28 : /// \endcond
29 :
30 : /// Holds Actions for Interpolator and InterpolationTarget.
31 : namespace intrp::Actions {
32 :
33 : // The purpose of the metafunctions in this namespace is to allow
34 : // InterpolationTarget::compute_target_points to omit an initialize
35 : // function and a compute_tags and simple_tags type alias if it
36 : // doesn't add anything to the DataBox.
37 : namespace initialize_interpolation_target_detail {
38 :
39 : CREATE_GET_TYPE_ALIAS_OR_DEFAULT(compute_tags)
40 : CREATE_GET_TYPE_ALIAS_OR_DEFAULT(simple_tags)
41 : CREATE_IS_CALLABLE(initialize)
42 : CREATE_IS_CALLABLE_V(initialize)
43 :
44 : } // namespace initialize_interpolation_target_detail
45 :
46 : /// \ingroup ActionsGroup
47 : /// \brief Initializes an InterpolationTarget
48 : ///
49 : /// Uses: nothing
50 : ///
51 : /// DataBox changes:
52 : /// - Adds:
53 : /// - `Tags::IndicesOfFilledInterpPoints<TemporalId>`
54 : /// - `Tags::IndicesOfInvalidInterpPoints<TemporalId>`
55 : /// - `Tags::TemporalIds<TemporalId>`
56 : /// - `Tags::CompletedTemporalIds<TemporalId>`
57 : /// - `Tags::InterpolatedVars<InterpolationTargetTag,TemporalId>`
58 : /// - `::Tags::Variables<typename
59 : /// InterpolationTargetTag::vars_to_interpolate_to_target>`
60 : /// - Removes: nothing
61 : /// - Modifies: nothing
62 : ///
63 : /// For requirements on InterpolationTargetTag, see InterpolationTarget
64 : template <typename Metavariables, typename InterpolationTargetTag>
65 1 : struct InitializeInterpolationTarget {
66 0 : using is_sequential =
67 : typename InterpolationTargetTag::compute_target_points::is_sequential;
68 0 : using TemporalId = typename InterpolationTargetTag::temporal_id::type;
69 0 : using return_tag_list_initial = tmpl::list<
70 : Tags::IndicesOfFilledInterpPoints<TemporalId>,
71 : Tags::IndicesOfInvalidInterpPoints<TemporalId>,
72 : Tags::TemporalIds<TemporalId>, Tags::CompletedTemporalIds<TemporalId>,
73 : Tags::InterpolatedVars<InterpolationTargetTag, TemporalId>,
74 : ::Tags::Variables<
75 : typename InterpolationTargetTag::vars_to_interpolate_to_target>>;
76 :
77 0 : using simple_tags = tmpl::append<
78 : return_tag_list_initial,
79 : initialize_interpolation_target_detail::get_simple_tags_or_default_t<
80 : typename InterpolationTargetTag::compute_target_points,
81 : tmpl::list<>>>;
82 0 : using compute_tags = tmpl::append<
83 : initialize_interpolation_target_detail::get_compute_tags_or_default_t<
84 : typename InterpolationTargetTag::compute_target_points, tmpl::list<>>,
85 : typename InterpolationTargetTag::compute_items_on_target>;
86 0 : using const_global_cache_tags = tmpl::list<intrp::Tags::Verbosity>;
87 :
88 : template <typename DbTagsList, typename... InboxTags, typename ArrayIndex,
89 : typename ActionList, typename ParallelComponent>
90 0 : static Parallel::iterable_action_return_t apply(
91 : db::DataBox<DbTagsList>& box,
92 : const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
93 : const Parallel::GlobalCache<Metavariables>& cache,
94 : const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
95 : const ParallelComponent* const /*meta*/) {
96 : if constexpr (
97 : initialize_interpolation_target_detail::is_initialize_callable_v<
98 : typename InterpolationTargetTag::compute_target_points,
99 : const gsl::not_null<db::DataBox<DbTagsList>*>,
100 : const Parallel::GlobalCache<Metavariables>&>) {
101 : InterpolationTargetTag::compute_target_points::initialize(
102 : make_not_null(&box), cache);
103 : }
104 : return {Parallel::AlgorithmExecution::Continue, std::nullopt};
105 : }
106 : };
107 :
108 : } // namespace intrp::Actions
|