Commit 8a010958 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

fixed tests

parent eb1df5f3
......@@ -14,37 +14,28 @@
* Test of Estimators against each other
*/
INSTANTIATE_TEST_SUITE_P(TestMonteCarlo, TestMonteCarloSeriellInterval, Values(
TestStruct{"StochasticDummyScalarGeneratorProblem", "GeneratorValue", "DummyPDESolver",
INSTANTIATE_TEST_SUITE_P(TestMonteCarlo, TestMonteCarlo, Values(
TestParams{"StochasticDummyScalarGeneratorProblem", "GeneratorValue", "DummyPDESolver",
0.0, 0.0, 1.0, 1.0},
TestStruct{"StochasticLaplace2DTest", "L2", "LagrangeElliptic",
0.0, 0.0, 1.0, 1.0}
TestParams{"StochasticLaplace2DTest", "L2", "LagrangeElliptic",
0.579087, 0.579087, 2.694804e-05, 2.694804e-05},
TestParams{"StochasticLaplace2DTest", "Outflow", "HybridElliptic",
1.0, 1.0, 2.694804e-05, 2.694804e-05}
));
INSTANTIATE_TEST_SUITE_P(TestMonteCarlo, TestMonteCarloParallelInterval, Values(
TestStruct{"StochasticDummyScalarGeneratorProblem", "GeneratorValue", "DummyPDESolver",
0.0, 0.0, 1.0, 1.0}
));
TEST_P(TestMonteCarloSeriellInterval, TestMethodOnlyFine) {
EXPECT_NEAR(mc.aggregate.mean.Q, GetParam().MeanQ, sqrt(1.0 / dM));
EXPECT_NEAR(mc.aggregate.mean.Y, GetParam().MeanY, sqrt(1.0 / dM));
EXPECT_NEAR(mc.aggregate.sVar.Q, GetParam().SVarQ, sqrt(10.0 / dM));
EXPECT_NEAR(mc.aggregate.sVar.Y, GetParam().SVarY, sqrt(10.0 / dM));
}
TEST_P(TestMonteCarloParallelInterval, TestMethodOnlyFine) {
EXPECT_NEAR(mc.aggregate.mean.Q, GetParam().MeanQ, sqrt(1.0 / dM));
EXPECT_NEAR(mc.aggregate.mean.Y, GetParam().MeanY, sqrt(1.0 / dM));
EXPECT_NEAR(mc.aggregate.sVar.Q, GetParam().SVarQ, sqrt(10.0 / dM));
EXPECT_NEAR(mc.aggregate.sVar.Y, GetParam().SVarY, sqrt(10.0 / dM));
TEST_P(TestMonteCarlo, TestMethodOnlyFine) {
EXPECT_NEAR(mcParallel.aggregate.mean.Q, mcSeriell.aggregate.mean.Q, sqrt(1.0 / dM));
EXPECT_NEAR(mcParallel.aggregate.mean.Y, mcSeriell.aggregate.mean.Y, sqrt(1.0 / dM));
EXPECT_NEAR(mcParallel.aggregate.sVar.Q, mcSeriell.aggregate.sVar.Q, sqrt(10.0 / dM));
EXPECT_NEAR(mcParallel.aggregate.sVar.Y, mcSeriell.aggregate.sVar.Y, sqrt(10.0 / dM));
}
int main(int argc, char **argv) {
return MppTest(
MppTestBuilder(argc, argv).
WithConfigEntry("PDESolverVerbose", 2).
WithConfigEntry("PDESolverVerbose", 0).
WithConfigEntry("NewtonVerbose", 0).
WithConfigEntry("LinearVerbose", 0).
WithParallelListeners().
WithScreenLogging().
WithPPM()
......
......@@ -7,39 +7,39 @@
#include "MeshesCreator.hpp"
#include "TestEnvironment.hpp"
struct TestStruct {
std::string problemName;
std::string quantity ;
struct TestParams {
std::string problemName;
std::string model;
std::string quantity;
double MeanQ;
double MeanY;
double SVarQ;
double SVarY;
std::string model;
};
std::ostream &operator<<(std::ostream &s, const TestParams &testParams) {
return s << "Problem Name: " << testParams.problemName << ", "
<< "Quantity: " << testParams.quantity << ", "
<< "Model: " << testParams.model << ", "
<< endl;
}
class TestMonteCarlo : public TestWithParam<TestStruct> {
class TestMonteCarlo : public TestWithParam<TestParams> {
protected:
bool onlyFine = true;
int level = 3;
int dM = 1e3;
int dM = 1e4;
PDESolverCreator pdeSolverCreator;
MeshesCreator meshesCreator;
MonteCarlo mc;
MonteCarlo mcSeriell;
MonteCarlo mcParallel;
TestMonteCarlo(const std::string &meshName, bool parallel) :
TestMonteCarlo() :
pdeSolverCreator(PDESolverCreator().
WithProblem(GetParam().problemName).
WithQuantity(GetParam().quantity).
......@@ -47,40 +47,23 @@ protected:
meshesCreator(MeshesCreator(pdeSolverCreator.GetMeshName()).
WithDistribute("RCB").
WithoutOverlap()),
mc(MonteCarlo(level, dM, onlyFine, parallel,
meshesCreator, pdeSolverCreator)) {
mc.Method();
mcSeriell(MonteCarlo(level, dM, onlyFine, false, meshesCreator, pdeSolverCreator)),
mcParallel(MonteCarlo(level, dM, onlyFine, true, meshesCreator, pdeSolverCreator)) {
mout.StartBlock("Monte Carlo seriell");
mout << "Start" << endl;
mcSeriell.Method();
mout.EndBlock();
mout << endl;
mout.StartBlock("Monte Carlo parallel");
mout << "Start" << endl;
mcParallel.Method();
mout.EndBlock();
mout << endl;
}
void TearDown() {
PPM->Barrier(0);
}
};
class TestMonteCarloSeriell : public TestMonteCarlo {
protected:
TestMonteCarloSeriell(const std::string &meshName) :
TestMonteCarlo(meshName, false) {}
};
class TestMonteCarloParallel : public TestMonteCarlo {
protected:
TestMonteCarloParallel(const std::string &meshName) :
TestMonteCarlo(meshName, true) {}
};
class TestMonteCarloSeriellInterval : public TestMonteCarloSeriell {
protected:
TestMonteCarloSeriellInterval() :
TestMonteCarloSeriell("Interval") {}
};
class TestMonteCarloParallelInterval : public TestMonteCarloParallel {
protected:
TestMonteCarloParallelInterval() :
TestMonteCarloParallel("Interval") {}
void TearDown() { PPM->Barrier(0); }
};
#endif //TESTMONTECARLO_HPP
Supports Markdown
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