fix(eos-bindings): minor bug fixes to bring eos bindings up to main
specifically, renamed EosIO -> EOSio, and updated read_helm_table signature
This commit is contained in:
@@ -8,8 +8,6 @@ subdir('opatIO')
|
||||
subdir('mpi')
|
||||
subdir('hypre')
|
||||
subdir('pybind')
|
||||
subdir('mpi')
|
||||
subdir('hypre')
|
||||
|
||||
# Set the config file error handling options
|
||||
configErr = get_option('config_error_handling')
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <string>
|
||||
|
||||
namespace serif::eos {
|
||||
EOSio::EOSio(const std::string filename) : m_filename(filename) {
|
||||
EOSio::EOSio(const std::string &filename) : m_filename(filename) {
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace serif::eos {
|
||||
>;
|
||||
|
||||
/**
|
||||
* @class EosIO
|
||||
* @class EOSio
|
||||
* @brief Handles the input/output operations for EOS tables.
|
||||
*
|
||||
* The EosIO class is responsible for loading and managing EOS tables from files.
|
||||
@@ -67,7 +67,7 @@ namespace serif::eos {
|
||||
* @brief Constructs an EosIO object with the given filename.
|
||||
* @param filename The filename of the EOS table.
|
||||
*/
|
||||
explicit EOSio(const std::string filename);
|
||||
explicit EOSio(const std::string &filename);
|
||||
|
||||
/**
|
||||
* @brief Default destructor.
|
||||
@@ -78,15 +78,15 @@ namespace serif::eos {
|
||||
* @brief Gets the format of the EOS table.
|
||||
* @return The format of the EOS table as a string.
|
||||
*/
|
||||
std::string getFormat() const;
|
||||
[[nodiscard]] std::string getFormat() const;
|
||||
|
||||
/**
|
||||
* @brief Gets the EOS table.
|
||||
* @return A reference to the EOS table.
|
||||
*/
|
||||
EOSTable& getTable();
|
||||
[[nodiscard]] EOSTable& getTable();
|
||||
|
||||
std::string getFilename() const { return m_filename; }
|
||||
[[nodiscard]] std::string getFilename() const { return m_filename; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -342,8 +342,8 @@ namespace serif::eos::helmholtz {
|
||||
* @param w1md Weight 1 for density (minus).
|
||||
* @return Result of the polynomial.
|
||||
*/
|
||||
double h3(double fi[36], double w0t, double w1t, double w0mt, double w1mt,
|
||||
double w0d, double w1d, double w0md, double w1md);
|
||||
double h3(const std::array<double, 36> &fi, const double w0t, const double w1t, const double w0mt, const double w1mt,
|
||||
const double w0d, const double w1d, const double w0md, const double w1md);
|
||||
|
||||
/**
|
||||
* @brief Interpolating polynomial function h5.
|
||||
@@ -362,16 +362,16 @@ namespace serif::eos::helmholtz {
|
||||
* @param w2md Weight 2 for density (minus).
|
||||
* @return Result of the polynomial.
|
||||
*/
|
||||
double h5(double fi[36], double w0t, double w1t, double w2t, double w0mt,
|
||||
double w1mt, double w2mt, double w0d, double w1d, double w2d,
|
||||
double w0md, double w1md, double w2md);
|
||||
double h5(const std::array<double, 36> &fi, const double w0t, const double w1t, const double w2t, const double w0mt,
|
||||
const double w1mt, const double w2mt, const double w0d, const double w1d, const double w2d,
|
||||
const double w0md, const double w1md, const double w2md);
|
||||
|
||||
/**
|
||||
* @brief Read the Helmholtz EOS table from a file.
|
||||
* @param filename Path to the file containing the table.
|
||||
* @return HELMTable structure containing the table data.
|
||||
*/
|
||||
std::unique_ptr<HELMTable> read_helm_table(const std::string filename);
|
||||
std::unique_ptr<HELMTable> read_helm_table(const std::string& filename);
|
||||
|
||||
/**
|
||||
* @brief Calculate the Helmholtz EOS components.
|
||||
|
||||
@@ -8,34 +8,38 @@
|
||||
// #include "resourceManager.h"
|
||||
#include "bindings.h"
|
||||
#include "EOSio.h"
|
||||
#include "../../eos/public/helm.h"
|
||||
#include "helm.h"
|
||||
|
||||
namespace serif::eos {
|
||||
class EOSio;
|
||||
}
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
|
||||
void register_eos_bindings(pybind11::module &eos_submodule) {
|
||||
py::class_<EOSio>(eos_submodule, "EOSio")
|
||||
py::class_<serif::eos::EOSio>(eos_submodule, "EOSio")
|
||||
.def(py::init<std::string>(), py::arg("filename"))
|
||||
// .def("load", &EOSio::load)
|
||||
.def("getFormat", &EOSio::getFormat, "Get the format of the EOS table.")
|
||||
.def("getFormat", &serif::eos::EOSio::getFormat, "Get the format of the EOS table.")
|
||||
|
||||
.def("__repr__", [](const EOSio &eos) {
|
||||
.def("__repr__", [](const serif::eos::EOSio &eos) {
|
||||
return "<EOSio(filename='" + eos.getFilename() + "', format='" + eos.getFormat() + "')>";
|
||||
});
|
||||
|
||||
py::class_<EOSTable>(eos_submodule, "EOSTable");
|
||||
py::class_<serif::eos::EOSTable>(eos_submodule, "EOSTable");
|
||||
|
||||
py::class_<helmholtz::HELMTable>(eos_submodule, "HELMTable")
|
||||
.def_readonly("loaded", &helmholtz::HELMTable::loaded)
|
||||
.def_readonly("imax", &helmholtz::HELMTable::imax)
|
||||
.def_readonly("jmax", &helmholtz::HELMTable::jmax)
|
||||
.def_readonly("t", &helmholtz::HELMTable::t)
|
||||
.def_readonly("d", &helmholtz::HELMTable::d)
|
||||
.def("__repr__", [](const helmholtz::HELMTable &table) {
|
||||
py::class_<serif::eos::helmholtz::HELMTable>(eos_submodule, "HELMTable")
|
||||
.def_readonly("loaded", &serif::eos::helmholtz::HELMTable::loaded)
|
||||
.def_readonly("imax", &serif::eos::helmholtz::HELMTable::imax)
|
||||
.def_readonly("jmax", &serif::eos::helmholtz::HELMTable::jmax)
|
||||
.def_readonly("t", &serif::eos::helmholtz::HELMTable::t)
|
||||
.def_readonly("d", &serif::eos::helmholtz::HELMTable::d)
|
||||
.def("__repr__", [](const serif::eos::helmholtz::HELMTable &table) {
|
||||
return "<HELMTable(loaded=" + std::to_string(table.loaded) + ", imax=" + std::to_string(table.imax) +
|
||||
", jmax=" + std::to_string(table.jmax) + ")>";
|
||||
})
|
||||
.def_property_readonly("f", [](helmholtz::HELMTable &table) -> py::array_t<double> {
|
||||
.def_property_readonly("f", [](serif::eos::helmholtz::HELMTable &table) -> py::array_t<double> {
|
||||
// --- Check Preconditions ---
|
||||
// 1. Check if dimensions are valid
|
||||
if (table.imax <= 0 || table.jmax <= 0) {
|
||||
@@ -57,8 +61,10 @@ void register_eos_bindings(pybind11::module &eos_submodule) {
|
||||
|
||||
// --- Define NumPy array shape and strides ---
|
||||
std::vector<py::ssize_t> shape = {rows, cols};
|
||||
std::vector<py::ssize_t> strides = {cols * sizeof(double), // Stride to next row
|
||||
sizeof(double)}; // Stride to next element in row
|
||||
std::vector<py::ssize_t> strides = {
|
||||
static_cast<py::ssize_t>(cols * sizeof(double)), // Stride to next row
|
||||
static_cast<py::ssize_t>( sizeof(double)) // Stride to next element in row
|
||||
};
|
||||
|
||||
// --- Create and return the py::array_t ---
|
||||
// py::cast(table) creates a py::object that acts as the 'base'.
|
||||
|
||||
Reference in New Issue
Block a user