Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <optional>
7 :
8 : #include "DataStructures/DataBox/DataBox.hpp"
9 : #include "DataStructures/TaggedTuple.hpp"
10 : #include "Parallel/AlgorithmExecution.hpp"
11 : #include "Parallel/ArrayCollection/IsDgElementCollection.hpp"
12 : #include "Parallel/ArrayCollection/SimpleActionOnElement.hpp"
13 : #include "Parallel/GlobalCache.hpp"
14 : #include "Parallel/Invoke.hpp"
15 : #include "ParallelAlgorithms/Interpolation/Actions/ElementReceiveInterpPoints.hpp"
16 : #include "ParallelAlgorithms/Interpolation/InterpolationTargetDetail.hpp"
17 : #include "Utilities/TMPL.hpp"
18 :
19 : namespace intrp {
20 : namespace Actions {
21 :
22 : /// \ingroup ActionsGroup
23 : /// \brief Sends interpolation points to all the Elements.
24 : ///
25 : /// This action is for the case in which the points are time-independent
26 : /// in the frame of the InterpolationTarget (which may or may not mean that
27 : /// the points are time-independent in the grid frame).
28 : ///
29 : /// This action should be placed in the Registration PDAL for
30 : /// InterpolationTarget.
31 : ///
32 : /// Uses:
33 : /// - DataBox:
34 : /// - Anything that the particular
35 : /// InterpolationTargetTag::compute_target_points needs from the DataBox.
36 : ///
37 : /// DataBox changes:
38 : /// - Adds: nothing
39 : /// - Removes: nothing
40 : /// - Modifies: nothing
41 : template <typename InterpolationTargetTag>
42 1 : struct InterpolationTargetSendTimeIndepPointsToElements {
43 : template <typename DbTags, typename... InboxTags, typename ArrayIndex,
44 : typename ActionList, typename Metavariables,
45 : typename ParallelComponent>
46 0 : static Parallel::iterable_action_return_t apply(
47 : db::DataBox<DbTags>& box,
48 : const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
49 : Parallel::GlobalCache<Metavariables>& cache,
50 : const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
51 : const ParallelComponent* const /*meta*/) {
52 : static_assert(
53 : not InterpolationTargetTag::compute_target_points::is_sequential::value,
54 : "Actions::InterpolationTargetSendTimeIndepPointsToElement can be used "
55 : "only with non-sequential targets, since a sequential target is "
56 : "time-dependent by definition.");
57 : auto coords = InterpolationTargetTag::compute_target_points::points(
58 : box, tmpl::type_<Metavariables>{});
59 : using ReceiverProxy =
60 : typename InterpolationTargetTag::template interpolating_component<
61 : Metavariables>;
62 : auto& receiver_proxy =
63 : Parallel::get_parallel_component<ReceiverProxy>(cache);
64 : if constexpr (Parallel::is_dg_element_collection_v<ReceiverProxy>) {
65 : Parallel::threaded_action<Parallel::Actions::SimpleActionOnElement<
66 : ElementReceiveInterpPoints<InterpolationTargetTag>, true>>(
67 : receiver_proxy, std::move(coords));
68 : } else {
69 : Parallel::simple_action<
70 : ElementReceiveInterpPoints<InterpolationTargetTag>>(
71 : receiver_proxy, std::move(coords));
72 : }
73 : return {Parallel::AlgorithmExecution::Continue, std::nullopt};
74 : }
75 : };
76 : } // namespace Actions
77 : } // namespace intrp
|