Commit 6f3aebf3 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

Split MainProgram tests

parent 47ca83e3
......@@ -6,13 +6,11 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/tests/log)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/tests/data/dual)
# Test Executables
add_executable(TestMainProgram TestMainProgram.cpp)
add_executable(BenchmarkEllipticResults BenchmarkEllipticResults.cpp)
add_executable(BenchmarkTransportResults BenchmarkTransportResults.cpp)
add_executable(TestMainProgramElliptic TestMainProgramElliptic.cpp)
add_executable(TestMainProgramTransport TestMainProgramTransport.cpp)
add_executable(TestMultilevelPlotter TestMultilevelPlotter.cpp)
# Linking
target_link_libraries(TestMainProgram ${MLMC_LIBRARIES} ${GTEST_LIB})
target_link_libraries(BenchmarkEllipticResults ${MLMC_LIBRARIES} ${GTEST_LIB})
target_link_libraries(BenchmarkTransportResults ${MLMC_LIBRARIES} ${GTEST_LIB})
target_link_libraries(TestMainProgramElliptic ${MLMC_LIBRARIES} ${GTEST_LIB})
target_link_libraries(TestMainProgramTransport ${MLMC_LIBRARIES} ${GTEST_LIB})
target_link_libraries(TestMultilevelPlotter ${MLMC_LIBRARIES} ${GTEST_LIB})
#include "main/MainProgram.hpp"
#include "ConfigMapsForTest.hpp"
#include "TestMainProgramElliptic.hpp"
#include "TestEnvironment.hpp"
......@@ -42,13 +42,6 @@ INSTANTIATE_TEST_CASE_P(TestMainProgram, TestMainProgram, Values(
ConfigMapsForTest{defaultEllipticConfigMap,
ConfigMap{{"Problem", "StochasticLaplace2D"}}}
// Tests with default transport config
// ConfigMapsForTest{defaultTransportConfigMap,
// ConfigMap{}},
// ConfigMapsForTest{defaultTransportConfigMap,
// ConfigMap{{"Problem", "StochasticPollution2D"}}}
));
TEST_P(TestMainProgram, TestRunMLMCExperiment) {
......
#ifndef TESTMAINPROGRAM_HPP
#define TESTMAINPROGRAM_HPP
#include <map>
#include <string>
const std::map<std::string, std::string> defaultEllipticConfigMap = {
// ----- Problem Settings -----
{"Experiment", "MLMCExperiment"},
{"Problem", "StochasticLaplace1D"},
{"Model", "LagrangeFEM"},
{"Functional", "L2"},
{"degree", "1"},
{"plevel", "2"},
// ----- Multilevel Monte Carlo -----
{"maxLevel", "7"},
{"epsilon", "0.01"},
{"mcOnly", "false"},
{"uniformSampleAmount", "100"},
{"initLevels", "[3, 4, 5]"},
{"initSampleAmount", "[12, 6, 3]"},
// ----- Stochastic Field -----
{"StochasticField", "LogNormal"},
{"mean", "0.0"},
{"sigma", "1.0"},
{"norm_p", "2"},
{"lambda", "[0.15, 0.15]"},
{"smoothing", "1.8"},
{"evtol", "1e-10"},
// ----- Solver -----
{"LinearReduction", "1e-12"},
{"LinearEpsilon", "1e-10"},
{"LinearSteps", "3000"},
{"NewtonSteps", "1"},
{"NewtonLineSearchSteps", "0"},
// ----- Plotting -----
{"GeneratorPlotting", "0"},
{"MCPlotting", "0"},
// ----- Verbose ----- //
{"MCVerbose", "1"},
{"PDEVerbose", "0"},
{"MLMCVerbose", "1"},
{"MainVerbose", "1"},
{"MeshVerbose", "0"},
{"ConfigVerbose", "0"},
{"LinearVerbose", "-1"},
{"NewtonVerbose", "-1"},
{"GeneratorVerbose", "0"},
// ----- Logging -----
{"TimeLevel", "-1"},
{"MuteLevel", "-1"},
{"DebugLevel", "-1"},
};
#endif //TESTMAINPROGRAM_HPP
#include "main/MainProgram.hpp"
#include "TestMainProgramTransport.hpp"
#include "TestEnvironment.hpp"
using ConfigMap = std::map<std::string, std::string>;
struct ConfigMapsForTest {
ConfigMap defaultMap;
ConfigMap additionalConfigMap;
};
class TestMainProgram : public TestWithParam<ConfigMapsForTest> {
protected:
std::unique_ptr<MainProgram> mainProgram;
void SetUp() override {
std::map<std::string, std::string> finalMap =
GetParam().defaultMap;
std::map<std::string, std::string> additionalMap =
GetParam().additionalConfigMap;
for (auto &pair: additionalMap)
finalMap[pair.first] = pair.second;
Config::initialize(finalMap);
mainProgram = std::make_unique<MainProgram>();
mainProgram->Initialize();
}
void TearDown() override {
Config::close();
}
};
INSTANTIATE_TEST_CASE_P(TestMainProgram, TestMainProgram, Values(
ConfigMapsForTest{defaultTransportConfigMap,
ConfigMap{}},
ConfigMapsForTest{defaultTransportConfigMap,
ConfigMap{{"Problem", "StochasticPollution2D"}}}
));
TEST_P(TestMainProgram, TestRunMLMCExperiment) {
ASSERT_EQ(mainProgram->Run(), 0);
ASSERT_TRUE(mainProgram->mlmc->totalErr < mainProgram->epsilon);
}
int main(int argc, char **argv) {
MppTest mppTest = MppTestBuilder(argc, argv).WithPPM().WithoutDefaultConfig().
WithScreenLogging().WithSearchPath("../../mlmc/");
return mppTest.RUN_ALL_MPP_TESTS();
}
......@@ -5,60 +5,6 @@
#include <string>
const std::map<std::string, std::string> defaultEllipticConfigMap = {
// ----- Problem Settings -----
{"Experiment", "MLMCExperiment"},
{"Problem", "StochasticLaplace1D"},
{"Model", "LagrangeFEM"},
{"Functional", "L2"},
{"degree", "1"},
{"plevel", "2"},
// ----- Multilevel Monte Carlo -----
{"maxLevel", "7"},
{"epsilon", "0.01"},
{"mcOnly", "false"},
{"uniformSampleAmount", "100"},
{"initLevels", "[3, 4, 5]"},
{"initSampleAmount", "[12, 6, 3]"},
// ----- Stochastic Field -----
{"StochasticField", "LogNormal"},
{"mean", "0.0"},
{"sigma", "1.0"},
{"norm_p", "2"},
{"lambda", "[0.15, 0.15]"},
{"smoothing", "1.8"},
{"evtol", "1e-10"},
// ----- Solver -----
{"LinearReduction", "1e-12"},
{"LinearEpsilon", "1e-10"},
{"LinearSteps", "3000"},
{"NewtonSteps", "1"},
{"NewtonLineSearchSteps", "0"},
// ----- Plotting -----
{"GeneratorPlotting", "0"},
{"MCPlotting", "0"},
// ----- Verbose ----- //
{"MCVerbose", "1"},
{"PDEVerbose", "0"},
{"MLMCVerbose", "1"},
{"MainVerbose", "1"},
{"MeshVerbose", "0"},
{"ConfigVerbose", "0"},
{"LinearVerbose", "-1"},
{"NewtonVerbose", "-1"},
{"GeneratorVerbose", "0"},
// ----- Logging -----
{"TimeLevel", "-1"},
{"MuteLevel", "-1"},
{"DebugLevel", "-1"},
};
const std::map<std::string, std::string> defaultTransportConfigMap = {
// ----- Problem Settings -----
{"Experiment", "MLMCExperiment"},
......
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