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 : #include <pup.h> 8 : #include <string> 9 : 10 : #include "NumericalAlgorithms/Strahlkorper/InitialShape.hpp" 11 : #include "Options/Context.hpp" 12 : #include "Options/String.hpp" 13 : #include "Utilities/Serialization/CharmPupable.hpp" 14 : #include "Utilities/TMPL.hpp" 15 : 16 : namespace ylm { 17 : template <typename Frame> 18 : class Strahlkorper; 19 : 20 : namespace InitialShapes { 21 : /*! 22 : * \ingroup SurfacesGroup 23 : * \brief An initial Strahlkorper shape read from an H5 file. 24 : */ 25 : template <typename Frame> 26 1 : class FromFile : public InitialShape<Frame> { 27 : public: 28 0 : struct H5Filename { 29 0 : using type = std::string; 30 0 : static constexpr Options::String help = { 31 : "H5 file containing the Strahlkorper coefficients"}; 32 : }; 33 0 : struct SubfileName { 34 0 : using type = std::string; 35 0 : static constexpr Options::String help = { 36 : "Subfile (without leading slash or .dat extension) within " 37 : "the H5 file that contains the Strahlkorper coefficients"}; 38 : }; 39 0 : struct Time { 40 0 : using type = double; 41 0 : static constexpr Options::String help = { 42 : "Time at which to read the Strahlkorper coefficients"}; 43 : }; 44 0 : struct TimeEpsilon { 45 0 : using type = double; 46 0 : static constexpr Options::String help = { 47 : "Tolerance for matching the requested time to read the Strahlkorper " 48 : "coefficients"}; 49 : }; 50 0 : struct CheckFrame { 51 0 : using type = bool; 52 0 : static constexpr Options::String help = { 53 : "Whether to check that the frame in the file matches the requested " 54 : "frame"}; 55 : }; 56 : 57 0 : using options = 58 : tmpl::list<H5Filename, SubfileName, Time, TimeEpsilon, CheckFrame>; 59 0 : static constexpr Options::String help = { 60 : "Construct a Strahlkorper from coefficients read from an H5 file."}; 61 0 : static std::string name() { return "FromFile"; } 62 : 63 0 : FromFile() = default; 64 0 : FromFile(std::string h5_filename, std::string subfile_name, double time, 65 : double time_epsilon, bool check_frame); 66 : 67 : /// \cond 68 : explicit FromFile(CkMigrateMessage* msg); 69 : using PUP::able::register_constructor; 70 : WRAPPED_PUPable_decl_template(FromFile); // NOLINT 71 : /// \endcond 72 : 73 1 : Strahlkorper<Frame> strahlkorper( 74 : size_t l_max, const Options::Context& context) const override; 75 : 76 0 : void pup(PUP::er& p) override; 77 : 78 : private: 79 0 : std::string h5_filename_{}; 80 0 : std::string subfile_name_{}; 81 0 : double time_{}; 82 0 : double time_epsilon_{}; 83 0 : bool check_frame_{}; 84 : }; 85 : } // namespace InitialShapes 86 : } // namespace ylm