SpECTRE Documentation Coverage Report
Current view: top level - Domain - DiagnosticInfo.hpp Hit Total Coverage
Commit: 9f349d3c09e1c03107f00c2135ca40e209d3b84c Lines: 1 2 50.0 %
Date: 2023-06-09 21:05:06
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 <sstream>
       8             : #include <string>
       9             : #include <vector>
      10             : 
      11             : #include "Domain/Domain.hpp"
      12             : #include "Parallel/GlobalCache.hpp"
      13             : #include "Parallel/Info.hpp"
      14             : #include "Parallel/Printf.hpp"
      15             : #include "Utilities/ErrorHandling/Assert.hpp"
      16             : #include "Utilities/Numeric.hpp"
      17             : #include "Utilities/StdHelpers.hpp"
      18             : 
      19             : namespace domain {
      20             : /// Returns a `std::string` with diagnostic information about how elements and
      21             : /// grid points are distributed on the nodes and cores.
      22             : template <size_t Dim, typename Metavariables>
      23           1 : std::string diagnostic_info(const Domain<Dim>& domain,
      24             :                             const Parallel::GlobalCache<Metavariables>& cache,
      25             :                             const std::vector<size_t>& elements_per_core,
      26             :                             const std::vector<size_t>& elements_per_node,
      27             :                             const std::vector<size_t>& grid_points_per_core,
      28             :                             const std::vector<size_t>& grid_points_per_node) {
      29             :   const size_t total_number_of_elements =
      30             :       alg::accumulate(elements_per_node, 0_st);
      31             :   const size_t total_number_of_grid_points =
      32             :       alg::accumulate(grid_points_per_node, 0_st);
      33             :   const size_t total_number_of_blocks = domain.blocks().size();
      34             :   const size_t number_of_cores = Parallel::number_of_procs<size_t>(cache);
      35             :   const size_t number_of_nodes = Parallel::number_of_nodes<size_t>(cache);
      36             : 
      37             :   // Sanity checks
      38             :   ASSERT(total_number_of_elements == alg::accumulate(elements_per_core, 0_st),
      39             :          "Number of elements determined from elements_per_core ("
      40             :              << alg::accumulate(elements_per_core, 0_st)
      41             :              << ") does not match number of elements determined from "
      42             :                 "elements_per_node ("
      43             :              << total_number_of_elements << ").");
      44             :   ASSERT(total_number_of_grid_points ==
      45             :              alg::accumulate(grid_points_per_core, 0_st),
      46             :          "Number of grid points determined from grid_points_per_core ("
      47             :              << alg::accumulate(grid_points_per_core, 0_st)
      48             :              << ") does not match number of grid points determined from "
      49             :                 "grid points_per_node ("
      50             :              << total_number_of_grid_points << ").");
      51             :   ASSERT(number_of_cores == elements_per_core.size(),
      52             :          "Number of cores determined from elements_per_core ("
      53             :              << elements_per_core.size()
      54             :              << ") does not match number of cores determined from "
      55             :                 "global cache ("
      56             :              << number_of_cores << ").");
      57             :   ASSERT(number_of_cores == grid_points_per_core.size(),
      58             :          "Number of cores determined from grid_points_per_core ("
      59             :              << grid_points_per_core.size()
      60             :              << ") does not match number of cores determined from "
      61             :                 "global cache ("
      62             :              << number_of_cores << ").");
      63             :   ASSERT(number_of_nodes == elements_per_node.size(),
      64             :          "Number of nodes determined from elements_per_node ("
      65             :              << elements_per_node.size()
      66             :              << ") does not match number of nodes determined from "
      67             :                 "global cache ("
      68             :              << number_of_nodes << ").");
      69             :   ASSERT(number_of_nodes == grid_points_per_node.size(),
      70             :          "Number of nodes determined from grid_points_per_node ("
      71             :              << grid_points_per_node.size()
      72             :              << ") does not match number of nodes determined from "
      73             :                 "global cache ("
      74             :              << number_of_nodes << ").");
      75             : 
      76             :   using ::operator<<;
      77             :   std::stringstream ss{};
      78             :   ss << "----- Domain Info -----\n"
      79             :      << "Total blocks: " << total_number_of_blocks << "\n"
      80             :      << "Total elements: " << total_number_of_elements << "\n"
      81             :      << "Total grid points: " << total_number_of_grid_points << "\n"
      82             :      << "Number of cores: " << number_of_cores << "\n"
      83             :      << "Number of nodes: " << number_of_nodes << "\n"
      84             :      << "Elements per core: " << elements_per_core << "\n"
      85             :      << "Elements per node: " << elements_per_node << "\n"
      86             :      << "Grid points per core: " << grid_points_per_core << "\n"
      87             :      << "Grid points per node: " << grid_points_per_node << "\n"
      88             :      << "-----------------------\n";
      89             : 
      90             :   return ss.str();
      91             : }
      92             : }  // namespace domain

Generated by: LCOV version 1.14