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
|
// Copyright (C) 2025 -- The 4D-STAR Collaboration
|
||||||
// File Author: Emily Boudreaux
|
// 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
|
// 4DSSE is free software; you can use it and/or modify
|
||||||
// it under the terms and restrictions the GNU General Library Public
|
// it under the terms and restrictions the GNU General Library Public
|
||||||
@@ -29,6 +29,9 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
namespace serif {
|
||||||
|
namespace config {
|
||||||
|
|
||||||
Config::Config() {}
|
Config::Config() {}
|
||||||
|
|
||||||
Config::~Config() {}
|
Config::~Config() {}
|
||||||
@@ -103,3 +106,6 @@ std::vector<std::string> Config::keys() const {
|
|||||||
recurse_keys(node, keyList);
|
recurse_keys(node, keyList);
|
||||||
return keyList;
|
return keyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace config
|
||||||
|
} // namespace serif
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2025 -- The 4D-STAR Collaboration
|
// Copyright (C) 2025 -- The 4D-STAR Collaboration
|
||||||
// File Author: Emily Boudreaux
|
// 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
|
// 4DSSE is free software; you can use it and/or modify
|
||||||
// it under the terms and restrictions the GNU General Library Public
|
// it under the terms and restrictions the GNU General Library Public
|
||||||
@@ -32,7 +32,11 @@
|
|||||||
#include "yaml-cpp/yaml.h"
|
#include "yaml-cpp/yaml.h"
|
||||||
|
|
||||||
// -- Forward Def of Resource manager to let it act as a friend of Config --
|
// -- 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
|
* @class Config
|
||||||
@@ -53,6 +57,7 @@ private:
|
|||||||
YAML::Node yamlRoot; ///< Root node of the YAML configuration.
|
YAML::Node yamlRoot; ///< Root node of the YAML configuration.
|
||||||
std::string configFilePath; ///< Path to the configuration file.
|
std::string configFilePath; ///< Path to the configuration file.
|
||||||
bool debug = false; ///< Flag to enable debug output.
|
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::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.
|
std::vector<std::string> unknownKeys; ///< Cache for the existence of configuration settings.
|
||||||
@@ -133,6 +138,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool loadConfig(const std::string& configFilePath);
|
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.
|
* @brief Get a configuration value by key.
|
||||||
* @tparam T Type of the value to retrieve.
|
* @tparam T Type of the value to retrieve.
|
||||||
@@ -226,7 +237,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup gTest class as a friend
|
// Setup gTest class as a friend
|
||||||
friend class configTestPrivateAccessor;
|
friend class ::configTestPrivateAccessor; // Friend declaration for global test accessor
|
||||||
// --- Resource Manager is a friend of config so it can create a separate instance
|
// -- Resource Manager is a friend of config so it can create a seperate instance
|
||||||
friend class ResourceManager;
|
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 {
|
class configTestPrivateAccessor {
|
||||||
public:
|
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);
|
return config.isKeyInCache(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int callCacheSize(Config& config) {
|
static int callCacheSize(serif::config::Config& config) {
|
||||||
return config.configMap.size();
|
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);
|
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);
|
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()) {
|
if (std::find(config.unknownKeys.begin(), config.unknownKeys.end(), key) == config.unknownKeys.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -48,22 +48,22 @@ class configTest : public ::testing::Test {};
|
|||||||
* @brief Test the constructor of the Config class.
|
* @brief Test the constructor of the Config class.
|
||||||
*/
|
*/
|
||||||
TEST_F(configTest, constructor) {
|
TEST_F(configTest, constructor) {
|
||||||
EXPECT_NO_THROW(Config::getInstance());
|
EXPECT_NO_THROW(serif::config::Config::getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(configTest, loadConfig) {
|
TEST_F(configTest, loadConfig) {
|
||||||
Config& config = Config::getInstance();
|
serif::config::Config& config = serif::config::Config::getInstance();
|
||||||
EXPECT_TRUE(config.loadConfig(EXAMPLE_FILENAME));
|
EXPECT_TRUE(config.loadConfig(EXAMPLE_FILENAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(configTest, singletonTest) {
|
TEST_F(configTest, singletonTest) {
|
||||||
Config& config1 = Config::getInstance();
|
serif::config::Config& config1 = serif::config::Config::getInstance();
|
||||||
Config& config2 = Config::getInstance();
|
serif::config::Config& config2 = serif::config::Config::getInstance();
|
||||||
EXPECT_EQ(&config1, &config2);
|
EXPECT_EQ(&config1, &config2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(configTest, getTest) {
|
TEST_F(configTest, getTest) {
|
||||||
Config& config = Config::getInstance();
|
serif::config::Config& config = serif::config::Config::getInstance();
|
||||||
config.loadConfig(EXAMPLE_FILENAME);
|
config.loadConfig(EXAMPLE_FILENAME);
|
||||||
int maxIter = config.get<int>("opac:lowTemp:numeric:maxIter", 10);
|
int maxIter = config.get<int>("opac:lowTemp:numeric:maxIter", 10);
|
||||||
EXPECT_EQ(maxIter, 100);
|
EXPECT_EQ(maxIter, 100);
|
||||||
@@ -82,19 +82,19 @@ TEST_F(configTest, getTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(configTest, secondSingletonTest) {
|
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);
|
EXPECT_EQ(config.get<int>("opac:lowTemp:numeric:maxIter", 10), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(configTest, isKeyInCacheTest) {
|
TEST_F(configTest, isKeyInCacheTest) {
|
||||||
Config& config = Config::getInstance();
|
serif::config::Config& config = serif::config::Config::getInstance();
|
||||||
config.loadConfig(EXAMPLE_FILENAME);
|
config.loadConfig(EXAMPLE_FILENAME);
|
||||||
EXPECT_TRUE(configTestPrivateAccessor::callIsKeyInCache(config, "opac:lowTemp:numeric:maxIter"));
|
EXPECT_TRUE(configTestPrivateAccessor::callIsKeyInCache(config, "opac:lowTemp:numeric:maxIter"));
|
||||||
EXPECT_FALSE(configTestPrivateAccessor::callIsKeyInCache(config, "opac:lowTemp:numeric:maxIter2"));
|
EXPECT_FALSE(configTestPrivateAccessor::callIsKeyInCache(config, "opac:lowTemp:numeric:maxIter2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(configTest, cacheSize) {
|
TEST_F(configTest, cacheSize) {
|
||||||
Config& config = Config::getInstance();
|
serif::config::Config& config = serif::config::Config::getInstance();
|
||||||
config.loadConfig(EXAMPLE_FILENAME);
|
config.loadConfig(EXAMPLE_FILENAME);
|
||||||
EXPECT_EQ(configTestPrivateAccessor::callCacheSize(config), 3);
|
EXPECT_EQ(configTestPrivateAccessor::callCacheSize(config), 3);
|
||||||
EXPECT_NE(configTestPrivateAccessor::callCacheSize(config), 4);
|
EXPECT_NE(configTestPrivateAccessor::callCacheSize(config), 4);
|
||||||
@@ -103,7 +103,7 @@ TEST_F(configTest, cacheSize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(configTest, unknownKeyTest) {
|
TEST_F(configTest, unknownKeyTest) {
|
||||||
Config& config = Config::getInstance();
|
serif::config::Config& config = serif::config::Config::getInstance();
|
||||||
config.loadConfig(EXAMPLE_FILENAME);
|
config.loadConfig(EXAMPLE_FILENAME);
|
||||||
config.get<int>("opac:lowTemp:numeric:random", 10);
|
config.get<int>("opac:lowTemp:numeric:random", 10);
|
||||||
EXPECT_FALSE(configTestPrivateAccessor::CheckIfKeyUnknown(config, "opac:lowTemp:numeric:maxIter"));
|
EXPECT_FALSE(configTestPrivateAccessor::CheckIfKeyUnknown(config, "opac:lowTemp:numeric:maxIter"));
|
||||||
|
|||||||
Reference in New Issue
Block a user