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