refactor(EosIO): renamed EosIO -> EOSio
This commit is contained in:
@@ -1,23 +1,24 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "eosIO.h"
|
||||
#include "EOSio.h"
|
||||
#include "helm.h"
|
||||
#include "debug.h"
|
||||
|
||||
EosIO::EosIO(const std::string filename) : m_filename(filename) {
|
||||
EOSio::EOSio(std::string filename) : m_filename(std::move(filename)) {
|
||||
load();
|
||||
}
|
||||
|
||||
std::string EosIO::getFormat() const {
|
||||
std::string EOSio::getFormat() const {
|
||||
return m_format;
|
||||
}
|
||||
|
||||
|
||||
EOSTable& EosIO::getTable() {
|
||||
EOSTable& EOSio::getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
void EosIO::load() {
|
||||
void EOSio::load() {
|
||||
// Load the EOS table from the file
|
||||
// For now, just set the format to HELM
|
||||
|
||||
@@ -27,10 +28,10 @@ void EosIO::load() {
|
||||
}
|
||||
}
|
||||
|
||||
void EosIO::loadHelm() {
|
||||
void EOSio::loadHelm() {
|
||||
// Load the HELM table from the file
|
||||
auto helmTabptr = helmholtz::read_helm_table(m_filename);
|
||||
m_table = std::move(helmTabptr);
|
||||
auto helmTabPtr = helmholtz::read_helm_table(m_filename);
|
||||
m_table = std::move(helmTabPtr);
|
||||
m_loaded = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef EOSIO_H
|
||||
#define EOSIO_H
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <variant>
|
||||
@@ -13,20 +12,20 @@ using EOSTable = std::variant<
|
||||
>;
|
||||
|
||||
/**
|
||||
* @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.
|
||||
* The EOSio class is responsible for loading and managing EOS tables from files.
|
||||
* It supports different formats, currently only HELM format.
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* EosIO eosIO("path/to/file");
|
||||
* EOSio eosIO("path/to/file");
|
||||
* std::string format = eosIO.getFormat();
|
||||
* EOSTable& table = eosIO.getTable();
|
||||
* @endcode
|
||||
*/
|
||||
class EosIO {
|
||||
class EOSio {
|
||||
private:
|
||||
std::string m_filename; ///< The filename of the EOS table.
|
||||
bool m_loaded = false; ///< Flag indicating if the table is loaded.
|
||||
@@ -47,12 +46,12 @@ public:
|
||||
* @brief Constructs an EosIO object with the given filename.
|
||||
* @param filename The filename of the EOS table.
|
||||
*/
|
||||
EosIO(const std::string filename);
|
||||
EOSio(std::string filename);
|
||||
|
||||
/**
|
||||
* @brief Default destructor.
|
||||
*/
|
||||
~EosIO() = default;
|
||||
~EOSio() = default;
|
||||
|
||||
/**
|
||||
* @brief Gets the format of the EOS table.
|
||||
@@ -66,5 +65,3 @@ public:
|
||||
*/
|
||||
EOSTable& getTable();
|
||||
};
|
||||
|
||||
#endif // EOSIO_H
|
||||
@@ -21,9 +21,7 @@
|
||||
// this file contains a C++ conversion of Frank Timmes' fortran code
|
||||
// helmholtz.f90, which implements the Helmholtz Free Energy EOS described
|
||||
// by Timmes & Swesty (2000) doi:10.1086/313304 -- Aaron Dotter 2025
|
||||
|
||||
#ifndef HELM_H
|
||||
#define HELM_H
|
||||
#pragma once
|
||||
|
||||
#define IMAX 541
|
||||
#define JMAX 201
|
||||
@@ -141,118 +139,6 @@ namespace helmholtz
|
||||
heap_deallocate_contiguous_2D_memory(xfdt);
|
||||
}
|
||||
|
||||
// // Delete copy constructor and copy assignment operator to prevent accidental shallow copies
|
||||
// HELMTable(const HELMTable&) = delete;
|
||||
// HELMTable& operator=(const HELMTable&) = delete;
|
||||
|
||||
// // Move constructor
|
||||
// HELMTable(HELMTable&& other) noexcept
|
||||
// : loaded(other.loaded),
|
||||
// f(other.f), fd(other.fd), ft(other.ft), fdd(other.fdd), ftt(other.ftt), fdt(other.fdt),
|
||||
// fddt(other.fddt), fdtt(other.fdtt), fddtt(other.fddtt),
|
||||
// dpdf(other.dpdf), dpdfd(other.dpdfd), dpdft(other.dpdft), dpdfdt(other.dpdfdt),
|
||||
// ef(other.ef), efd(other.efd), eft(other.eft), efdt(other.efdt),
|
||||
// xf(other.xf), xfd(other.xfd), xft(other.xft), xfdt(other.xfdt)
|
||||
// {
|
||||
// other.f = nullptr;
|
||||
// other.fd = nullptr;
|
||||
// other.ft = nullptr;
|
||||
// other.fdd = nullptr;
|
||||
// other.ftt = nullptr;
|
||||
// other.fdt = nullptr;
|
||||
// other.fddt = nullptr;
|
||||
// other.fdtt = nullptr;
|
||||
// other.fddtt = nullptr;
|
||||
// other.dpdf = nullptr;
|
||||
// other.dpdfd = nullptr;
|
||||
// other.dpdft = nullptr;
|
||||
// other.dpdfdt = nullptr;
|
||||
// other.ef = nullptr;
|
||||
// other.efd = nullptr;
|
||||
// other.eft = nullptr;
|
||||
// other.efdt = nullptr;
|
||||
// other.xf = nullptr;
|
||||
// other.xfd = nullptr;
|
||||
// other.xft = nullptr;
|
||||
// other.xfdt = nullptr;
|
||||
// }
|
||||
|
||||
// // Move assignment operator
|
||||
// HELMTable& operator=(HELMTable&& other) noexcept {
|
||||
// if (this != &other) {
|
||||
// // Deallocate current memory
|
||||
// heap_deallocate_contiguous_2D_memory(f);
|
||||
// heap_deallocate_contiguous_2D_memory(fd);
|
||||
// heap_deallocate_contiguous_2D_memory(ft);
|
||||
// heap_deallocate_contiguous_2D_memory(fdd);
|
||||
// heap_deallocate_contiguous_2D_memory(ftt);
|
||||
// heap_deallocate_contiguous_2D_memory(fdt);
|
||||
// heap_deallocate_contiguous_2D_memory(fddt);
|
||||
// heap_deallocate_contiguous_2D_memory(fdtt);
|
||||
// heap_deallocate_contiguous_2D_memory(fddtt);
|
||||
// heap_deallocate_contiguous_2D_memory(dpdf);
|
||||
// heap_deallocate_contiguous_2D_memory(dpdfd);
|
||||
// heap_deallocate_contiguous_2D_memory(dpdft);
|
||||
// heap_deallocate_contiguous_2D_memory(dpdfdt);
|
||||
// heap_deallocate_contiguous_2D_memory(ef);
|
||||
// heap_deallocate_contiguous_2D_memory(efd);
|
||||
// heap_deallocate_contiguous_2D_memory(eft);
|
||||
// heap_deallocate_contiguous_2D_memory(efdt);
|
||||
// heap_deallocate_contiguous_2D_memory(xf);
|
||||
// heap_deallocate_contiguous_2D_memory(xfd);
|
||||
// heap_deallocate_contiguous_2D_memory(xft);
|
||||
// heap_deallocate_contiguous_2D_memory(xfdt);
|
||||
|
||||
// // Transfer ownership of resources
|
||||
// loaded = other.loaded;
|
||||
// f = other.f;
|
||||
// fd = other.fd;
|
||||
// ft = other.ft;
|
||||
// fdd = other.fdd;
|
||||
// ftt = other.ftt;
|
||||
// fdt = other.fdt;
|
||||
// fddt = other.fddt;
|
||||
// fdtt = other.fdtt;
|
||||
// fddtt = other.fddtt;
|
||||
// dpdf = other.dpdf;
|
||||
// dpdfd = other.dpdfd;
|
||||
// dpdft = other.dpdft;
|
||||
// dpdfdt = other.dpdfdt;
|
||||
// ef = other.ef;
|
||||
// efd = other.efd;
|
||||
// eft = other.eft;
|
||||
// efdt = other.efdt;
|
||||
// xf = other.xf;
|
||||
// xfd = other.xfd;
|
||||
// xft = other.xft;
|
||||
// xfdt = other.xfdt;
|
||||
|
||||
// // Null out the other object's pointers
|
||||
// other.f = nullptr;
|
||||
// other.fd = nullptr;
|
||||
// other.ft = nullptr;
|
||||
// other.fdd = nullptr;
|
||||
// other.ftt = nullptr;
|
||||
// other.fdt = nullptr;
|
||||
// other.fddt = nullptr;
|
||||
// other.fdtt = nullptr;
|
||||
// other.fddtt = nullptr;
|
||||
// other.dpdf = nullptr;
|
||||
// other.dpdfd = nullptr;
|
||||
// other.dpdft = nullptr;
|
||||
// other.dpdfdt = nullptr;
|
||||
// other.ef = nullptr;
|
||||
// other.efd = nullptr;
|
||||
// other.eft = nullptr;
|
||||
// other.efdt = nullptr;
|
||||
// other.xf = nullptr;
|
||||
// other.xfd = nullptr;
|
||||
// other.xft = nullptr;
|
||||
// other.xfdt = nullptr;
|
||||
// }
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const helmholtz::HELMTable& table) {
|
||||
if (!table.loaded) {
|
||||
os << "HELMTable not loaded\n";
|
||||
@@ -497,4 +383,3 @@ namespace helmholtz
|
||||
|
||||
}
|
||||
|
||||
#endif // HELM_H
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "resourceManagerTypes.h"
|
||||
#include "opatIO.h"
|
||||
#include "meshIO.h"
|
||||
#include "eosIO.h"
|
||||
#include "EOSio.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
@@ -48,7 +48,7 @@ Resource createResource(const std::string& type, const std::string& path) {
|
||||
std::make_unique<MeshIO>(p));
|
||||
}},
|
||||
{"eos", [](const std::string& p) { return Resource(
|
||||
std::make_unique<EosIO>(p));
|
||||
std::make_unique<EOSio>(p));
|
||||
}}
|
||||
// Add more mappings as needed
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "opatIO.h"
|
||||
#include "helm.h"
|
||||
#include "meshIO.h"
|
||||
#include "eosIO.h"
|
||||
#include "EOSio.h"
|
||||
|
||||
/**
|
||||
* @file resourceManagerTypes.h
|
||||
@@ -42,7 +42,7 @@
|
||||
* @brief A variant type that can hold different types of resources.
|
||||
*
|
||||
* The Resource type is a std::variant that can hold a unique pointer to
|
||||
* an OpatIO, MeshIO, or EosIO object.
|
||||
* an OpatIO, MeshIO, or EOSio object.
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
@@ -52,7 +52,7 @@
|
||||
using Resource = std::variant<
|
||||
std::unique_ptr<opat::OPAT>,
|
||||
std::unique_ptr<MeshIO>,
|
||||
std::unique_ptr<EosIO>>;
|
||||
std::unique_ptr<EOSio>>;
|
||||
|
||||
/**
|
||||
* @brief Extracts the first segment of a given string.
|
||||
@@ -77,7 +77,7 @@ std::string getFirstSegment(const std::string& input);
|
||||
* This function creates a resource object based on the provided type
|
||||
* and initializes it using the given path.
|
||||
*
|
||||
* @param type The type of the resource to be created (e.g., "OpatIO", "MeshIO", "EosIO").
|
||||
* @param type The type of the resource to be created (e.g., "OpatIO", "MeshIO", "EOSio").
|
||||
* @param path The path to initialize the resource with.
|
||||
* @return A Resource object initialized with the specified type and path.
|
||||
*
|
||||
|
||||
@@ -27,7 +27,7 @@ std::string TEST_CONFIG = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/tes
|
||||
TEST_F(eosTest, read_helm_table) {
|
||||
Config::getInstance().loadConfig(TEST_CONFIG);
|
||||
ResourceManager& rm = ResourceManager::getInstance();
|
||||
auto& eos = std::get<std::unique_ptr<EosIO>>(rm.getResource("eos:helm"));
|
||||
auto& eos = std::get<std::unique_ptr<EOSio>>(rm.getResource("eos:helm"));
|
||||
auto& table = eos->getTable();
|
||||
auto& helmTable = *std::get<std::unique_ptr<helmholtz::HELMTable>>(table);
|
||||
std::stringstream ss;
|
||||
@@ -59,7 +59,7 @@ TEST_F(eosTest, get_helm_EOS) {
|
||||
eos1.zbar = eos1.abar*zsum;
|
||||
|
||||
ResourceManager& rm = ResourceManager::getInstance();
|
||||
auto& eos = std::get<std::unique_ptr<EosIO>>(rm.getResource("eos:helm"));
|
||||
auto& eos = std::get<std::unique_ptr<EOSio>>(rm.getResource("eos:helm"));
|
||||
auto& table = eos->getTable();
|
||||
auto& helmTable = *std::get<std::unique_ptr<helmholtz::HELMTable>>(table);
|
||||
EOS helmEos = get_helm_EOS(eos1, helmTable);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "resourceManager.h"
|
||||
#include "config.h"
|
||||
#include "eosIO.h"
|
||||
#include "EOSio.h"
|
||||
#include "helm.h"
|
||||
#include "resourceManagerTypes.h"
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST_F(resourceManagerTest, getResource) {
|
||||
std::string name = "eos:helm";
|
||||
const Resource &r = rm.getResource(name);
|
||||
// BREAKPOINT();
|
||||
const auto &eos = std::get<std::unique_ptr<EosIO>>(r);
|
||||
const auto &eos = std::get<std::unique_ptr<EOSio>>(r);
|
||||
EXPECT_EQ("helm", eos->getFormat());
|
||||
EOSTable &table = eos->getTable();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user