SpECTRE Documentation Coverage Report
Current view: top level - Domain/Structure - BlockGroups.hpp Hit Total Coverage
Commit: 3ffcbc8ecf43797401b60bcca17d6040ee06f013 Lines: 4 4 100.0 %
Date: 2026-03-03 02:01:44
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 <set>
      10             : #include <string>
      11             : #include <unordered_map>
      12             : #include <unordered_set>
      13             : #include <vector>
      14             : 
      15             : namespace domain {
      16             : 
      17             : /*!
      18             :  * \brief Check if a block is in the given group
      19             :  *
      20             :  * \param block_name The name of the block to check
      21             :  * \param block_or_group_name The group name we're testing. Returns true if
      22             :  * the block is in this group. This can also be the name of the block itself.
      23             :  * \param block_groups All block groups.
      24             :  */
      25           1 : bool block_is_in_group(
      26             :     const std::string& block_name, const std::string& block_or_group_name,
      27             :     const std::unordered_map<std::string, std::unordered_set<std::string>>&
      28             :         block_groups);
      29             : 
      30             : /*!
      31             :  * \brief Expand a list of block or group names into a list of block names
      32             :  *
      33             :  * \param block_or_group_names Block or group names to expand
      34             :  * \param all_block_names All block names in the domain
      35             :  * \param block_groups Block groups used to expand the names
      36             :  * \return std::unordered_set<std::string> List of block names that appear in
      37             :  * \p all_block_names. If one of the input names was a group, then all block
      38             :  * names from that group are included. Overlaps between groups are allowed.
      39             :  */
      40           1 : std::unordered_set<std::string> expand_block_groups_to_block_names(
      41             :     const std::vector<std::string>& block_or_group_names,
      42             :     const std::vector<std::string>& all_block_names,
      43             :     const std::unordered_map<std::string, std::unordered_set<std::string>>&
      44             :         block_groups);
      45             : 
      46             : /*!
      47             :  * \brief Get the block IDs corresponding to the given block or group names.
      48             :  *
      49             :  * \param block_or_group_names Block names to get the IDs of. Any block groups
      50             :  * in this list are expanded.
      51             :  * \param all_block_names All block names in the domain.
      52             :  * \param block_groups Block groups used to expand the names.
      53             :  * \return std::set<size_t> Set of block IDs.
      54             :  */
      55           1 : std::set<size_t> block_ids_from_names(
      56             :     const std::vector<std::string>& block_or_group_names,
      57             :     const std::vector<std::string>& all_block_names,
      58             :     const std::unordered_map<std::string, std::unordered_set<std::string>>&
      59             :         block_groups);
      60             : 
      61             : }  // namespace domain

Generated by: LCOV version 1.14