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