Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include "DataStructures/DataBox/DataBox.hpp" 7 : #include "IO/Logging/Verbosity.hpp" 8 : #include "Parallel/Printf/Printf.hpp" 9 : #include "ParallelAlgorithms/ApparentHorizonFinder/FastFlow.hpp" 10 : #include "ParallelAlgorithms/ApparentHorizonFinder/Tags.hpp" 11 : #include "ParallelAlgorithms/Interpolation/InterpolationTargetDetail.hpp" 12 : #include "Utilities/PrettyType.hpp" 13 : 14 : /// \cond 15 : namespace Parallel { 16 : template <typename Metavariables> 17 : class GlobalCache; 18 : } // namespace Parallel 19 : namespace logging::Tags { 20 : template <typename OptionsGroup> 21 : struct Verbosity; 22 : } // namespace logging::Tags 23 : /// \endcond 24 : 25 : namespace intrp::callbacks { 26 : 27 : /// \brief Callback for a failed apparent horizon find that prints a 28 : /// message (if sufficient Verbosity is enabled) but does not 29 : /// terminate the executable. 30 1 : struct IgnoreFailedApparentHorizon { 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 : const auto& verbosity = 38 : db::get<logging::Tags::Verbosity<InterpolationTargetTag>>(box); 39 : if (verbosity >= ::Verbosity::Quiet) { 40 : const auto& invalid_indices = 41 : db::get<::intrp::Tags::IndicesOfInvalidInterpPoints<TemporalId>>(box); 42 : std::ostringstream os; 43 : if (invalid_indices.contains(temporal_id) and 44 : not invalid_indices.at(temporal_id).empty()) { 45 : // There are invalid points (i.e. points that could not be 46 : // interpolated). Print info about those points. 47 : 48 : // First get the actual points 49 : const auto coords = 50 : InterpolationTargetTag::compute_target_points::points( 51 : box, tmpl::type_<Metavariables>{}, temporal_id); 52 : 53 : const auto& fast_flow = db::get<::ah::Tags::FastFlow>(box); 54 : 55 : // Now output some information about them 56 : os << "Invalid points (in " 57 : << pretty_type::name<typename InterpolationTargetTag:: 58 : compute_target_points::frame>() 59 : << " frame) at time " 60 : << InterpolationTarget_detail::get_temporal_id_value(temporal_id) 61 : << " at fast-flow iteration " << fast_flow.current_iteration() 62 : << " are:\n"; 63 : for (const auto index : invalid_indices.at(temporal_id)) { 64 : os << " (" << get<0>(coords)[index] << "," << get<1>(coords)[index] 65 : << "," << get<2>(coords)[index] << ")\n"; 66 : } 67 : } 68 : 69 : Parallel::printf( 70 : "Remark: Horizon finder %s failed. Number of interpolation retries: " 71 : "%u, reason = %s\n%s", 72 : pretty_type::name<InterpolationTargetTag>(), 73 : db::get<ah::Tags::FailedInterpolationIterations>(box), failure_reason, 74 : os.str()); 75 : } 76 : } 77 : }; 78 : 79 : } // namespace intrp::callbacks