diff --git a/.gitignore b/.gitignore index ab5ee4d..141f25e 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,7 @@ subprojects/pybind11*/ subprojects/packagecache/ subprojects/hypre/ subprojects/qhull/ +subprojects/libconstants/ qhull.wrap diff --git a/assets/static/meson.build b/assets/static/meson.build index 9e902de..aa735dc 100644 --- a/assets/static/meson.build +++ b/assets/static/meson.build @@ -1,2 +1 @@ -subdir('const') -subdir('atomic') \ No newline at end of file +subdir('atomic') diff --git a/build-config/fourdst/libconstants/meson.build b/build-config/fourdst/libconstants/meson.build new file mode 100644 index 0000000..d578238 --- /dev/null +++ b/build-config/fourdst/libconstants/meson.build @@ -0,0 +1,2 @@ +const_p = subproject('libconstants') +const_dep = const_p.get_variable('const_dep') diff --git a/build-config/fourdst/meson.build b/build-config/fourdst/meson.build new file mode 100644 index 0000000..6f7c958 --- /dev/null +++ b/build-config/fourdst/meson.build @@ -0,0 +1 @@ +subdir('libconstants') diff --git a/build-config/meson.build b/build-config/meson.build index 0dab29f..4937af3 100644 --- a/build-config/meson.build +++ b/build-config/meson.build @@ -1,5 +1,7 @@ cmake = import('cmake') +subdir('fourdst') + subdir('mfem') subdir('yaml-cpp') subdir('quill') @@ -20,4 +22,4 @@ elif configErr == 'harsh' commonCppArgs += ['-DCONFIG_HARSH'] endif -add_project_arguments(commonCppArgs, language: 'cpp') \ No newline at end of file +add_project_arguments(commonCppArgs, language: 'cpp') diff --git a/src/eos/private/helm.cpp b/src/eos/private/helm.cpp index e2df9de..f97ca9c 100644 --- a/src/eos/private/helm.cpp +++ b/src/eos/private/helm.cpp @@ -41,10 +41,6 @@ #include "config.h" #include "quill/LogMacros.h" -namespace serif::constant { - class Constants; -} - using namespace std; // interpolating polynomila function definitions @@ -246,7 +242,7 @@ namespace serif::eos::helmholtz { serif::probe::LogManager& logManager = serif::probe::LogManager::getInstance(); quill::Logger* logger = logManager.getLogger(logFile); - serif::constant::Constants& constants = serif::constant::Constants::getInstance(); + fourdst::constant::Constants& constants = fourdst::constant::Constants::getInstance(); const double pi = std::numbers::pi; const double amu = constants.get("u").value; const double h = constants.get("h").value; diff --git a/src/meson.build b/src/meson.build index b424179..bfe3449 100644 --- a/src/meson.build +++ b/src/meson.build @@ -9,7 +9,7 @@ subdir('config') subdir('probe') # Physically Informed Libraries -subdir('constants') +# subdir('constants') subdir('composition') # Asset Libraries diff --git a/src/network/private/approx8.cpp b/src/network/private/approx8.cpp index f46bb7e..c08d53b 100644 --- a/src/network/private/approx8.cpp +++ b/src/network/private/approx8.cpp @@ -245,7 +245,7 @@ namespace serif::network::approx8{ // a Jacobian matrix for implicit solvers void Jacobian::operator() ( const vector_type &y, matrix_type &J, double /* t */, vector_type &dfdt ) const { - serif::constant::Constants& constants = serif::constant::Constants::getInstance(); + fourdst::constant::Constants& constants = fourdst::constant::Constants::getInstance(); const double avo = constants.get("N_a").value; const double clight = constants.get("c").value; // EOS @@ -350,7 +350,7 @@ namespace serif::network::approx8{ } void ODE::operator() ( const vector_type &y, vector_type &dydt, double /* t */) const { - const serif::constant::Constants& constants = serif::constant::Constants::getInstance(); + const fourdst::constant::Constants& constants = fourdst::constant::Constants::getInstance(); const double avo = constants.get("N_a").value; const double clight = constants.get("c").value; diff --git a/src/python/const/bindings.cpp b/src/python/const/bindings.cpp index 4f67ed3..11679c6 100644 --- a/src/python/const/bindings.cpp +++ b/src/python/const/bindings.cpp @@ -10,44 +10,44 @@ namespace py = pybind11; void register_const_bindings(pybind11::module &const_submodule) { - py::class_(const_submodule, "Constant") - .def_readonly("name", &serif::constant::Constant::name) - .def_readonly("value", &serif::constant::Constant::value) - .def_readonly("uncertainty", &serif::constant::Constant::uncertainty) - .def_readonly("unit", &serif::constant::Constant::unit) - .def_readonly("reference", &serif::constant::Constant::reference) - .def("__repr__", [](const serif::constant::Constant &c) { + py::class_(const_submodule, "Constant") + .def_readonly("name", &fourdst::constant::Constant::name) + .def_readonly("value", &fourdst::constant::Constant::value) + .def_readonly("uncertainty", &fourdst::constant::Constant::uncertainty) + .def_readonly("unit", &fourdst::constant::Constant::unit) + .def_readonly("reference", &fourdst::constant::Constant::reference) + .def("__repr__", [](const fourdst::constant::Constant &c) { return ""; }); - py::class_(const_submodule, "Constants") - .def_property_readonly("loaded", &serif::constant::Constants::isLoaded) + py::class_(const_submodule, "Constants") + .def_property_readonly("loaded", &fourdst::constant::Constants::isLoaded) .def_static("get", [](const std::string &name) { return py::cast( - serif::constant::Constants::getInstance().get(name) + fourdst::constant::Constants::getInstance().get(name) ); }, "Get a constant by name. Returns None if not found." ) .def_static("has", [](const std::string &name) { - return serif::constant::Constants::getInstance().has(name); + return fourdst::constant::Constants::getInstance().has(name); }, "Check if a constant exists by name.") .def_static("keys", []() { return py::cast( - serif::constant::Constants::getInstance().keys() + fourdst::constant::Constants::getInstance().keys() ); }, "Get a list of all constant names.") .def_static("__class_getitem__", [](const std::string &name) { return py::cast( - serif::constant::Constants::getInstance().get(name) + fourdst::constant::Constants::getInstance().get(name) ); }); diff --git a/subprojects/libconstants.wrap b/subprojects/libconstants.wrap new file mode 100644 index 0000000..26d2ceb --- /dev/null +++ b/subprojects/libconstants.wrap @@ -0,0 +1,7 @@ +[wrap-git] +url = git@github.com:4D-STAR/libconstants.git +revision = v1.1 +depth = 1 + +[provide] +libconstants = const_dep diff --git a/tests/config/meson.build b/tests/config/meson.build index 1aaffb1..8a5f3bb 100644 --- a/tests/config/meson.build +++ b/tests/config/meson.build @@ -13,7 +13,6 @@ foreach test_file : test_sources test_file, dependencies: [gtest_dep, config_dep, gtest_main], include_directories: include_directories('../../src/config/public'), - link_with: libconst, # Link the dobj library install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly ) diff --git a/tests/const/constTest.cpp b/tests/const/constTest.cpp deleted file mode 100644 index b458339..0000000 --- a/tests/const/constTest.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include "const.h" -#include -#include -#include -#include -#include - -/** - * @file constTest.cpp - * @brief Unit tests for the const class. - */ - -/** - * @brief Test suite for the const class. - */ -class constTest : public ::testing::Test { -protected: - void SetUp() override { - serif::constant::Constants::getInstance(); - } -}; - -/** - * @test Verify default constructor initializes correctly. - */ -TEST_F(constTest, DefaultConstructor) { - EXPECT_NO_THROW(serif::constant::Constants::getInstance()); -} - -/** - * @test Verify constructor initializes with provided data and metadata. - */ -TEST_F(constTest, isLoaded) { - - EXPECT_NO_THROW(serif::constant::Constants::getInstance().isLoaded()); -} - -/** - * @test Verify get method returns the correct constant. - */ -TEST_F(constTest, GetMethod) { - serif::constant::Constants& obj = serif::constant::Constants::getInstance(); - EXPECT_DOUBLE_EQ(obj.get("c").value, 2.99792458e10); - EXPECT_EQ(obj.get("c").unit, "cm / s"); - EXPECT_DOUBLE_EQ(obj.get("c").uncertainty, 0.0); - EXPECT_EQ(obj.get("c").reference, "CODATA2022"); -} - -/** - * @test Verify [] opperators returns the correct constant. - */ -TEST_F(constTest, SubscriptOperator) { - serif::constant::Constants& obj = serif::constant::Constants::getInstance(); - EXPECT_DOUBLE_EQ(obj["c"].value, 2.99792458e10); - EXPECT_EQ(obj["c"].unit, "cm / s"); - EXPECT_DOUBLE_EQ(obj["c"].uncertainty, 0.0); - EXPECT_EQ(obj["c"].reference, "CODATA2022"); -} - -/** - * @test Verify that the has method returns the correct values - */ -TEST_F(constTest, HasMethod) { - serif::constant::Constants& obj = serif::constant::Constants::getInstance(); - - EXPECT_TRUE(obj.has("c")); - EXPECT_FALSE(obj.has("c4")); - EXPECT_TRUE(obj.has("hbar")); -} - -TEST_F(constTest, KeysMethod) { - serif::constant::Constants& obj = serif::constant::Constants::getInstance(); - std::set checkKeys; - checkKeys.insert("c"); - checkKeys.insert("wienK"); - checkKeys.insert("hbar"); - checkKeys.insert("g_h"); - checkKeys.insert("R_sun"); - - std::set keys = obj.keys(); - - for (const auto& key : checkKeys) { - bool found = keys.find(key) != keys.end(); - EXPECT_TRUE(found); - } - - std::set checkBadKeys; - checkBadKeys.insert("c4"); - checkBadKeys.insert("wienK4"); - checkBadKeys.insert("hbar4"); - checkBadKeys.insert("g_h4"); - checkBadKeys.insert("R_sun4"); - - for (const auto& key : checkBadKeys) { - bool found = keys.find(key) != keys.end(); - EXPECT_FALSE(found); - } -} - -TEST_F(constTest, StreamOperator) { - serif::constant::Constants& obj = serif::constant::Constants::getInstance(); - std::ostringstream os; - - os << obj.get("c"); - std::string expected = "\n"; - - EXPECT_EQ(os.str(), expected); -} \ No newline at end of file diff --git a/tests/const/meson.build b/tests/const/meson.build deleted file mode 100644 index 53ec814..0000000 --- a/tests/const/meson.build +++ /dev/null @@ -1,22 +0,0 @@ -# Test files for const -test_sources = [ - 'constTest.cpp', -] - -foreach test_file : test_sources - exe_name = test_file.split('.')[0] - message('Building test: ' + exe_name) - - # Create an executable target for each test - test_exe = executable( - exe_name, - test_file, - dependencies: [gtest_dep, const_dep, gtest_main], - include_directories: include_directories('../../src/constants/public'), - link_with: libconst, # Link the dobj library - install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly - ) - - # Add the executable as a test - test(exe_name, test_exe) -endforeach diff --git a/tests/meson.build b/tests/meson.build index c89e717..1d2c01f 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -4,7 +4,6 @@ gtest_main = dependency('gtest_main', required: true) gtest_nomain_dep = dependency('gtest', main: false, required : true) # Subdirectories for unit and integration tests -subdir('const') subdir('meshIO') subdir('probe') subdir('config')