SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/ApparentHorizonFinder/Callbacks - ErrorOnFailedApparentHorizon.hpp Hit Total Coverage
Commit: 1f2210958b4f38fdc0400907ee7c6d5af5111418 Lines: 1 3 33.3 %
Date: 2025-12-05 05:03:31
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 <sstream>
       7             : 
       8             : #include "DataStructures/DataBox/DataBox.hpp"
       9             : #include "ParallelAlgorithms/ApparentHorizonFinder/FastFlow.hpp"
      10             : #include "ParallelAlgorithms/ApparentHorizonFinder/Tags.hpp"
      11             : #include "ParallelAlgorithms/Interpolation/InterpolationTargetDetail.hpp"
      12             : #include "ParallelAlgorithms/Interpolation/Tags.hpp"
      13             : #include "Utilities/ErrorHandling/Error.hpp"
      14             : #include "Utilities/PrettyType.hpp"
      15             : 
      16             : /// \cond
      17             : namespace db {
      18             : template <typename DbTags>
      19             : class DataBox;
      20             : }  // namespace db
      21             : namespace Parallel {
      22             : template <typename Metavariables>
      23             : class GlobalCache;
      24             : }  // namespace Parallel
      25             : /// \endcond
      26             : 
      27             : namespace intrp::callbacks {
      28             : 
      29             : /// \brief Callback for a failed apparent horizon find that simply errors.
      30           1 : struct ErrorOnFailedApparentHorizon {
      31             :   template <typename InterpolationTargetTag, typename DbTags,
      32             :             typename Metavariables, typename TemporalId>
      33           0 :   static void apply(db::DataBox<DbTags>& box,
      34             :                     const Parallel::GlobalCache<Metavariables>& /*cache*/,
      35             :                     const TemporalId& temporal_id,
      36             :                     const FastFlow::Status failure_reason) {
      37             :     if (failure_reason == FastFlow::Status::InterpolationFailure) {
      38             :       const auto& invalid_indices =
      39             :           db::get<::intrp::Tags::IndicesOfInvalidInterpPoints<TemporalId>>(box);
      40             :       if (invalid_indices.find(temporal_id) != invalid_indices.end() and
      41             :           not invalid_indices.at(temporal_id).empty()) {
      42             :         // There are invalid points (i.e. points that could not be
      43             :         // interpolated). Print info about those points.
      44             : 
      45             :         // First get the actual points
      46             :         const auto coords =
      47             :             InterpolationTargetTag::compute_target_points::points(
      48             :                 box, tmpl::type_<Metavariables>{}, temporal_id);
      49             : 
      50             :         // Now output some information about them
      51             :         std::ostringstream os;
      52             :         os << "\nInvalid points (in Strahlkorper frame) at time "
      53             :            << InterpolationTarget_detail::get_temporal_id_value(temporal_id)
      54             :            << " are:\n";
      55             :         for (const auto index : invalid_indices.at(temporal_id)) {
      56             :           os << "(" << get<0>(coords)[index] << "," << get<1>(coords)[index]
      57             :              << "," << get<2>(coords)[index] << ")\n";
      58             :         }
      59             :         ERROR("Apparent horizon finder "
      60             :               << pretty_type::name<InterpolationTargetTag>()
      61             :               << " failed. Number of interpolation retries: "
      62             :               << db::get<ah::Tags::FailedInterpolationIterations>(box)
      63             :               << ", reason = " << failure_reason << os.str());
      64             :       }
      65             :     }
      66             :     ERROR("Apparent horizon finder "
      67             :           << pretty_type::name<InterpolationTargetTag>()
      68             :           << " failed. Number of interpolation retries: "
      69             :           << db::get<ah::Tags::FailedInterpolationIterations>(box)
      70             :           << ", reason = " << failure_reason << " at time "
      71             :           << InterpolationTarget_detail::get_temporal_id_value(temporal_id));
      72             :   }
      73             : };
      74             : 
      75             : }  // namespace intrp::callbacks

Generated by: LCOV version 1.14