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 <pup.h> 8 : #include <string> 9 : #include <type_traits> 10 : 11 : #include "Options/String.hpp" 12 : #include "ParallelAlgorithms/Actions/FunctionsOfTimeAreReady.hpp" 13 : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp" 14 : #include "ParallelAlgorithms/Interpolation/Events/GetComputeItemsOnSource.hpp" 15 : #include "ParallelAlgorithms/Interpolation/Interpolate.hpp" 16 : #include "Utilities/PrettyType.hpp" 17 : #include "Utilities/Serialization/CharmPupable.hpp" 18 : #include "Utilities/TMPL.hpp" 19 : 20 : /// \cond 21 : template <size_t Dim> 22 : class Mesh; 23 : template <size_t VolumeDim> 24 : class ElementId; 25 : namespace Parallel { 26 : template <typename Metavariables> 27 : class GlobalCache; 28 : } // namespace Parallel 29 : namespace Tags { 30 : struct Time; 31 : } // namespace Tags 32 : namespace domain::Tags { 33 : struct FunctionsOfTime; 34 : } // namespace domain::Tags 35 : namespace Events::Tags { 36 : template <size_t Dim> 37 : struct ObserverMesh; 38 : } // namespace Events::Tags 39 : /// \endcond 40 : 41 : namespace intrp { 42 0 : namespace Events { 43 : /// Does an interpolation onto InterpolationTargetTag by calling Actions on 44 : /// the Interpolator and InterpolationTarget components. 45 : template <size_t VolumeDim, typename InterpolationTargetTag, 46 : typename InterpolatorSourceVarTags> 47 1 : class Interpolate; 48 : 49 : template <size_t VolumeDim, typename InterpolationTargetTag, 50 : typename... InterpolatorSourceVarTags> 51 0 : class Interpolate<VolumeDim, InterpolationTargetTag, 52 : tmpl::list<InterpolatorSourceVarTags...>> : public Event { 53 : public: 54 : /// \cond 55 : explicit Interpolate(CkMigrateMessage* /*unused*/) {} 56 : using PUP::able::register_constructor; 57 : WRAPPED_PUPable_decl_template(Interpolate); // NOLINT 58 : /// \endcond 59 : 60 0 : using options = tmpl::list<>; 61 0 : static constexpr Options::String help = 62 : "Starts interpolation onto the given InterpolationTargetTag."; 63 : 64 0 : static std::string name() { 65 : return pretty_type::name<InterpolationTargetTag>(); 66 : } 67 : 68 0 : Interpolate() = default; 69 : 70 0 : using compute_tags_for_observation_box = 71 : detail::get_compute_items_on_source_or_default_t<InterpolationTargetTag, 72 : tmpl::list<>>; 73 : 74 0 : using return_tags = tmpl::list<>; 75 0 : using argument_tags = tmpl::list<typename InterpolationTargetTag::temporal_id, 76 : ::Events::Tags::ObserverMesh<VolumeDim>, 77 : InterpolatorSourceVarTags...>; 78 : 79 : template <typename Metavariables, typename ParallelComponent> 80 0 : void operator()( 81 : const typename InterpolationTargetTag::temporal_id::type& temporal_id, 82 : const Mesh<VolumeDim>& mesh, 83 : const typename InterpolatorSourceVarTags:: 84 : type&... interpolator_source_vars, 85 : Parallel::GlobalCache<Metavariables>& cache, 86 : const ElementId<VolumeDim>& array_index, 87 : const ParallelComponent* const /*meta*/, 88 : const ObservationValue& /*observation_value*/) const { 89 : static_assert( 90 : std::is_same_v<typename Metavariables::interpolator_source_vars, 91 : tmpl::list<InterpolatorSourceVarTags...>>); 92 : interpolate<InterpolationTargetTag>(temporal_id, mesh, cache, array_index, 93 : interpolator_source_vars...); 94 : } 95 : 96 0 : using is_ready_argument_tags = tmpl::list<::Tags::Time>; 97 : 98 : template <typename Metavariables, typename ArrayIndex, typename Component> 99 0 : bool is_ready(const double time, Parallel::GlobalCache<Metavariables>& cache, 100 : const ArrayIndex& array_index, 101 : const Component* const component) const { 102 : return domain::functions_of_time_are_ready_algorithm_callback< 103 : domain::Tags::FunctionsOfTime>(cache, array_index, component, time); 104 : } 105 : 106 1 : bool needs_evolved_variables() const override { return true; } 107 : }; 108 : 109 : /// \cond 110 : template <size_t VolumeDim, typename InterpolationTargetTag, 111 : typename... InterpolatorSourceVarTags> 112 : PUP::able::PUP_ID 113 : Interpolate<VolumeDim, InterpolationTargetTag, 114 : tmpl::list<InterpolatorSourceVarTags...>>::my_PUP_ID = 115 : 0; // NOLINT 116 : /// \endcond 117 : 118 : } // namespace Events 119 : } // namespace intrp