Commit dae0941d authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

adapted tests

parent befe2734
Pipeline #147710 passed with stages
in 48 minutes and 19 seconds
#include "TestMonteCarlo.hpp"
class TestMonteCarlo : public TestWithParam<std::string> {
protected:
int pLevel = 2;
int level = 3;
int dM = 1e6;
MeshesCreator meshesCreator;
PDESolverCreator pdeSolverCreator;
MonteCarlo mc;
TestMonteCarlo(const std::string &meshName, int commSplit = 0) :
meshesCreator(MeshesCreator("Interval").
WithCommSplit(commSplit).
WithDistribute("RCB").
WithoutOverlap().
WithPLevel(pLevel).
WithLevel(level)),
pdeSolverCreator(PDESolverCreator().
WithProblem(GetParam()).
WithQuantity("GeneratorValue").
WithModel("DummyPDESolver")),
mc(MonteCarlo(level, dM, true, meshesCreator, pdeSolverCreator)) {
mc.Method();
}
void TearDown() {
PPM->Barrier(0);
PPM->ClearCommunicators(false);
}
};
class TestMonteCarloInterval : public TestMonteCarlo {
protected:
TestMonteCarloInterval(int commSplit = 0) :
TestMonteCarlo("Interval", commSplit) {}
};
INSTANTIATE_TEST_SUITE_P(TestMonteCarlo, TestMonteCarloSeriellInterval, Values(
"StochasticDummyScalarGeneratorProblem"
));
INSTANTIATE_TEST_SUITE_P(TestMonteCarlo, TestMonteCarloInterval, Values(
"StochasticDummyScalarGeneratorProblem"
INSTANTIATE_TEST_SUITE_P(TestMonteCarlo, TestMonteCarloParallelInterval, Values(
"StochasticDummyScalarGeneratorProblem"
));
TEST_P(TestMonteCarloInterval, TestMethodOnlyFine) {
// EXPECT_NEAR(mc.avgs.Q, 0.0, sqrt(1.0 / dM));
// EXPECT_NEAR(mc.avgs.Y, 0.0, sqrt(1.0 / dM));
// EXPECT_NEAR(mc.vars.Q, 1.0, sqrt(10.0 / dM));
// EXPECT_NEAR(mc.vars.Y, 1.0, sqrt(10.0 / dM));
TEST_P(TestMonteCarloSeriellInterval, TestMethodOnlyFine) {
EXPECT_NEAR(mc.aggregate.MeanQ, 0.0, sqrt(1.0 / dM));
EXPECT_NEAR(mc.aggregate.MeanY, 0.0, sqrt(1.0 / dM));
EXPECT_NEAR(mc.aggregate.SVarQ, 1.0, sqrt(10.0 / dM));
EXPECT_NEAR(mc.aggregate.SVarY, 1.0, sqrt(10.0 / dM));
}
TEST_P(TestMonteCarloParallelInterval, TestMethodOnlyFine) {
EXPECT_NEAR(mc.aggregate.MeanQ, 0.0, sqrt(1.0 / dM));
EXPECT_NEAR(mc.aggregate.MeanY, 0.0, sqrt(1.0 / dM));
EXPECT_NEAR(mc.aggregate.SVarQ, 1.0, sqrt(10.0 / dM));
EXPECT_NEAR(mc.aggregate.SVarY, 1.0, sqrt(10.0 / dM));
}
int main(int argc, char **argv) {
return MppTest(
MppTestBuilder(argc, argv).
WithParallelListeners().
WithScreenLogging().
WithPPM()
).RUN_ALL_MPP_TESTS();
return MppTest(
MppTestBuilder(argc, argv).
WithParallelListeners().
WithScreenLogging().
WithPPM()
).RUN_ALL_MPP_TESTS();
}
\ No newline at end of file
......@@ -5,10 +5,68 @@
#include "pdesolver/PDESolverCreator.hpp"
#include "mesh/MeshesCreator.hpp"
#include "TestEnvironment.hpp"
class TestMonteCarlo : public TestWithParam<std::string> {
protected:
int pLevel = 2;
int level = 3;
int dM = 1e6;
MeshesCreator meshesCreator;
PDESolverCreator pdeSolverCreator;
MonteCarlo mc;
TestMonteCarlo(const std::string &meshName, bool parallel, int commSplit = 0) :
meshesCreator(MeshesCreator("Interval").
WithCommSplit(commSplit).
WithDistribute("RCB").
WithoutOverlap().
WithPLevel(pLevel).
WithLevel(level)),
pdeSolverCreator(PDESolverCreator().
WithProblem(GetParam()).
WithQuantity("GeneratorValue").
WithModel("DummyPDESolver")),
mc(MonteCarlo(level, dM, true, parallel, meshesCreator, pdeSolverCreator)) {
mc.Method();
}
void TearDown() {
PPM->Barrier(0);
PPM->ClearCommunicators(false);
}
};
class TestMonteCarloSeriell : public TestMonteCarlo {
protected:
TestMonteCarloSeriell(const std::string &meshName, int commSplit = 0) :
TestMonteCarlo(meshName, false, commSplit) {}
};
class TestMonteCarloParallel : public TestMonteCarlo {
protected:
TestMonteCarloParallel(const std::string &meshName, int commSplit = 0) :
TestMonteCarlo(meshName, true, commSplit) {}
};
class TestMonteCarloSeriellInterval : public TestMonteCarloSeriell {
protected:
TestMonteCarloSeriellInterval(int commSplit = 0) :
TestMonteCarloSeriell("Interval", commSplit) {}
};
class TestMonteCarloParallelInterval : public TestMonteCarloParallel {
protected:
TestMonteCarloParallelInterval(int commSplit = 0) :
TestMonteCarloParallel("Interval", commSplit) {}
};
#endif //TESTMONTECARLO_HPP
......@@ -7,10 +7,10 @@
struct TestData {
MonteCarloMap _mcMap = {
{3, MonteCarlo(3, 0, true)},
{4, MonteCarlo(4, 0, true)},
{5, MonteCarlo(5, 0, true)},
{6, MonteCarlo(6, 0, true)}
{3, MonteCarlo(3, 0, true, true)},
{4, MonteCarlo(4, 0, true, true)},
{5, MonteCarlo(5, 0, true, true)},
{6, MonteCarlo(6, 0, true, true)}
};
SampleCounterMap _ctrs = {
......
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