Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mpp
MLUQ
Commits
6f3aebf3
Commit
6f3aebf3
authored
Aug 26, 2020
by
niklas.baumgarten
Browse files
Split MainProgram tests
parent
47ca83e3
Changes
5
Hide whitespace changes
Inline
Side-by-side
tests/CMakeLists.txt
View file @
6f3aebf3
...
@@ -6,13 +6,11 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/tests/log)
...
@@ -6,13 +6,11 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/tests/log)
file
(
MAKE_DIRECTORY
${
PROJECT_BINARY_DIR
}
/tests/data/dual
)
file
(
MAKE_DIRECTORY
${
PROJECT_BINARY_DIR
}
/tests/data/dual
)
# Test Executables
# Test Executables
add_executable
(
TestMainProgram TestMainProgram.cpp
)
add_executable
(
TestMainProgramElliptic TestMainProgramElliptic.cpp
)
add_executable
(
BenchmarkEllipticResults BenchmarkEllipticResults.cpp
)
add_executable
(
TestMainProgramTransport TestMainProgramTransport.cpp
)
add_executable
(
BenchmarkTransportResults BenchmarkTransportResults.cpp
)
add_executable
(
TestMultilevelPlotter TestMultilevelPlotter.cpp
)
add_executable
(
TestMultilevelPlotter TestMultilevelPlotter.cpp
)
# Linking
# Linking
target_link_libraries
(
TestMainProgram
${
MLMC_LIBRARIES
}
${
GTEST_LIB
}
)
target_link_libraries
(
TestMainProgramElliptic
${
MLMC_LIBRARIES
}
${
GTEST_LIB
}
)
target_link_libraries
(
BenchmarkEllipticResults
${
MLMC_LIBRARIES
}
${
GTEST_LIB
}
)
target_link_libraries
(
TestMainProgramTransport
${
MLMC_LIBRARIES
}
${
GTEST_LIB
}
)
target_link_libraries
(
BenchmarkTransportResults
${
MLMC_LIBRARIES
}
${
GTEST_LIB
}
)
target_link_libraries
(
TestMultilevelPlotter
${
MLMC_LIBRARIES
}
${
GTEST_LIB
}
)
target_link_libraries
(
TestMultilevelPlotter
${
MLMC_LIBRARIES
}
${
GTEST_LIB
}
)
tests/TestMainProgram.cpp
→
tests/TestMainProgram
Elliptic
.cpp
View file @
6f3aebf3
#include
"main/MainProgram.hpp"
#include
"main/MainProgram.hpp"
#include
"
ConfigMapsForTest
.hpp"
#include
"
TestMainProgramElliptic
.hpp"
#include
"TestEnvironment.hpp"
#include
"TestEnvironment.hpp"
...
@@ -42,13 +42,6 @@ INSTANTIATE_TEST_CASE_P(TestMainProgram, TestMainProgram, Values(
...
@@ -42,13 +42,6 @@ INSTANTIATE_TEST_CASE_P(TestMainProgram, TestMainProgram, Values(
ConfigMapsForTest
{
defaultEllipticConfigMap
,
ConfigMapsForTest
{
defaultEllipticConfigMap
,
ConfigMap
{{
"Problem"
,
"StochasticLaplace2D"
}}}
ConfigMap
{{
"Problem"
,
"StochasticLaplace2D"
}}}
// Tests with default transport config
// ConfigMapsForTest{defaultTransportConfigMap,
// ConfigMap{}},
// ConfigMapsForTest{defaultTransportConfigMap,
// ConfigMap{{"Problem", "StochasticPollution2D"}}}
));
));
TEST_P
(
TestMainProgram
,
TestRunMLMCExperiment
)
{
TEST_P
(
TestMainProgram
,
TestRunMLMCExperiment
)
{
...
...
tests/TestMainProgramElliptic.hpp
0 → 100644
View file @
6f3aebf3
#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
tests/TestMainProgramTransport.cpp
0 → 100644
View file @
6f3aebf3
#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
();
}
tests/
ConfigMapsForTes
t.hpp
→
tests/
TestMainProgramTranspor
t.hpp
View file @
6f3aebf3
...
@@ -5,60 +5,6 @@
...
@@ -5,60 +5,6 @@
#include
<string>
#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
=
{
const
std
::
map
<
std
::
string
,
std
::
string
>
defaultTransportConfigMap
=
{
// ----- Problem Settings -----
// ----- Problem Settings -----
{
"Experiment"
,
"MLMCExperiment"
},
{
"Experiment"
,
"MLMCExperiment"
},
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment