SpECTRE Documentation Coverage Report
Current view: top level - IO/H5 - EosTable.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 44.1 % 34 15
Test Date: 2026-10-22 17:29:42
Legend: Lines:     hit not hit

            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 <cstdint>
       8              : #include <hdf5.h>
       9              : #include <string>
      10              : #include <vector>
      11              : 
      12              : #include "IO/H5/Object.hpp"
      13              : #include "IO/H5/OpenGroup.hpp"
      14              : 
      15              : /// \cond
      16              : class DataVector;
      17              : /// \endcond
      18              : 
      19              : namespace h5 {
      20              : /*!
      21              :  * \ingroup HDF5Group
      22              :  * \brief An equation of state table subfile written inside an H5 file.
      23              :  *
      24              :  * ### Data Layout
      25              :  *
      26              :  * To be consistent with the CompOSE ASCII table format, the data is stored in a
      27              :  * last independent variable varies fastest. For example, if you had independent
      28              :  * variables \f$\rho\f$, \f$T\f$, and \f$Y_e\f$, then \f$Y_e\f$ varies fastest
      29              :  * while \f$\rho\f$ varies slowest.
      30              :  */
      31            1 : class EosTable : public h5::Object {
      32              :  public:
      33            0 :   static std::string extension() { return ".eos"; }
      34              : 
      35              :   /// Constructor used when writing a new equation of state.
      36            1 :   EosTable(bool subfile_exists, detail::OpenGroup&& group, hid_t location,
      37              :            const std::string& name,
      38              :            std::vector<std::string> independent_variable_names,
      39              :            std::vector<std::array<double, 2>> independent_variable_bounds,
      40              :            std::vector<size_t> independent_variable_number_of_points,
      41              :            std::vector<bool> independent_variable_uses_log_spacing,
      42              :            bool beta_equilibrium, uint32_t version = 1);
      43              : 
      44              :   /// Constructor used when reading in an equation of state.
      45            1 :   EosTable(bool subfile_exists, detail::OpenGroup&& group, hid_t location,
      46              :            const std::string& name);
      47              : 
      48            0 :   EosTable(const EosTable& /*rhs*/) = delete;
      49            0 :   EosTable& operator=(const EosTable& /*rhs*/) = delete;
      50            0 :   EosTable(EosTable&& /*rhs*/) = delete;             // NOLINT
      51            0 :   EosTable& operator=(EosTable&& /*rhs*/) = delete;  // NOLINT
      52              : 
      53            0 :   ~EosTable() override = default;
      54              : 
      55              :   /*!
      56              :    * \returns the header of the EosTable file
      57              :    */
      58            1 :   const std::string& get_header() const { return header_; }
      59              : 
      60              :   /*!
      61              :    * \returns the user-specified version number of the EosTable file
      62              :    *
      63              :    * \note h5::Version returns a uint32_t, so we return one here too for the
      64              :    * version
      65              :    */
      66            1 :   uint32_t get_version() const { return version_; }
      67              : 
      68            1 :   const std::string& subfile_path() const override { return path_; }
      69              : 
      70              :   /*!
      71              :    * \brief Write a thermodynamic quantity to disk.
      72              :    */
      73            1 :   void write_quantity(std::string name, const DataVector& data);
      74              : 
      75              :   /*!
      76              :    * \brief Read a thermodynamic quantity to disk.
      77              :    */
      78            1 :   DataVector read_quantity(const std::string& name) const;
      79              : 
      80              :   /// The available thermodynamic quantities.
      81            1 :   const std::vector<std::string> available_quantities() const {
      82              :     return available_quantities_;
      83              :   }
      84              : 
      85              :   /// Number of independent variables.
      86            1 :   size_t number_of_independent_variables() const {
      87              :     return independent_variable_names_.size();
      88              :   }
      89              : 
      90              :   /// Names of the independent variables.
      91            1 :   const std::vector<std::string>& independent_variable_names() const {
      92              :     return independent_variable_names_;
      93              :   }
      94              : 
      95              :   /// Lower and upper bounds of the independent variables.
      96            1 :   const std::vector<std::array<double, 2>>& independent_variable_bounds()
      97              :       const {
      98              :     return independent_variable_bounds_;
      99              :   }
     100              : 
     101              :   /// The number of points for each of the independent variables.
     102            1 :   const std::vector<size_t>& independent_variable_number_of_points() const {
     103              :     return independent_variable_number_of_points_;
     104              :   }
     105              : 
     106              :   /// Whether each independent variable is in log spacing. Linear spacing is
     107              :   /// used if `false`.
     108            1 :   const std::vector<bool>& independent_variable_uses_log_spacing() const {
     109              :     return independent_variable_uses_log_spacing_;
     110              :   }
     111              : 
     112              :   /// `true` if the EOS is in beta equilibrium.
     113            1 :   bool beta_equilibrium() const { return beta_equilibrium_; }
     114              : 
     115              :  private:
     116            0 :   detail::OpenGroup group_{};
     117            0 :   std::string name_{};
     118            0 :   std::string path_{};
     119            0 :   uint32_t version_{};
     120            0 :   detail::OpenGroup eos_table_group_{};
     121            0 :   std::string header_{};
     122              : 
     123            0 :   std::vector<std::string> independent_variable_names_{};
     124            0 :   std::vector<std::array<double, 2>> independent_variable_bounds_{};
     125            0 :   std::vector<size_t> independent_variable_number_of_points_{};
     126            0 :   std::vector<bool> independent_variable_uses_log_spacing_{};
     127            0 :   bool beta_equilibrium_ = false;
     128            0 :   std::vector<std::string> available_quantities_{};
     129              : };
     130              : }  // namespace h5
        

Generated by: LCOV version 2.0-1