Line data Source code
1 1 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : /// \file 5 : /// Defines class h5::StellarCollapseEos 6 : 7 : #pragma once 8 : 9 : #include <hdf5.h> 10 : #include <string> 11 : #include <vector> 12 : 13 : #include "DataStructures/BoostMultiArray.hpp" // IWYU pragma: keep 14 : #include "IO/H5/Object.hpp" 15 : #include "IO/H5/OpenGroup.hpp" 16 : 17 : // IWYU pragma: no_include <boost/multi_array.hpp> 18 : 19 : namespace h5 { 20 : /*! 21 : * \ingroup HDF5Group 22 : * \brief Reads in tabulated equation of state file from 23 : * [stellarcollapse.org](https://stellarcollapse.org) 24 : * 25 : * Reads in H5 file containing data for tabulated equation of state. 26 : * Contains functions to obtain thermodynamic quantities from the file, 27 : * stored as either rank-1 or rank-3 datasets. 28 : * 29 : * It is assumed that the file is in the format of the 30 : * [SRO (Schneider, Roberts, Ott 2017) Equation of State files](https:// 31 : * stellarcollapse.org/SROEOS) 32 : * 33 : * The description of each dataset in the file can be found 34 : * [here](https://bitbucket.org/andschn/sroeos/src/master/ 35 : * User_Guide/User_Guide.pdf?fileviewer=file-view-default) 36 : * 37 : */ 38 1 : class StellarCollapseEos : public h5::Object { 39 : public: 40 : /// \cond 41 : // The root-level HDF5 group in the SRO Equation of State files does not 42 : // have an extension in its group name 43 : static std::string extension() { return ""; } 44 : 45 : StellarCollapseEos(bool exists, detail::OpenGroup&& group, hid_t location, 46 : const std::string& name); 47 : 48 : StellarCollapseEos(const StellarCollapseEos& /*rhs*/) = delete; 49 : StellarCollapseEos& operator=(const StellarCollapseEos& /*rhs*/) = delete; 50 : StellarCollapseEos(StellarCollapseEos&& /*rhs*/) = delete; 51 : StellarCollapseEos& operator=(StellarCollapseEos&& /*rhs*/) = delete; 52 : 53 : ~StellarCollapseEos() override = default; 54 : /// \endcond 55 : 56 : /*! 57 : * \ingroup HDF5Group 58 : * \brief reads a rank-0 dataset (contains only one element) 59 : */ 60 : template <typename T> 61 1 : T get_scalar_dataset(const std::string& dataset_name) const; 62 : 63 : /*! 64 : * \ingroup HDF5Group 65 : * \brief reads a dataset with elements along 1 dimension 66 : */ 67 1 : std::vector<double> get_rank1_dataset(const std::string& dataset_name) const; 68 : 69 : /*! 70 : * \ingroup HDF5Group 71 : * \brief reads a dataset with elements along 3 dimensions 72 : */ 73 1 : boost::multi_array<double, 3> get_rank3_dataset( 74 : const std::string& dataset_name) const; 75 : 76 1 : const std::string& subfile_path() const override { return path_; } 77 : 78 : private: 79 0 : detail::OpenGroup root_group_; 80 0 : detail::OpenGroup group_; 81 0 : std::string path_; 82 : }; 83 : } // namespace h5