Merge pull request #59 from tboudreaux/feature/mixedPolytrope
Static 3D FEM Polytropic Model
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Copyright (C) 2025 -- The 4D-STAR Collaboration
|
||||
// File Author: Emily Boudreaux
|
||||
// Last Modified: February 21, 2025
|
||||
// Last Modified: March 20, 2025
|
||||
//
|
||||
// 4DSSE is free software; you can use it and/or modify
|
||||
// it under the terms and restrictions the GNU General Library Public
|
||||
@@ -29,6 +29,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
namespace serif {
|
||||
namespace config {
|
||||
|
||||
Config::Config() {}
|
||||
|
||||
Config::~Config() {}
|
||||
@@ -102,4 +105,7 @@ std::vector<std::string> Config::keys() const {
|
||||
YAML::Node node = YAML::Clone(yamlRoot);
|
||||
recurse_keys(node, keyList);
|
||||
return keyList;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace config
|
||||
} // namespace serif
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Copyright (C) 2025 -- The 4D-STAR Collaboration
|
||||
// File Author: Emily Boudreaux
|
||||
// Last Modified: February 20, 2025
|
||||
// Last Modified: March 26, 2025
|
||||
//
|
||||
// 4DSSE is free software; you can use it and/or modify
|
||||
// it under the terms and restrictions the GNU General Library Public
|
||||
@@ -32,7 +32,11 @@
|
||||
#include "yaml-cpp/yaml.h"
|
||||
|
||||
// -- Forward Def of Resource manager to let it act as a friend of Config --
|
||||
class ResourceManager;
|
||||
namespace serif { namespace resource { class ResourceManager; } } // Forward declaration
|
||||
class configTestPrivateAccessor; // Forward declaration for test utility
|
||||
|
||||
namespace serif {
|
||||
namespace config {
|
||||
|
||||
/**
|
||||
* @class Config
|
||||
@@ -53,6 +57,7 @@ private:
|
||||
YAML::Node yamlRoot; ///< Root node of the YAML configuration.
|
||||
std::string configFilePath; ///< Path to the configuration file.
|
||||
bool debug = false; ///< Flag to enable debug output.
|
||||
bool loaded = false; ///< Flag to indicate if the configuration has been loaded.
|
||||
|
||||
std::map<std::string, YAML::Node> configMap; ///< Cache for the location of configuration settings.
|
||||
std::vector<std::string> unknownKeys; ///< Cache for the existence of configuration settings.
|
||||
@@ -133,6 +138,12 @@ public:
|
||||
*/
|
||||
bool loadConfig(const std::string& configFilePath);
|
||||
|
||||
/**
|
||||
* @brief Get the input table from the configuration.
|
||||
* @return Input table as a string.
|
||||
*/
|
||||
std::string getInputTable() const;
|
||||
|
||||
/**
|
||||
* @brief Get a configuration value by key.
|
||||
* @tparam T Type of the value to retrieve.
|
||||
@@ -226,7 +237,10 @@ public:
|
||||
}
|
||||
|
||||
// Setup gTest class as a friend
|
||||
friend class configTestPrivateAccessor;
|
||||
// --- Resource Manager is a friend of config so it can create a separate instance
|
||||
friend class ResourceManager;
|
||||
friend class ::configTestPrivateAccessor; // Friend declaration for global test accessor
|
||||
// -- Resource Manager is a friend of config so it can create a seperate instance
|
||||
friend class serif::resource::ResourceManager; // Adjusted friend declaration
|
||||
};
|
||||
|
||||
} // namespace config
|
||||
} // namespace serif
|
||||
|
||||
@@ -15,23 +15,23 @@ std::string EXAMPLE_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/test
|
||||
|
||||
class configTestPrivateAccessor {
|
||||
public:
|
||||
static bool callIsKeyInCache(Config& config, const std::string& key) {
|
||||
static bool callIsKeyInCache(serif::config::Config& config, const std::string& key) {
|
||||
return config.isKeyInCache(key);
|
||||
}
|
||||
|
||||
static int callCacheSize(Config& config) {
|
||||
static int callCacheSize(serif::config::Config& config) {
|
||||
return config.configMap.size();
|
||||
}
|
||||
|
||||
static void callAddToCache(Config& config, const std::string& key, const YAML::Node& node) {
|
||||
static void callAddToCache(serif::config::Config& config, const std::string& key, const YAML::Node& node) {
|
||||
config.addToCache(key, node);
|
||||
}
|
||||
|
||||
static void callRegisterKeyNotFound(Config& config, const std::string& key) {
|
||||
static void callRegisterKeyNotFound(serif::config::Config& config, const std::string& key) {
|
||||
config.registerUnknownKey(key);
|
||||
}
|
||||
|
||||
static bool CheckIfKeyUnknown(Config& config, const std::string& key) {
|
||||
static bool CheckIfKeyUnknown(serif::config::Config& config, const std::string& key) {
|
||||
if (std::find(config.unknownKeys.begin(), config.unknownKeys.end(), key) == config.unknownKeys.end()) {
|
||||
return false;
|
||||
}
|
||||
@@ -48,22 +48,22 @@ class configTest : public ::testing::Test {};
|
||||
* @brief Test the constructor of the Config class.
|
||||
*/
|
||||
TEST_F(configTest, constructor) {
|
||||
EXPECT_NO_THROW(Config::getInstance());
|
||||
EXPECT_NO_THROW(serif::config::Config::getInstance());
|
||||
}
|
||||
|
||||
TEST_F(configTest, loadConfig) {
|
||||
Config& config = Config::getInstance();
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
EXPECT_TRUE(config.loadConfig(EXAMPLE_FILENAME));
|
||||
}
|
||||
|
||||
TEST_F(configTest, singletonTest) {
|
||||
Config& config1 = Config::getInstance();
|
||||
Config& config2 = Config::getInstance();
|
||||
serif::config::Config& config1 = serif::config::Config::getInstance();
|
||||
serif::config::Config& config2 = serif::config::Config::getInstance();
|
||||
EXPECT_EQ(&config1, &config2);
|
||||
}
|
||||
|
||||
TEST_F(configTest, getTest) {
|
||||
Config& config = Config::getInstance();
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(EXAMPLE_FILENAME);
|
||||
int maxIter = config.get<int>("opac:lowTemp:numeric:maxIter", 10);
|
||||
EXPECT_EQ(maxIter, 100);
|
||||
@@ -82,19 +82,19 @@ TEST_F(configTest, getTest) {
|
||||
}
|
||||
|
||||
TEST_F(configTest, secondSingletonTest) {
|
||||
Config& config = Config::getInstance();
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
EXPECT_EQ(config.get<int>("opac:lowTemp:numeric:maxIter", 10), 100);
|
||||
}
|
||||
|
||||
TEST_F(configTest, isKeyInCacheTest) {
|
||||
Config& config = Config::getInstance();
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(EXAMPLE_FILENAME);
|
||||
EXPECT_TRUE(configTestPrivateAccessor::callIsKeyInCache(config, "opac:lowTemp:numeric:maxIter"));
|
||||
EXPECT_FALSE(configTestPrivateAccessor::callIsKeyInCache(config, "opac:lowTemp:numeric:maxIter2"));
|
||||
}
|
||||
|
||||
TEST_F(configTest, cacheSize) {
|
||||
Config& config = Config::getInstance();
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(EXAMPLE_FILENAME);
|
||||
EXPECT_EQ(configTestPrivateAccessor::callCacheSize(config), 3);
|
||||
EXPECT_NE(configTestPrivateAccessor::callCacheSize(config), 4);
|
||||
@@ -103,9 +103,9 @@ TEST_F(configTest, cacheSize) {
|
||||
}
|
||||
|
||||
TEST_F(configTest, unknownKeyTest) {
|
||||
Config& config = Config::getInstance();
|
||||
serif::config::Config& config = serif::config::Config::getInstance();
|
||||
config.loadConfig(EXAMPLE_FILENAME);
|
||||
config.get<int>("opac:lowTemp:numeric:random", 10);
|
||||
EXPECT_FALSE(configTestPrivateAccessor::CheckIfKeyUnknown(config, "opac:lowTemp:numeric:maxIter"));
|
||||
EXPECT_TRUE(configTestPrivateAccessor::CheckIfKeyUnknown(config, "opac:lowTemp:numeric:random"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user