Files
SERiF/tests/poly/polyTest.cpp
Emily Boudreaux 8dcdf92414 feat(poly): interpolating polynomial to find polytrope surface
Instead of treating the polytrope as a free boundary problem I have defined an interpolating polynominal, accurate to within 0.01 percent over n=[0,5) which is used to set the size of the domain for a given n
2025-03-18 10:15:51 -04:00

42 lines
1.5 KiB
C++

#include <gtest/gtest.h>
#include <iostream>
#include "quill/LogMacros.h"
#include "mfem.hpp"
#include "polySolver.h"
#include "polyCoeff.h"
#include "probe.h"
#include "config.h"
#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 {};
TEST_F(polyTest, Solve) {
Config& config = Config::getInstance();
config.loadConfig(CONFIG_FILENAME);
Probe::LogManager& logManager = Probe::LogManager::getInstance();
quill::Logger* logger = logManager.getLogger("log");
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();
double radius = Probe::getMeshRadius(mesh);
LOG_INFO(logger, "Mesh radius: {:0.4f} (target={:0.4f})", radius, polyRadius);
PolySolver polytrope(polytropicIndex, 1, mesh);
LOG_INFO(logger, "Solving polytrope...");
EXPECT_NO_THROW(polytrope.solve());
LOG_INFO(logger, "Polytrope solved.");
}