Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <array> 7 : #include <memory> 8 : #include <optional> 9 : #include <string> 10 : 11 : #include "DataStructures/DataVector.hpp" 12 : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp" 13 : #include "Domain/Structure/ObjectLabel.hpp" 14 : #include "Options/Auto.hpp" 15 : #include "Options/Context.hpp" 16 : #include "Options/String.hpp" 17 : #include "Utilities/TMPL.hpp" 18 : 19 : namespace domain::creators::time_dependent_options { 20 : /// @{ 21 : /*! 22 : * \brief Read in FunctionOfTime coefficients from an H5 file and volume 23 : * subfile. 24 : * 25 : * \details The H5 file will only be accessed in the `retrieve_function_of_time` 26 : * function. 27 : */ 28 1 : struct FromVolumeFile { 29 0 : struct H5Filename { 30 0 : using type = std::string; 31 0 : static constexpr Options::String help{ 32 : "Name of H5 file to read functions of time from."}; 33 : }; 34 : 35 0 : struct SubfileName { 36 0 : using type = std::string; 37 0 : static constexpr Options::String help{ 38 : "Subfile that holds the volume data. Must be an h5::VolumeData " 39 : "subfile."}; 40 : }; 41 : 42 0 : using options = tmpl::list<H5Filename, SubfileName>; 43 0 : static constexpr Options::String help = 44 : "Read function of time coefficients from a volume subfile of an H5 file."; 45 : 46 0 : FromVolumeFile() = default; 47 : // The replay option cannot be set from options 48 0 : FromVolumeFile(std::string h5_filename, std::string subfile_name, 49 : bool replay = false); 50 : 51 : /*! 52 : * \brief Searches the last observation in the volume subfile and returns 53 : * clones of all functions of time in \p function_of_time_names. 54 : * 55 : * \details If a value for \p time is specified, will ensure that \p time is 56 : * within the `domain::FunctionsOfTime::FunctionOfTime::time_bounds()` of each 57 : * function of time. 58 : */ 59 1 : FunctionsOfTimeMap retrieve_function_of_time( 60 : const std::unordered_set<std::string>& function_of_time_names, 61 : const std::optional<double>& time) const; 62 : 63 : /*! 64 : * \brief Whether the function of time from the volume file should just be 65 : * replayed (read in and unmodified), or not. 66 : */ 67 1 : bool replay() const { return replay_; } 68 : 69 : private: 70 0 : std::string h5_filename_; 71 0 : std::string subfile_name_; 72 0 : bool replay_{false}; 73 : }; 74 : /// @} 75 : } // namespace domain::creators::time_dependent_options