Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <array> 7 : #include <cstddef> 8 : #include <string> 9 : #include <utility> 10 : #include <vector> 11 : 12 : #include "DataStructures/DataBox/TagName.hpp" 13 : #include "IO/Observer/ReductionActions.hpp" 14 : #include "Parallel/GlobalCache.hpp" 15 : #include "Parallel/Info.hpp" 16 : #include "Parallel/Invoke.hpp" 17 : #include "Parallel/Local.hpp" 18 : #include "Parallel/Reduction.hpp" 19 : #include "ParallelAlgorithms/Interpolation/InterpolationTargetDetail.hpp" 20 : #include "ParallelAlgorithms/Interpolation/Protocols/PostInterpolationCallback.hpp" 21 : #include "Utilities/Functional.hpp" 22 : #include "Utilities/Gsl.hpp" 23 : #include "Utilities/PrettyType.hpp" 24 : #include "Utilities/ProtocolHelpers.hpp" 25 : #include "Utilities/TMPL.hpp" 26 : 27 : /// \cond 28 : namespace db { 29 : template <typename TagsList> 30 : class DataBox; 31 : } // namespace db 32 : namespace observers { 33 : template <class Metavariables> 34 : struct ObserverWriter; 35 : } // namespace observers 36 : /// \endcond 37 : 38 : namespace intrp { 39 : namespace callbacks { 40 : 41 : namespace detail { 42 : 43 : template <typename... Ts> 44 : auto make_legend(tmpl::list<Ts...> /* meta */) { 45 : return std::vector<std::string>{"Time", db::tag_name<Ts>()...}; 46 : } 47 : 48 : template <typename DbTags, typename... Ts> 49 : auto make_reduction_data(const db::DataBox<DbTags>& box, double time, 50 : tmpl::list<Ts...> /* meta */) { 51 : return std::make_tuple(time, get<Ts>(box)...); 52 : } 53 : 54 : } // namespace detail 55 : 56 : /// \brief post_interpolation_callback that outputs 57 : /// a time series on a surface. 58 : /// 59 : /// Uses: 60 : /// - Metavariables 61 : /// - `temporal_id` 62 : /// - DataBox: 63 : /// - `TagsToObserve` 64 : /// 65 : /// Conforms to the intrp::protocols::PostInterpolationCallback protocol 66 : /// 67 : /// For requirements on InterpolationTargetTag, see 68 : /// intrp::protocols::InterpolationTargetTag 69 : template <typename TagsToObserve, typename InterpolationTargetTag> 70 1 : struct ObserveTimeSeriesOnSurface 71 : : tt::ConformsTo<intrp::protocols::PostInterpolationCallback> { 72 0 : static constexpr double fill_invalid_points_with = 73 : std::numeric_limits<double>::quiet_NaN(); 74 : 75 : template <typename DbTags, typename Metavariables, typename TemporalId> 76 0 : static void apply(const db::DataBox<DbTags>& box, 77 : Parallel::GlobalCache<Metavariables>& cache, 78 : const TemporalId& temporal_id) { 79 : auto& proxy = Parallel::get_parallel_component< 80 : observers::ObserverWriter<Metavariables>>(cache); 81 : 82 : // We call this on proxy[0] because the 0th element of a NodeGroup is 83 : // always guaranteed to be present. 84 : Parallel::threaded_action< 85 : observers::ThreadedActions::WriteReductionDataRow>( 86 : proxy[0], 87 : std::string{"/" + pretty_type::name<InterpolationTargetTag>()}, 88 : detail::make_legend(TagsToObserve{}), 89 : detail::make_reduction_data( 90 : box, InterpolationTarget_detail::get_temporal_id_value(temporal_id), 91 : TagsToObserve{})); 92 : } 93 : }; 94 : } // namespace callbacks 95 : } // namespace intrp