SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/ApparentHorizonFinder - PrintDeadlockAnalysis.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 25.0 % 4 1
Test Date: 2026-10-22 17:29:42
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 <iomanip>
       7              : #include <ios>
       8              : #include <limits>
       9              : #include <sstream>
      10              : 
      11              : #include "DataStructures/DataBox/DataBox.hpp"
      12              : #include "Parallel/GlobalCache.hpp"
      13              : #include "Parallel/Printf/Printf.hpp"
      14              : #include "ParallelAlgorithms/ApparentHorizonFinder/Tags.hpp"
      15              : #include "Utilities/PrettyType.hpp"
      16              : #include "Utilities/TMPL.hpp"
      17              : 
      18            0 : namespace ah::Actions {
      19              : /*!
      20              :  * \brief Simple action to print deadlock info of the horizon finder.
      21              :  */
      22            1 : struct PrintDeadlockAnalysis {
      23              :   template <typename ParallelComponent, typename DbTags, typename Metavariables,
      24              :             typename ArrayIndex>
      25            0 :   static void apply(const db::DataBox<DbTags>& box,
      26              :                     const Parallel::GlobalCache<Metavariables>& /*cache*/,
      27              :                     const ArrayIndex& /*array_index*/,
      28              :                     const std::string& file_name) {
      29              :     std::stringstream ss{};
      30              :     ss << std::setprecision(std::numeric_limits<double>::digits10 + 4)
      31              :        << std::scientific;
      32              : 
      33              :     using HorizonMetavars = typename ParallelComponent::horizon_metavars;
      34              :     const std::string& name = pretty_type::name<HorizonMetavars>();
      35              :     ss << "Horizon finder " << name << ":\n";
      36              : 
      37              :     const auto& completed_times = db::get<ah::Tags::CompletedTimes>(box);
      38              :     ss << "  Completed times: " << completed_times << "\n";
      39              : 
      40              :     const auto& current_time_optional = db::get<ah::Tags::CurrentTime>(box);
      41              :     if (current_time_optional.has_value()) {
      42              :       ss << "  Current time: " << current_time_optional.value() << "\n";
      43              :     } else {
      44              :       ss << "  No current time set.\n";
      45              :     }
      46              : 
      47              :     const auto& pending_times = db::get<ah::Tags::PendingTimes>(box);
      48              :     ss << "  Pending times: " << pending_times << "\n";
      49              : 
      50              :     if (current_time_optional.has_value()) {
      51              :       const auto& current_time = current_time_optional.value();
      52              :       const auto& all_storage =
      53              :           db::get<ah::Tags::Storage<typename HorizonMetavars::frame>>(box);
      54              :       if (all_storage.contains(current_time)) {
      55              :         const auto& current_time_storage = all_storage.at(current_time);
      56              :         const auto& all_volume_variables =
      57              :             current_time_storage.all_volume_variables;
      58              :         const auto& current_iteration_storage =
      59              :             current_time_storage.current_iteration;
      60              :         const auto& fast_flow = db::get<ah::Tags::FastFlow>(box);
      61              : 
      62              :         ss << "  Time is ready: " << current_time_storage.time_is_ready << "\n";
      63              :         ss << "  FastFlow iteration: " << fast_flow.current_iteration() << "\n";
      64              :         ss << "  Coordinates are set: "
      65              :            << current_iteration_storage.block_coord_holders.has_value() << "\n";
      66              : 
      67              :         if (current_iteration_storage.block_coord_holders.has_value()) {
      68              :           ss << "  Number of points to interpolate to: "
      69              :              << current_iteration_storage.block_coord_holders->size() << "\n";
      70              :           const bool interpolation_is_complete =
      71              :               current_iteration_storage.interpolation_is_complete();
      72              :           ss << "  Interpolation is complete: " << interpolation_is_complete
      73              :              << "\n";
      74              :           if (not interpolation_is_complete) {
      75              :             ss << "  THE HORIZON FINDER IS STUCK IN INTERPOLATION, WHICH "
      76              :                   "LIKELY CAUSED THIS DEADLOCK. It is likely waiting for "
      77              :                   "volume data that will never arrive. See "
      78              :                   "'src/ParallelAlgorithms/ApparentHorizonFinder/Events/"
      79              :                   "FindApparentHorizon.hpp' for possible causes and "
      80              :                   "solutions.\n";
      81              :             const auto& block_logical_coords =
      82              :                 current_iteration_storage.block_coord_holders.value();
      83              :             ss << "  Missing points (in block-logical coords):\n";
      84              :             const auto& filled =
      85              :                 current_iteration_storage.indices_interpolated_to_thus_far;
      86              :             for (size_t i = 0; i < filled.size(); ++i) {
      87              :               if (not filled[i]) {
      88              :                 ss << "    Index " << i << ": " << block_logical_coords[i]
      89              :                    << "\n";
      90              :               }
      91              :             }
      92              :           }
      93              :           ss << "  Intersecting element IDs: "
      94              :              << current_iteration_storage.intersecting_element_ids << "\n";
      95              :           ss << "  Element order: " << current_time_storage.element_order
      96              :              << "\n";
      97              :           ss << "  Volume data received from " << all_volume_variables.size()
      98              :              << " elements:\n";
      99              :           for (const auto& [element_id, volume_vars_storage] :
     100              :                all_volume_variables) {
     101              :             ss << "    " << element_id << "\n";
     102              :           }
     103              :         }
     104              :       } else {
     105              :         ss << "  No storage for current time " << current_time << ".\n";
     106              :       }
     107              :     }
     108              : 
     109              :     Parallel::fprintf(file_name, "%s\n", ss.str());
     110              :   }
     111              : };
     112              : }  // namespace ah::Actions
        

Generated by: LCOV version 2.0-1