11 #include <gtest/gtest.h>
12 #include <gmock/gmock.h>
13 using namespace ::testing;
17 #define PFASST_UNIT_TESTING
18 #include "../examples/advection_diffusion/mpi_pfasst.cpp"
19 #undef PFASST_UNIT_TESTING
25 typedef error_map::value_type
vtype;
28 auto get_step = [](
const vtype x) {
return get<0>(get<0>(x)); };
29 auto get_iter = [](
const vtype x) {
return get<1>(get<0>(x)); };
30 auto get_error = [](
const vtype x) {
return get<1>(x); };
32 auto max_iter = get_iter(*std::max_element(errors.begin(), errors.end(),
33 [get_iter](
const vtype p1,
const vtype p2) {
return get_iter(p1) < get_iter(p2); }));
35 vector<double> ub = { 1.e-12, 1.e-12, 2.5e-12, 5.e-12 };
36 for (
auto& x: errors) {
37 if (get_iter(x) == max_iter) {
38 EXPECT_LE(get_error(x), ub[get_step(x)]);
43 TEST(AdaptiveErrorTest, MPIPFASST)
45 typedef error_map::value_type
vtype;
47 auto errors =
run_mpi_pfasst(1.e-8, 0.0, 12, 4, 0.01, 128, 64, 5, 3);
48 auto get_step = [](
const vtype x) {
return get<0>(get<0>(x)); };
49 auto get_iter = [](
const vtype x) {
return get<1>(get<0>(x)); };
50 auto get_error = [](
const vtype x) {
return get<1>(x); };
52 auto max_iter = get_iter(*std::max_element(errors.begin(), errors.end(),
53 [get_iter](
const vtype p1,
const vtype p2) {
return get_iter(p1) < get_iter(p2); }));
55 vector<double> ub = { 5e-8, 5e-8, 5e-8, 5e-8 };
56 for (
auto& x: errors) {
57 if (get_iter(x) == max_iter) {
58 EXPECT_LE(get_error(x), ub[get_step(x)]);
63 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
64 vector<size_t> ic = { 1, 1, 2, 2 };
65 ASSERT_EQ(max_iter, (
size_t) ic[rank]);
68 int main(
int argc,
char** argv)
70 testing::InitGoogleTest(&argc, argv);
71 MPI_Init(&argc, &argv);
75 int result = 1, max_result;
77 result = RUN_ALL_TESTS();
78 MPI_Allreduce(&result, &max_result, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
int main(int argc, char **argv)
static void init(int argc, char **argv, std::function< void()> opts=nullptr, std::function< void()> logs=nullptr)
error_map run_mpi_pfasst(const double abs_res_tol, const double rel_res_tol, const size_t niters, const size_t nsteps, const double dt, const size_t ndofs_f, const size_t ndofs_c, const size_t nnodes_f, const size_t nnodes_c)
Advection/diffusion example using an encapsulated IMEX sweeper.
error_map::value_type vtype
advection-diffusion sweeper with semi-implicit time-integration.
TEST(ErrorTest, MPIPFASST)