SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Interpolation/Actions - PrintInterpolationTargetForDeadlock.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 33.3 % 3 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/Interpolation/Tags.hpp"
      15              : #include "Utilities/PrettyType.hpp"
      16              : #include "Utilities/TMPL.hpp"
      17              : 
      18              : namespace deadlock {
      19              : /*!
      20              :  * \brief Simple action to print deadlock info on an interpolation target.
      21              :  *
      22              :  * \details This will print the following information for all temporal ids
      23              :  * stored in `intrp::Tags::TemporalIds`.
      24              :  *
      25              :  * - `intrp::Tags::IndicesOfFilledInterpPoints`
      26              :  * - `intrp::Tags::IndicesOfInvalidInterpPoints`
      27              :  * - Size of `intrp::Tags::InterpolatedVars`
      28              :  */
      29            1 : struct PrintInterpolationTarget {
      30              :   template <typename ParallelComponent, typename DbTags, typename Metavariables,
      31              :             typename ArrayIndex>
      32            0 :   static void apply(const db::DataBox<DbTags>& box,
      33              :                     const Parallel::GlobalCache<Metavariables>& /*cache*/,
      34              :                     const ArrayIndex& /*array_index*/,
      35              :                     const std::string& file_name) {
      36              :     std::stringstream ss{};
      37              :     ss << std::setprecision(std::numeric_limits<double>::digits10 + 4)
      38              :        << std::scientific;
      39              : 
      40              :     using TargetTag = typename ParallelComponent::interpolation_target_tag;
      41              :     using TemporalId = typename TargetTag::temporal_id::type;
      42              : 
      43              :     const auto stream_points = [&](const TemporalId& temporal_id) {
      44              :       const auto& filled_indices =
      45              :           db::get<intrp::Tags::IndicesOfFilledInterpPoints<TemporalId>>(box);
      46              :       const auto& invalid_indices =
      47              :           db::get<intrp::Tags::IndicesOfInvalidInterpPoints<TemporalId>>(box);
      48              :       const auto& interpolated_vars =
      49              :           db::get<intrp::Tags::InterpolatedVars<TargetTag, TemporalId>>(box);
      50              : 
      51              :       const size_t expected_size =
      52              :           interpolated_vars.at(temporal_id).number_of_grid_points();
      53              :       const size_t filled_size = filled_indices.count(temporal_id) > 0
      54              :                                      ? filled_indices.at(temporal_id).size()
      55              :                                      : 0_st;
      56              :       const size_t invalid_size = invalid_indices.count(temporal_id) > 0
      57              :                                       ? invalid_indices.at(temporal_id).size()
      58              :                                       : 0_st;
      59              : 
      60              :       ss << "Total points expected = " << expected_size
      61              :          << ", valid points received = " << filled_size
      62              :          << ", invalid points received " << invalid_size << ". ";
      63              :     };
      64              : 
      65              :     const auto& temporal_ids =
      66              :         db::get<intrp::Tags::TemporalIds<TemporalId>>(box);
      67              : 
      68              :     if (temporal_ids.empty()) {
      69              :       ss << pretty_type::name<TargetTag>() << ", No temporal ids.";
      70              :       Parallel::printf("%s\n", ss.str());
      71              :       return;
      72              :     }
      73              : 
      74              :     ss << "========== BEGIN TARGET " << pretty_type::name<TargetTag>()
      75              :        << " ==========\n";
      76              : 
      77              :     for (const auto& temporal_id : temporal_ids) {
      78              :       ss << "Temporal id " << temporal_id << ", ";
      79              : 
      80              :       stream_points(temporal_id);
      81              : 
      82              :       ss << "\n";
      83              :     }
      84              : 
      85              :     ss << "========== END TARGET " << pretty_type::name<TargetTag>()
      86              :        << " ============\n";
      87              : 
      88              :     Parallel::fprintf(file_name, "%s\n", ss.str());
      89              :   }
      90              : };
      91              : }  // namespace deadlock
        

Generated by: LCOV version 2.0-1