Skip to content

Commit 98f4431

Browse files
committed
tests: Add SerialMLSDC test.
Signed-off-by: Matthew Emmett <[email protected]>
1 parent 5d7929c commit 98f4431

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

examples/advection_diffusion/serial_mlsdc.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using namespace pfasst;
1919
using namespace pfasst::encap;
2020

21-
int main(int argc, char** argv)
21+
error_map run_serial_mlsdc()
2222
{
2323
MLSDC<> mlsdc;
2424

@@ -74,4 +74,13 @@ int main(int argc, char** argv)
7474
mlsdc.run();
7575

7676
fftw_cleanup();
77+
78+
return sweeper->get_errors();
79+
}
80+
81+
#ifndef PFASST_UNIT_TESTING
82+
int main(int argc, char** argv)
83+
{
84+
run_serial_mlsdc();
7785
}
86+
#endif

tests/test-advection-diffusion.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#define PFASST_UNIT_TESTING
1414
#include "../examples/advection_diffusion/vanilla_sdc.cpp"
15+
#include "../examples/advection_diffusion/serial_mlsdc.cpp"
1516
#undef PFASST_UNIT_TESTING
1617

1718
using namespace std;
@@ -29,7 +30,7 @@ MATCHER(DoubleLess, "")
2930

3031
TEST(ErrorTest, VanillaSDC)
3132
{
32-
typedef pair<pair<size_t, size_t>, double> vtype;
33+
typedef error_map::value_type vtype;
3334

3435
auto errors = run_vanilla_sdc();
3536
auto get_iter = [](const vtype x) { return get<1>(get<0>(x)); };
@@ -50,6 +51,29 @@ TEST(ErrorTest, VanillaSDC)
5051
EXPECT_THAT(err, testing::Pointwise(DoubleLess(), tol));
5152
}
5253

54+
TEST(ErrorTest, SerialMLSDC)
55+
{
56+
typedef error_map::value_type vtype;
57+
58+
auto errors = run_serial_mlsdc();
59+
auto get_iter = [](const vtype x) { return get<1>(get<0>(x)); };
60+
auto get_step = [](const vtype x) { return get<0>(get<0>(x)); };
61+
auto get_error = [](const vtype x) { return get<1>(x); };
62+
63+
auto max_iter = get_iter(*std::max_element(errors.begin(), errors.end(),
64+
[get_iter](const vtype p1, const vtype p2) { return get_iter(p1) < get_iter(p2); }));
65+
66+
vector<double> tol = { 8e-11, 8e-11, 8e-11, 8e-11 };
67+
vector<double> err;
68+
for (auto& x: errors) {
69+
if (get_iter(x) == max_iter) {
70+
err.push_back(get_error(x));
71+
}
72+
}
73+
74+
EXPECT_THAT(err, testing::Pointwise(DoubleLess(), tol));
75+
}
76+
5377
int main(int argc, char** argv)
5478
{
5579
testing::InitGoogleTest(&argc, argv);

0 commit comments

Comments
 (0)