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 <utility> 8 : 9 : #include "DataStructures/DataBox/DataBox.hpp" 10 : #include "Parallel/GlobalCache.hpp" 11 : #include "Parallel/Invoke.hpp" 12 : #include "ParallelAlgorithms/Interpolation/InterpolationTargetDetail.hpp" 13 : #include "Utilities/Gsl.hpp" 14 : #include "Utilities/TMPL.hpp" 15 : 16 : /// \cond 17 : namespace intrp { 18 : template <typename Metavariables, typename InterpolationTargetTag> 19 : struct InterpolationTarget; 20 : namespace Actions { 21 : template <typename InterpolationTargetTag> 22 : struct InterpolationTargetReceiveVars; 23 : } // namespace Actions 24 : } // namespace intrp 25 : /// \endcond 26 : 27 : namespace intrp { 28 : namespace Actions { 29 : /// \ingroup ActionsGroup 30 : /// \brief Sets up points on an `InterpolationTarget` at a new `temporal_id` 31 : /// and sends these points to an `Interpolator`. 32 : /// 33 : /// The `iteration` parameter tags each set of points so the `Interpolator` 34 : /// knows which are newer points and which are older points. 35 : /// 36 : /// \see `intrp::Actions::ReceivePoints` 37 : /// 38 : /// Uses: 39 : /// - DataBox: 40 : /// - `domain::Tags::Domain<3>` 41 : /// 42 : /// DataBox changes: 43 : /// - Adds: nothing 44 : /// - Removes: nothing 45 : /// - Modifies: 46 : /// - `Tags::IndicesOfFilledInterpPoints` 47 : /// - `Tags::IndicesOfInvalidInterpPoints` 48 : /// - `Tags::InterpolatedVars<InterpolationTargetTag, TemporalId>` 49 : /// 50 : /// For requirements on InterpolationTargetTag, see InterpolationTarget 51 : template <typename InterpolationTargetTag> 52 1 : struct SendPointsToInterpolator { 53 : template <typename ParallelComponent, typename DbTags, typename Metavariables, 54 : typename ArrayIndex, typename TemporalId> 55 0 : static void apply(db::DataBox<DbTags>& box, 56 : Parallel::GlobalCache<Metavariables>& cache, 57 : const ArrayIndex& /*array_index*/, 58 : const TemporalId& temporal_id, 59 : const size_t iteration = 0_st) { 60 : auto coords = InterpolationTarget_detail::block_logical_coords< 61 : InterpolationTargetTag>(box, cache, temporal_id); 62 : InterpolationTarget_detail::set_up_interpolation<InterpolationTargetTag>( 63 : make_not_null(&box), temporal_id, coords); 64 : 65 : // If all target points are invalid, we need to notify the target as no 66 : // interpolation is done. 67 : const auto& invalid_points = 68 : db::get<Tags::IndicesOfInvalidInterpPoints<TemporalId>>(box); 69 : if (invalid_points.count(temporal_id) > 0) { 70 : if (coords.size() == invalid_points.at(temporal_id).size()) { 71 : auto& receiver_proxy = Parallel::get_parallel_component< 72 : InterpolationTarget<Metavariables, InterpolationTargetTag>>(cache); 73 : // just send empty vectors for the data and global offsets. 74 : std::vector<Variables< 75 : typename InterpolationTargetTag::vars_to_interpolate_to_target>> 76 : vars{}; 77 : std::vector<std::vector<size_t>> global_offsets{}; 78 : Parallel::simple_action< 79 : Actions::InterpolationTargetReceiveVars<InterpolationTargetTag>>( 80 : receiver_proxy, vars, global_offsets, temporal_id); 81 : } 82 : } 83 : 84 : auto& receiver_proxy = 85 : Parallel::get_parallel_component<Interpolator<Metavariables>>(cache); 86 : Parallel::simple_action<Actions::ReceivePoints<InterpolationTargetTag>>( 87 : receiver_proxy, temporal_id, std::move(coords), iteration); 88 : } 89 : }; 90 : 91 : } // namespace Actions 92 : } // namespace intrp