feat(tests/poly): updated polytrope tests to use resource manager

This commit is contained in:
2025-03-26 12:36:18 -04:00
parent e8d2061809
commit 3fbfb366d2
2 changed files with 11 additions and 6 deletions

View File

@@ -11,7 +11,7 @@ foreach test_file : test_sources
test_exe = executable(
exe_name,
test_file,
dependencies: [gtest_dep, polysolver_dep, probe_dep, quill_dep, config_dep, gtest_main],
dependencies: [gtest_dep, polysolver_dep, probe_dep, quill_dep, config_dep, gtest_main, resourceManager_dep],
install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly
)

View File

@@ -24,6 +24,8 @@
#include "quill/LogMacros.h"
#include "mfem.hpp"
#include "resourceManager.h"
#include "resourceManagerTypes.h"
#include "polySolver.h"
#include "polyCoeff.h"
@@ -32,7 +34,7 @@
#include "meshIO.h"
std::string CONFIG_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/testsConfig.yaml";
std::string SPHERICAL_MESH = std::string(getenv("MESON_SOURCE_ROOT")) + "/src/resources/mesh/core.msh";
class polyTest : public ::testing::Test {};
@@ -41,16 +43,19 @@ TEST_F(polyTest, Solve) {
config.loadConfig(CONFIG_FILENAME);
Probe::LogManager& logManager = Probe::LogManager::getInstance();
quill::Logger* logger = logManager.getLogger("log");
ResourceManager& rm = ResourceManager::getInstance();
const Resource& resource = rm.getResource("mesh:polySphere");
const auto &meshIO = std::get<std::unique_ptr<MeshIO>>(resource);
LOG_INFO(logger, "Starting polytrope solve test 1...");
config.loadConfig(CONFIG_FILENAME);
double polytropicIndex = config.get<double>("Tests:Poly:Index", 1);
double polyRadius = polycoeff::x1(polytropicIndex);
std::cout << "Polytropic index: " << polytropicIndex << std::endl;
std::cout << "Polytropic radius: " << polyRadius << std::endl;
LOG_INFO(logger, "Solving polytrope with n = {:0.2f}", polytropicIndex);
MeshIO meshIO(SPHERICAL_MESH, polyRadius);
mfem::Mesh& mesh = meshIO.GetMesh();
meshIO->LinearRescale(polyRadius);
mfem::Mesh& mesh = meshIO->GetMesh();
double radius = Probe::getMeshRadius(mesh);
LOG_INFO(logger, "Mesh radius: {:0.4f} (target={:0.4f})", radius, polyRadius);