From 95d344a79c1d9fd9d706b4af93316daf636c31f8 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Sun, 11 May 2025 14:58:00 -0400 Subject: [PATCH] refactor(EosIO): renamed EosIO -> EOSio --- src/eos/private/{eosIO.cpp => EOSio.cpp} | 17 +-- src/eos/public/{eosIO.h => EOSio.h} | 17 ++- src/eos/public/helm.h | 117 +----------------- src/resource/private/resourceManagerTypes.cpp | 4 +- src/resource/public/resourceManagerTypes.h | 8 +- tests/eos/eosTest.cpp | 4 +- tests/resource/resourceManagerTest.cpp | 4 +- 7 files changed, 27 insertions(+), 144 deletions(-) rename src/eos/private/{eosIO.cpp => EOSio.cpp} (52%) rename src/eos/public/{eosIO.h => EOSio.h} (85%) diff --git a/src/eos/private/eosIO.cpp b/src/eos/private/EOSio.cpp similarity index 52% rename from src/eos/private/eosIO.cpp rename to src/eos/private/EOSio.cpp index ba3e471..23a4adf 100644 --- a/src/eos/private/eosIO.cpp +++ b/src/eos/private/EOSio.cpp @@ -1,23 +1,24 @@ #include +#include -#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; } diff --git a/src/eos/public/eosIO.h b/src/eos/public/EOSio.h similarity index 85% rename from src/eos/public/eosIO.h rename to src/eos/public/EOSio.h index aab0c59..15899f0 100644 --- a/src/eos/public/eosIO.h +++ b/src/eos/public/EOSio.h @@ -1,5 +1,4 @@ -#ifndef EOSIO_H -#define EOSIO_H +#pragma once #include #include @@ -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 \ No newline at end of file diff --git a/src/eos/public/helm.h b/src/eos/public/helm.h index 64e7a8a..dcd7559 100644 --- a/src/eos/public/helm.h +++ b/src/eos/public/helm.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 diff --git a/src/resource/private/resourceManagerTypes.cpp b/src/resource/private/resourceManagerTypes.cpp index 26d77df..b5f6cc9 100644 --- a/src/resource/private/resourceManagerTypes.cpp +++ b/src/resource/private/resourceManagerTypes.cpp @@ -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(p)); }}, {"eos", [](const std::string& p) { return Resource( - std::make_unique(p)); + std::make_unique(p)); }} // Add more mappings as needed }; diff --git a/src/resource/public/resourceManagerTypes.h b/src/resource/public/resourceManagerTypes.h index 5161fcc..df6ca54 100644 --- a/src/resource/public/resourceManagerTypes.h +++ b/src/resource/public/resourceManagerTypes.h @@ -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, std::unique_ptr, - std::unique_ptr>; + std::unique_ptr>; /** * @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. * diff --git a/tests/eos/eosTest.cpp b/tests/eos/eosTest.cpp index b1a352b..f88d0bc 100644 --- a/tests/eos/eosTest.cpp +++ b/tests/eos/eosTest.cpp @@ -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>(rm.getResource("eos:helm")); + auto& eos = std::get>(rm.getResource("eos:helm")); auto& table = eos->getTable(); auto& helmTable = *std::get>(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>(rm.getResource("eos:helm")); + auto& eos = std::get>(rm.getResource("eos:helm")); auto& table = eos->getTable(); auto& helmTable = *std::get>(table); EOS helmEos = get_helm_EOS(eos1, helmTable); diff --git a/tests/resource/resourceManagerTest.cpp b/tests/resource/resourceManagerTest.cpp index d0264d7..a64d079 100644 --- a/tests/resource/resourceManagerTest.cpp +++ b/tests/resource/resourceManagerTest.cpp @@ -1,7 +1,7 @@ #include #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>(r); + const auto &eos = std::get>(r); EXPECT_EQ("helm", eos->getFormat()); EOSTable &table = eos->getTable();