SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Interpolation - Tags.hpp Hit Total Coverage
Commit: d0fc80462417e83e5cddfa1b9901bb4a9b6af4d6 Lines: 13 39 33.3 %
Date: 2024-03-29 00:33:31
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 <cstddef>
       7             : #include <deque>
       8             : #include <string>
       9             : #include <type_traits>
      10             : #include <unordered_map>
      11             : #include <unordered_set>
      12             : 
      13             : #include "DataStructures/DataBox/PrefixHelpers.hpp"
      14             : #include "DataStructures/DataBox/Tag.hpp"
      15             : #include "DataStructures/Variables.hpp"
      16             : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
      17             : #include "Options/String.hpp"
      18             : #include "ParallelAlgorithms/Interpolation/InterpolatedVars.hpp"
      19             : #include "Utilities/TaggedTuple.hpp"
      20             : 
      21             : /// \cond
      22             : template <size_t VolumeDim>
      23             : class ElementId;
      24             : /// \endcond
      25             : 
      26             : namespace intrp {
      27             : 
      28             : namespace OptionTags {
      29             : /*!
      30             :  * \ingroup OptionGroupsGroup
      31             :  * \brief Groups option tags for InterpolationTargets.
      32             :  */
      33           1 : struct InterpolationTargets {
      34           0 :   static constexpr Options::String help{"Options for interpolation targets"};
      35             : };
      36             : 
      37             : /*!
      38             :  * \ingroup OptionGroupsGroup
      39             :  * \brief Groups option tags for the Interpolator.
      40             :  */
      41           1 : struct Interpolator {
      42           0 :   static constexpr Options::String help{
      43             :       "Options related to the Interpolator parallel component"};
      44             : };
      45             : 
      46             : /// Option tag that determines if volume data will be dumped from the
      47             : /// Interpolator upon a failure.
      48           1 : struct DumpVolumeDataOnFailure {
      49           0 :   using type = bool;
      50           0 :   static constexpr Options::String help{
      51             :       "Whether or not to dump all volume data currently stored by the "
      52             :       "interpolator. Volume data is written to the file corresponding to the "
      53             :       "node it was collected on."};
      54           0 :   using group = Interpolator;
      55             : };
      56             : }  // namespace OptionTags
      57             : 
      58             : /// Tags for items held in the `DataBox` of `InterpolationTarget` or
      59             : /// `Interpolator`.
      60             : namespace Tags {
      61             : /// Tag that determines if volume data will be dumped form the Interpolator upon
      62             : /// failure
      63           1 : struct DumpVolumeDataOnFailure : db::SimpleTag {
      64           0 :   using type = bool;
      65           0 :   using option_tags = tmpl::list<OptionTags::DumpVolumeDataOnFailure>;
      66           0 :   static constexpr bool pass_metavariables = false;
      67             : 
      68           0 :   static bool create_from_options(const bool input) { return input; }
      69             : };
      70             : 
      71             : /// Keeps track of which points have been filled with interpolated data.
      72             : template <typename TemporalId>
      73           1 : struct IndicesOfFilledInterpPoints : db::SimpleTag {
      74           0 :   using type = std::unordered_map<TemporalId, std::unordered_set<size_t>>;
      75             : };
      76             : 
      77             : /// Keeps track of points that cannot be filled with interpolated data.
      78             : ///
      79             : /// The InterpolationTarget can decide what to do with these points.
      80             : /// In most cases the correct action is to throw an error, but in other
      81             : /// cases one might wish to fill these points with a default value or
      82             : /// take some other action.
      83             : template <typename TemporalId>
      84           1 : struct IndicesOfInvalidInterpPoints : db::SimpleTag {
      85           0 :   using type = std::unordered_map<TemporalId, std::unordered_set<size_t>>;
      86             : };
      87             : 
      88             : /// `temporal_id`s that have been flagged to interpolate on, but that
      89             : /// have not yet been added to Tags::TemporalIds.  A `temporal_id` is
      90             : /// pending if the `FunctionOfTime`s are not up to date for the time
      91             : /// associated with the `temporal_id`.
      92             : template <typename TemporalId>
      93           1 : struct PendingTemporalIds : db::SimpleTag {
      94           0 :   using type = std::deque<TemporalId>;
      95             : };
      96             : 
      97             : /// `temporal_id`s on which to interpolate.
      98             : template <typename TemporalId>
      99           1 : struct TemporalIds : db::SimpleTag {
     100           0 :   using type = std::deque<TemporalId>;
     101             : };
     102             : 
     103             : /// `temporal_id`s that we have already interpolated onto.
     104             : ///  This is used to prevent problems with multiple late calls to
     105             : ///  AddTemporalIdsToInterpolationTarget.
     106             : template <typename TemporalId>
     107           1 : struct CompletedTemporalIds : db::SimpleTag {
     108           0 :   using type = std::deque<TemporalId>;
     109             : };
     110             : 
     111             : /// Holds interpolated variables on an InterpolationTarget.
     112             : template <typename InterpolationTargetTag, typename TemporalId>
     113           1 : struct InterpolatedVars : db::SimpleTag {
     114           0 :   using type = std::unordered_map<
     115             :       TemporalId,
     116             :       Variables<
     117             :           typename InterpolationTargetTag::vars_to_interpolate_to_target>>;
     118             : };
     119             : 
     120             : template <typename InterpolationTargetTag>
     121           0 : struct VarsToInterpolateToTarget {
     122           0 :   using type =
     123             :       Variables<typename InterpolationTargetTag::vars_to_interpolate_to_target>;
     124             : };
     125             : 
     126             : /// Volume variables at all `temporal_id`s for all local `Element`s.
     127             : /// Held by the Interpolator.
     128             : template <typename Metavariables, typename TemporalId>
     129           1 : struct VolumeVarsInfo : db::SimpleTag {
     130           0 :   struct Info {
     131           0 :     Mesh<Metavariables::volume_dim> mesh;
     132             :     // Variables that have been sent from the Elements.
     133             :     Variables<typename Metavariables::interpolator_source_vars>
     134           0 :         source_vars_from_element;
     135             :     // Variables, for each InterpolationTargetTag, that have been
     136             :     // computed in the volume before interpolation, and that will
     137             :     // be interpolated.
     138             :     tuples::tagged_tuple_from_typelist<
     139             :         db::wrap_tags_in<VarsToInterpolateToTarget,
     140             :                          typename Metavariables::interpolation_target_tags>>
     141           0 :         vars_to_interpolate;
     142             :     // NOLINTNEXTLINE(google-runtime-references)
     143           0 :     void pup(PUP::er& p) {
     144             :       p | mesh;
     145             :       p | source_vars_from_element;
     146             :       p | vars_to_interpolate;
     147             :     }
     148             :   };
     149           0 :   using type = std::unordered_map<
     150             :       typename TemporalId::type,
     151             :       std::unordered_map<ElementId<Metavariables::volume_dim>, Info>>;
     152             : };
     153             : 
     154             : namespace holders_detail {
     155             : template <typename InterpolationTargetTag, typename Metavariables>
     156             : using WrappedHolderTag = Vars::HolderTag<InterpolationTargetTag, Metavariables>;
     157             : }  // namespace holders_detail
     158             : 
     159             : /// `TaggedTuple` containing all local `Vars::Holder`s for
     160             : /// all `InterpolationTarget`s.
     161             : ///
     162             : /// A particular `Vars::Holder` can be retrieved from this
     163             : /// `TaggedTuple` via a `Vars::HolderTag`.  An `Interpolator` uses the
     164             : /// object in `InterpolatedVarsHolders` to iterate over all of the
     165             : /// `InterpolationTarget`s.
     166             : template <typename Metavariables>
     167           1 : struct InterpolatedVarsHolders : db::SimpleTag {
     168           0 :   using type = tuples::tagged_tuple_from_typelist<db::wrap_tags_in<
     169             :       holders_detail::WrappedHolderTag,
     170             :       typename Metavariables::interpolation_target_tags, Metavariables>>;
     171             : };
     172             : 
     173             : /// Number of local `Element`s.
     174           1 : struct NumberOfElements : db::SimpleTag {
     175           0 :   using type = size_t;
     176             : };
     177             : 
     178             : }  // namespace Tags
     179             : }  // namespace intrp

Generated by: LCOV version 1.14