SpECTRE Documentation Coverage Report
Current view: top level - Domain/Structure - BlockGroups.hpp Hit Total Coverage
Commit: 1e29a35ad8559408f21493dc5db8a49a237bb2f0 Lines: 4 4 100.0 %
Date: 2026-03-31 22:27:51
Legend: Lines: hit not hit

          Line data    Source code
       1           1 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : /// \file
       5             : /// Utilities to work with block names and groups
       6             : 
       7             : #pragma once
       8             : 
       9             : #include <string>
      10             : #include <unordered_map>
      11             : #include <unordered_set>
      12             : #include <vector>
      13             : 
      14             : namespace domain {
      15             : 
      16             : /*!
      17             :  * \brief Check if a block is in the given group
      18             :  *
      19             :  * \param block_name The name of the block to check
      20             :  * \param block_or_group_name The group name we're testing. Returns true if
      21             :  * the block is in this group. This can also be the name of the block itself.
      22             :  * \param block_groups All block groups.
      23             :  */
      24           1 : bool block_is_in_group(
      25             :     const std::string& block_name, const std::string& block_or_group_name,
      26             :     const std::unordered_map<std::string, std::unordered_set<std::string>>&
      27             :         block_groups);
      28             : 
      29             : /*!
      30             :  * \brief Expand a list of block or group names into a list of block names
      31             :  *
      32             :  * Throws a `std::invalid_argument` exception if any of the input names are not
      33             :  * in \p all_block_names or \p block_groups.
      34             :  *
      35             :  * \param block_or_group_names Block or group names to expand
      36             :  * \param all_block_names All block names in the domain
      37             :  * \param block_groups Block groups used to expand the names
      38             :  * \return std::unordered_set<std::string> List of block names that appear in
      39             :  * \p all_block_names. If one of the input names was a group, then all block
      40             :  * names from that group are included. Overlaps between groups are allowed.
      41             :  */
      42           1 : std::unordered_set<std::string> expand_block_groups_to_block_names(
      43             :     const std::vector<std::string>& block_or_group_names,
      44             :     const std::vector<std::string>& all_block_names,
      45             :     const std::unordered_map<std::string, std::unordered_set<std::string>>&
      46             :         block_groups);
      47             : 
      48             : /*!
      49             :  * \brief Sorted block IDs corresponding to the given block or group names.
      50             :  *
      51             :  * Throws a `std::invalid_argument` exception if any of the input names are not
      52             :  * in \p all_block_names or \p block_groups.
      53             :  *
      54             :  * \param block_or_group_names Block names to get the IDs of. Any block groups
      55             :  * in this list are expanded.
      56             :  * \param all_block_names All block names in the domain.
      57             :  * \param block_groups Block groups used to expand the names.
      58             :  * \return std::vector<size_t> Sorted list of block IDs.
      59             :  */
      60           1 : std::vector<size_t> block_ids_from_names(
      61             :     const std::vector<std::string>& block_or_group_names,
      62             :     const std::vector<std::string>& all_block_names,
      63             :     const std::unordered_map<std::string, std::unordered_set<std::string>>&
      64             :         block_groups);
      65             : 
      66             : }  // namespace domain

Generated by: LCOV version 1.14