SpECTRE Documentation Coverage Report
Current view: top level - ControlSystem/Tags - IsActiveMap.hpp Hit Total Coverage
Commit: 3ddfed217f4ad7ff185c653c2ab25b955494084a Lines: 1 8 12.5 %
Date: 2024-05-01 02:01:53
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 <map>
       7             : #include <optional>
       8             : #include <string>
       9             : #include <unordered_map>
      10             : 
      11             : #include "ControlSystem/Metafunctions.hpp"
      12             : #include "ControlSystem/Tags/OptionTags.hpp"
      13             : #include "DataStructures/DataBox/Tag.hpp"
      14             : #include "Utilities/TMPL.hpp"
      15             : 
      16             : /// \cond
      17             : template <typename Metavariables, typename ControlSystem>
      18             : struct ControlComponent;
      19             : namespace domain::FunctionsOfTime::OptionTags {
      20             : struct FunctionOfTimeFile;
      21             : struct FunctionOfTimeNameMap;
      22             : }  // namespace domain::FunctionsOfTime::OptionTags
      23             : /// \endcond
      24             : 
      25             : namespace control_system::Tags {
      26             : namespace detail {
      27             : template <typename... OptionHolders>
      28             : std::unordered_map<std::string, bool> create_is_active_map(
      29             :     const OptionHolders&... option_holders) {
      30             :   std::unordered_map<std::string, bool> result{};
      31             : 
      32             :   [[maybe_unused]] const auto add_to_result =
      33             :       [&result](const auto& option_holder) {
      34             :         using control_system =
      35             :             typename std::decay_t<decltype(option_holder)>::control_system;
      36             :         result[control_system::name()] = option_holder.is_active;
      37             :       };
      38             : 
      39             :   EXPAND_PACK_LEFT_TO_RIGHT(add_to_result(option_holders));
      40             : 
      41             :   return result;
      42             : }
      43             : }  // namespace detail
      44             : 
      45             : /*!
      46             :  * \ingroup DataBoxTagsGroup
      47             :  * \ingroup ControlSystemGroup
      48             :  * \brief Tag that holds a map between control system name and whether that
      49             :  * control system is active. Can be used in the GlobalCache.
      50             :  *
      51             :  * This effectively lets us choose control systems at runtime. The OptionHolder
      52             :  * has an option for whether the control system is active.
      53             :  */
      54           1 : struct IsActiveMap : db::SimpleTag {
      55           0 :   using type = std::unordered_map<std::string, bool>;
      56           0 :   static constexpr bool pass_metavariables = true;
      57             : 
      58             :   template <typename Component>
      59           0 :   struct system {
      60           0 :     using type = typename Component::control_system;
      61             :   };
      62             : 
      63             :   template <typename Metavariables>
      64           0 :   using option_tags = control_system::inputs<tmpl::transform<
      65             :       metafunctions::all_control_components<Metavariables>, system<tmpl::_1>>>;
      66             : 
      67             :   template <typename Metavariables, typename... OptionHolders>
      68           0 :   static type create_from_options(const OptionHolders&... option_holders) {
      69             :     return detail::create_is_active_map(option_holders...);
      70             :   }
      71             : };
      72             : }  // namespace control_system::Tags

Generated by: LCOV version 1.14