Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cmath> 7 : #include <cstddef> 8 : #include <string> 9 : #include <vector> 10 : 11 : #include "DataStructures/ComplexModalVector.hpp" 12 : #include "IO/H5/AccessType.hpp" 13 : #include "IO/H5/File.hpp" 14 : 15 : /// \cond 16 : class ComplexDataVector; 17 : /// \endcond 18 : 19 : namespace Cce { 20 : /*! 21 : * \brief The dataset string associated with each scalar that will be output 22 : * from the `Cce::Tags::worldtube_boundary_tags_for_writing` list (from the tags 23 : * within the BoundaryPrefix). 24 : */ 25 : template <typename Tag> 26 1 : std::string dataset_label_for_tag(); 27 : 28 : /*! 29 : * \brief Class that standardizes the output of our worldtube data into the 30 : * Bondi modal format that the CharacteristicExtract executable can read in. 31 : * 32 : * \details Takes Bondi nodal data in `fill_data_to_write` and gives the modal 33 : * data as a `std::vector<double>` with the time as the 0th component. The \p 34 : * output_l_max that this class is constructed with is the LMax that will be 35 : * written to disk. 36 : */ 37 1 : class WorldtubeModeRecorder { 38 : public: 39 0 : WorldtubeModeRecorder(); 40 0 : WorldtubeModeRecorder(size_t output_l_max, const std::string& h5_filename); 41 : 42 : /// @{ 43 : /*! 44 : * \brief Writes bondi modal data to the given \p subfile_path 45 : * 46 : * \details If nodal data is given (ComplexDataVector), uses `swsh_transform` 47 : * to transform the data and `libsharp_to_goldberg_modes` to convert the 48 : * libsharp formatted array into modes. 49 : * 50 : * There are exactly half the number of modes for \p Spin = 0 quantities as 51 : * their are for \p Spin != 0 because we don't include imaginary or m=0 for \p 52 : * Spin = 0. 53 : * 54 : * The \p data_l_max is the LMax of the \p nodal_data or \p modal_data and 55 : * must be >= \p output_l_max that this class was constructed with. A 56 : * restriction operation will be performed on the data before it is written, 57 : * if necessary. 58 : */ 59 : template <int Spin> 60 1 : void append_modal_data(const std::string& subfile_path, double time, 61 : const ComplexDataVector& nodal_data, 62 : size_t data_l_max); 63 : template <int Spin> 64 1 : void append_modal_data(const std::string& subfile_path, double time, 65 : const ComplexModalVector& modal_data, 66 : size_t data_l_max); 67 : /// @} 68 : 69 : /// @{ 70 : /// The legend for writing dat files for both spin = 0 (real) and spin != 0 71 : /// (all) quantities. 72 1 : const std::vector<std::string>& all_legend() const; 73 1 : const std::vector<std::string>& real_legend() const; 74 : /// @} 75 : 76 : private: 77 0 : size_t data_to_write_size(bool is_real) const; 78 0 : std::vector<std::string> build_legend(bool is_real) const; 79 0 : void check_data_l_max(size_t data_l_max) const; 80 : 81 0 : size_t output_l_max_{}; 82 0 : h5::H5File<h5::AccessType::ReadWrite> output_file_; 83 0 : std::vector<std::string> all_legend_; 84 0 : std::vector<std::string> real_legend_; 85 0 : std::vector<double> data_to_write_buffer_; 86 0 : ComplexModalVector goldberg_mode_buffer_; 87 : }; 88 : } // namespace Cce