@@ -12,13 +12,6 @@ using namespace ::testing;
1212#include " ../examples/scalar/scalar_sdc.cpp"
1313#undef PFASST_UNIT_TESTING
1414
15- // I could not get this matcher to do what I want...
16- MATCHER (MyDoubleMore, " " )
17- {
18- return get<0 >(arg) > get<1 >(arg);
19- }
20-
21-
2215/*
2316 * parameterized test fixture with number of nodes as parameter
2417 */
@@ -64,15 +57,19 @@ class ConvergenceTest
6457 for (size_t i = 0 ; i <= nsteps_l - 2 ; ++i) {
6558 convrate_lobatto[i] = log10 (err[i+1 ] / err[i]) / log10 (double (nsteps[i]) / double (nsteps[i + 1 ]));
6659 }
67-
68- // Run for Legendre nodes
60+
61+ /*
62+ * Compute convergence rates for Legendre nodes.
63+ * Note that this is not a particularly nice way to do the test, because both types
64+ * of nodes are tested in the same test. Having separate tests would be nicer...
65+ */
6966 nodetype = pfasst::QuadratureType::GaussLegendre;
7067 this ->convrate_legendre .resize (this ->nsteps .size ());
7168
7269 // refine parameter
73- complex <double > lambda = complex <double >(-1.0 , 4 .0 );
74- this ->Tend = 5 .0 ;
75- this ->nsteps = { 5 , 7 , 9 , 11 , 13 };
70+ complex <double > lambda = complex <double >(-1.0 , 2 .0 );
71+ this ->Tend = 6 .0 ;
72+ this ->nsteps = { 2 , 4 , 6 , 8 , 10 };
7673 this ->niters = 2 *nnodes;
7774
7875 // run to compute errors
@@ -96,25 +93,25 @@ class ConvergenceTest
9693};
9794
9895/*
99- * For Lobatto nodes, the resulting method should of order 2*M-2 with M=number of nodes
10096 * The test below verifies that the code approximately (up to a safety factor) reproduces
101- * the theoretically expected rate of convergence
97+ * the theoretically expected rate of convergence for Lobatto and Legendre nodes
10298 */
10399TEST_P (ConvergenceTest, GaussNodes)
104100{
105101 for (size_t i = 0 ; i <= nsteps_l - 2 ; ++i) {
106102
103+ // Lobatto nodes reproduce the convergence rate quite accurately, so use DoubleNear
107104 EXPECT_THAT (convrate_lobatto[i],
108105 testing::DoubleNear (double (2 * nnodes - 2 ), 0.99 )) << " Convergence rate at node "
109106 << i
110107 << " not within expected range" ;
111108
112- // convergence rates for legendre nodes should be 2*nodes but is actually better and
113- // this is why DoubleNear fails. Need something like DoubleMore ...
109+ // convergence rates for Legendre nodes should be 2*nodes but are actually better, so
110+ // use Ge here
114111 EXPECT_THAT (convrate_legendre[i],
115- testing::DoubleNear (double (2 * nnodes ), 0.9 )) << " Convergence rate at node "
116- << i
117- << " not within expected range" ;
112+ testing::Ge (double (2 * nnodes) )) << " Convergence rate at node "
113+ << i
114+ << " not within expected range" ;
118115
119116 }
120117}
0 commit comments