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

Generated by: LCOV version 1.14