SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Interpolation - Interpolator.hpp Hit Total Coverage
Commit: 9ddc33268b29014a4956c8f0c24ca90b397463e1 Lines: 1 11 9.1 %
Date: 2024-04-26 20:00:04
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include "DataStructures/DataBox/DataBox.hpp"
       7             : #include "DataStructures/DataBox/TagName.hpp"
       8             : #include "IO/Observer/Actions/ObserverRegistration.hpp"
       9             : #include "IO/Observer/Actions/RegisterWithObservers.hpp"
      10             : #include "IO/Observer/ObservationId.hpp"
      11             : #include "IO/Observer/TypeOfObservation.hpp"
      12             : #include "Parallel/Algorithms/AlgorithmGroup.hpp"
      13             : #include "Parallel/ArrayComponentId.hpp"
      14             : #include "Parallel/GlobalCache.hpp"
      15             : #include "Parallel/Local.hpp"
      16             : #include "Parallel/ParallelComponentHelpers.hpp"
      17             : #include "Parallel/Phase.hpp"
      18             : #include "Parallel/PhaseDependentActionList.hpp"
      19             : #include "ParallelAlgorithms/Actions/TerminatePhase.hpp"
      20             : #include "ParallelAlgorithms/Interpolation/Actions/DumpInterpolatorVolumeData.hpp"
      21             : #include "ParallelAlgorithms/Interpolation/Actions/InitializeInterpolator.hpp"
      22             : #include "Utilities/GetOutput.hpp"
      23             : #include "Utilities/TMPL.hpp"
      24             : #include "Utilities/TypeTraits/IsA.hpp"
      25             : 
      26             : namespace intrp {
      27             : namespace Actions {
      28             : template <typename TemporalIdTag>
      29           0 : struct RegisterWithObserverWriter {
      30             :   template <typename DbTagList, typename... InboxTags, typename Metavariables,
      31             :             typename ArrayIndex, typename ActionList,
      32             :             typename ParallelComponent>
      33           0 :   static Parallel::iterable_action_return_t apply(
      34             :       db::DataBox<DbTagList>& /*box*/,
      35             :       const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
      36             :       Parallel::GlobalCache<Metavariables>& cache,
      37             :       const ArrayIndex& array_index, const ActionList /*meta*/,
      38             :       const ParallelComponent* const /*meta*/) {
      39             :     // This has to be the local observer writer or else registration will be
      40             :     // messed up
      41             :     auto& observer_writer = *Parallel::local_branch(
      42             :         Parallel::get_parallel_component<
      43             :             observers::ObserverWriter<Metavariables>>(cache));
      44             : 
      45             :     const observers::ObservationKey observation_key{
      46             :         "/InterpolatorVolumeData_"s + db::tag_name<TemporalIdTag>()};
      47             :     const Parallel::ArrayComponentId array_component_id =
      48             :         Parallel::make_array_component_id<ParallelComponent>(array_index);
      49             : 
      50             :     Parallel::simple_action<
      51             :         observers::Actions::RegisterVolumeContributorWithObserverWriter>(
      52             :         observer_writer, observation_key, array_component_id);
      53             : 
      54             :     return {Parallel::AlgorithmExecution::Continue, std::nullopt};
      55             :   }
      56             : };
      57             : }  // namespace Actions
      58             : 
      59             : namespace detail {
      60             : template <typename InterpolationTarget>
      61             : struct get_interpolation_target_tag {
      62             :   using type = typename InterpolationTarget::interpolation_target_tag;
      63             : };
      64             : template <typename InterpolationTargetTag>
      65             : struct get_temporal_id {
      66             :   using type = typename InterpolationTargetTag::temporal_id;
      67             : };
      68             : }  // namespace detail
      69             : 
      70             : /// \brief ParallelComponent responsible for collecting data from
      71             : /// `Element`s and interpolating it onto `InterpolationTarget`s.
      72             : ///
      73             : /// For requirements on Metavariables, see InterpolationTarget
      74             : template <class Metavariables>
      75           1 : struct Interpolator {
      76           0 :   using chare_type = Parallel::Algorithms::Group;
      77           0 :   using metavariables = Metavariables;
      78           0 :   using all_interpolation_target_tags = tmpl::transform<
      79             :       tmpl::filter<typename Metavariables::component_list,
      80             :                    tt::is_a<intrp::InterpolationTarget, tmpl::_1>>,
      81             :       detail::get_interpolation_target_tag<tmpl::_1>>;
      82           0 :   using all_temporal_ids = tmpl::remove_duplicates<tmpl::transform<
      83             :       all_interpolation_target_tags, detail::get_temporal_id<tmpl::_1>>>;
      84           0 :   using phase_dependent_action_list = tmpl::list<
      85             :       Parallel::PhaseActions<
      86             :           Parallel::Phase::Initialization,
      87             :           tmpl::list<Actions::InitializeInterpolator<
      88             :                          tmpl::transform<
      89             :                              all_temporal_ids,
      90             :                              tmpl::bind<Tags::VolumeVarsInfo,
      91             :                                         tmpl::pin<Metavariables>, tmpl::_1>>,
      92             :                          Tags::InterpolatedVarsHolders<Metavariables>>,
      93             :                      Parallel::Actions::TerminatePhase>>,
      94             :       Parallel::PhaseActions<
      95             :           Parallel::Phase::Register,
      96             :           tmpl::flatten<tmpl::list<
      97             :               tmpl::transform<
      98             :                   all_temporal_ids,
      99             :                   tmpl::bind<Actions::RegisterWithObserverWriter, tmpl::_1>>,
     100             :               Parallel::Actions::TerminatePhase>>>,
     101             :       Parallel::PhaseActions<
     102             :           Parallel::Phase::PostFailureCleanup,
     103             :           tmpl::list<Actions::DumpInterpolatorVolumeData<all_temporal_ids>,
     104             :                      Parallel::Actions::TerminatePhase>>>;
     105           0 :   using simple_tags_from_options = Parallel::get_simple_tags_from_options<
     106             :       Parallel::get_initialization_actions_list<phase_dependent_action_list>>;
     107           0 :   static void execute_next_phase(
     108             :       Parallel::Phase next_phase,
     109             :       const Parallel::CProxy_GlobalCache<Metavariables>& global_cache) {
     110             :     auto& local_cache = *Parallel::local_branch(global_cache);
     111             :     Parallel::get_parallel_component<Interpolator>(local_cache)
     112             :         .start_phase(next_phase);
     113             :   };
     114             : };
     115             : }  // namespace intrp

Generated by: LCOV version 1.14