Commit 3b3900fa authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

moved GetOverlap, added stream for TestParam and refactoring

parent ba85a102
Pipeline #131613 failed with stages
in 9 minutes and 22 seconds
......@@ -5,27 +5,40 @@
#include "TestEnvironment.hpp"
constexpr double PDESOLVER_TEST_TOLERANCE = 1e-4;
constexpr double PDESOLVER_TEST_TOLERANCE = 1e-3;
struct TestParams {
std::string model;
std::string problem;
std::string quantity;
double Q;
std::string GetOverlap() const {
if (model.find("DG") != -1) return "dG1";
else return "NoOverlap";
}
};
std::ostream &operator<<(std::ostream &s, const TestParams &testParams) {
return s << "{Model: " << testParams.model
<< ", Problem: " << testParams.problem
<< ", Quantity: " << testParams.quantity << "}" << endl;
}
class TestPDESolver : public TestWithParam<TestParams> {
protected:
SampleID id;
Meshes *meshes;
PDESolver *pdeSolver;
SampleID id;
TestPDESolver(const std::string &meshName, int commSplit = 0) {
// Todo use googletest number as m!
id = SampleID(5, 0, false);
TestPDESolver(const std::string &meshName, int commSplit = 0) :
id(SampleID(3, 0, false)) {
meshes = MeshesCreator(meshName).
WithOverlap(GetOverlap()).
WithOverlap(GetParam().GetOverlap()).
WithCommSplit(commSplit).
WithDistribute("RCB").
WithPLevel(id.level.pLevel).
......@@ -39,15 +52,6 @@ protected:
Create(*meshes);
}
std::string GetOverlap() {
if (GetParam().model == "DGElliptic")
return "dG1";
else if (GetParam().model == "DGTransport")
return "dG1";
else
return "NoOverlap";
}
void TearDown() override {
delete pdeSolver;
delete meshes;
......@@ -56,7 +60,7 @@ protected:
class TestLaplace1D : public TestPDESolver {
public:
TestLaplace1D() : TestPDESolver("Interval_DirichletBC") {};
TestLaplace1D() : TestPDESolver("Interval") {};
};
INSTANTIATE_TEST_SUITE_P(TestPDESolver, TestLaplace1D, Values(
......@@ -93,7 +97,7 @@ TEST_P(TestLaplace1D, TestRun) {
class TestLaplace2D : public TestPDESolver {
public:
TestLaplace2D() : TestPDESolver("Square_DirichletBC") {};
TestLaplace2D() : TestPDESolver("Square") {};
};
INSTANTIATE_TEST_SUITE_P(TestPDESolver, TestLaplace2D, Values(
......@@ -128,16 +132,31 @@ TEST_P(TestLaplace2D, TestRun) {
EXPECT_NEAR(solution.Q, GetParam().Q, PDESOLVER_TEST_TOLERANCE);
}
class TestGaussHat : public TestPDESolver {
//class TestTransport1D : public TestPDESolver {
//public:
// TestTransport1D() : TestPDESolver("Interval") {};
//};
//
//INSTANTIATE_TEST_SUITE_P(TestPDESolver, TestTransport1D, Values(
// TestParams{"DGTransport", "Pollution1D", "Mass", 1.0}
//));
//
//TEST_P(TestTransport1D, TestRun) {
// SampleSolution solution(pdeSolver->MGraphs(), id);
// pdeSolver->Run(solution);
// EXPECT_NEAR(solution.Q, GetParam().Q, PDESOLVER_TEST_TOLERANCE);
//}
class TestTransport2D : public TestPDESolver {
public:
TestGaussHat() : TestPDESolver("Square_DirichletBC") {};
TestTransport2D() : TestPDESolver("Square") {};
};
INSTANTIATE_TEST_SUITE_P(TestPDESolver, TestGaussHat, Values(
INSTANTIATE_TEST_SUITE_P(TestPDESolver, TestTransport2D, Values(
TestParams{"DGTransport", "GaussHat2D", "Mass", 1.0}
));
TEST_P(TestGaussHat, TestRun) {
TEST_P(TestTransport2D, TestRun) {
SampleSolution solution(pdeSolver->MGraphs(), id);
pdeSolver->Run(solution);
EXPECT_NEAR(solution.Q, GetParam().Q, PDESOLVER_TEST_TOLERANCE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment