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 <optional> 8 : #include <tuple> 9 : #include <unordered_set> 10 : 11 : #include "DataStructures/DataBox/DataBox.hpp" 12 : #include "DataStructures/DataBox/DataBoxTag.hpp" 13 : #include "Domain/Structure/ElementId.hpp" 14 : #include "Domain/Tags.hpp" 15 : #include "Parallel/AlgorithmExecution.hpp" 16 : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp" 17 : #include "ParallelAlgorithms/Interpolation/InterpolationTargetDetail.hpp" 18 : #include "Utilities/Gsl.hpp" 19 : #include "Utilities/Literals.hpp" 20 : #include "Utilities/TMPL.hpp" 21 : #include "Utilities/TaggedTuple.hpp" 22 : 23 : /// \cond 24 : 25 : namespace Parallel { 26 : template <typename Metavariables> 27 : class GlobalCache; 28 : } // namespace Parallel 29 : namespace intrp::Tags { 30 : template <size_t Dim> 31 : struct NumberOfElements; 32 : template <typename Metavariables> 33 : struct InterpolatedVarsHolders; 34 : template <typename Metavariables, typename TemporalId> 35 : struct VolumeVarsInfo; 36 : struct Verbosity; 37 : } // namespace intrp::Tags 38 : /// \endcond 39 : 40 : namespace intrp::Actions { 41 : 42 : /// \ingroup ActionsGroup 43 : /// \brief Initializes an Interpolator 44 : /// 45 : /// Uses: nothing 46 : /// 47 : /// DataBox changes: 48 : /// - Adds: 49 : /// - `Tags::NumberOfElements` 50 : /// - each tag in the template argument VolumeVarsInfos, which may either be a 51 : /// single `Tags::VolumeVarsInfo<Metavariables, TemporalId>` or a 52 : /// `tmpl::list` of multiple tags for `VolumeVarsInfo`. 53 : /// - `Tags::InterpolatedVarsHolders<Metavariables>` 54 : /// - Removes: nothing 55 : /// - Modifies: nothing 56 : template <size_t Dim, typename VolumeVarsInfos, 57 : typename InterpolatedVarsHolders> 58 1 : struct InitializeInterpolator { 59 0 : using return_tag_list = 60 : tmpl::flatten<tmpl::list<Tags::NumberOfElements<Dim>, VolumeVarsInfos, 61 : InterpolatedVarsHolders>>; 62 : 63 0 : using simple_tags = return_tag_list; 64 0 : using compute_tags = tmpl::list<>; 65 0 : using const_global_cache_tags = tmpl::list<intrp::Tags::Verbosity>; 66 : template <typename DbTagsList, typename... InboxTags, typename Metavariables, 67 : typename ArrayIndex, typename ActionList, 68 : typename ParallelComponent> 69 0 : static Parallel::iterable_action_return_t apply( 70 : db::DataBox<DbTagsList>& box, 71 : const tuples::TaggedTuple<InboxTags...>& /*inboxes*/, 72 : const Parallel::GlobalCache<Metavariables>& /*cache*/, 73 : const ArrayIndex& /*array_index*/, const ActionList /*meta*/, 74 : const ParallelComponent* const /*meta*/) { 75 : using sequential_targets = 76 : intrp::InterpolationTarget_detail::get_sequential_target_tags< 77 : Metavariables>; 78 : db::mutate<Tags::NumberOfElements<Dim>>( 79 : [](const gsl::not_null<std::unordered_map< 80 : std::string, std::unordered_set<ElementId<Dim>>>*> 81 : num_elements) { 82 : tmpl::for_each<sequential_targets>([&](auto target_v) { 83 : using target = tmpl::type_from<decltype(target_v)>; 84 : const std::string& target_name = pretty_type::name<target>(); 85 : 86 : (*num_elements)[target_name] = std::unordered_set<ElementId<Dim>>{}; 87 : }); 88 : }, 89 : make_not_null(&box)); 90 : return {Parallel::AlgorithmExecution::Continue, std::nullopt}; 91 : } 92 : }; 93 : 94 : } // namespace intrp::Actions