Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cstddef> 7 : 8 : #include "DataStructures/DataBox/DataBox.hpp" 9 : #include "Domain/FunctionsOfTime/OutputTimeBounds.hpp" 10 : #include "Domain/FunctionsOfTime/Tags.hpp" 11 : #include "Parallel/GlobalCache.hpp" 12 : #include "Parallel/Info.hpp" 13 : #include "Parallel/ParallelComponentHelpers.hpp" 14 : #include "Parallel/Printf/Printf.hpp" 15 : 16 : namespace control_system::Tags { 17 : struct MeasurementTimescales; 18 : } // namespace control_system::Tags 19 : 20 : namespace deadlock { 21 : /*! 22 : * \brief Simple action that will print the `domain::Tags::FunctionsOfTime` and 23 : * `control_system::Tags::MeasurementTimescales` (if it exists) time bounds for 24 : * each node of a simulation. 25 : */ 26 1 : struct PrintFunctionsOfTime { 27 : template <typename ParallelComponent, typename DbTags, typename Metavariables, 28 : typename ArrayIndex> 29 0 : static void apply(db::DataBox<DbTags>& /*box*/, 30 : Parallel::GlobalCache<Metavariables>& cache, 31 : const ArrayIndex& /*array_index*/, 32 : const std::string& file_name) { 33 : const auto& functions_of_time = 34 : Parallel::get<::domain::Tags::FunctionsOfTime>(cache); 35 : const std::string time_bounds = 36 : ::domain::FunctionsOfTime::output_time_bounds(functions_of_time); 37 : 38 : if constexpr (Parallel::is_in_global_cache< 39 : Metavariables, 40 : control_system::Tags::MeasurementTimescales>) { 41 : const auto& measurement_timescales = 42 : Parallel::get<control_system::Tags::MeasurementTimescales>(cache); 43 : const std::string measurement_time_bounds = 44 : ::domain::FunctionsOfTime::output_time_bounds(measurement_timescales); 45 : 46 : Parallel::fprintf( 47 : file_name, 48 : "Node %zu\nFunctionsOfTime:\n%s\n\nMeasurementTimescales:\n%s\n", 49 : Parallel::my_node<size_t>(cache), time_bounds, 50 : measurement_time_bounds); 51 : } else { 52 : Parallel::fprintf(file_name, "Node %zu\nFunctionsOfTime:%s\n", 53 : Parallel::my_node<size_t>(cache), time_bounds); 54 : } 55 : } 56 : }; 57 : } // namespace deadlock