8 #include <gtest/gtest.h>
9 #include <gmock/gmock.h>
10 using namespace ::testing;
14 #define PFASST_UNIT_TESTING
15 #include "../examples/vanderpol/vdp_sdc.cpp"
16 #undef PFASST_UNIT_TESTING
23 :
public TestWithParam<tuple<size_t, pfasst::quadrature::QuadratureType>>
28 const double nu = 0.0;
29 const double x0 = 1.0;
30 const double y0 = 0.5;
42 this->nnodes = get<0>(GetParam());
43 this->nodetype = get<1>(GetParam());
45 switch (this->nodetype)
48 this->niters = 2 * this->nnodes;
49 this->end_time = 0.88;
50 this->nsteps = { 7, 9, 11 };
54 this->niters = 2 * this->nnodes - 1;
55 this->end_time = 0.88;
56 this->nsteps = { 7, 9, 11, 13 };
64 for (
size_t i = 0; i < this->nsteps.size(); ++i) {
65 auto dt = this->end_time / this->nsteps[i];
66 this->err.push_back(
run_vdp_sdc(this->nsteps[i],
dt, this->nnodes,
67 this->niters, this->nu, this->x0, this->y0, this->nodetype));
71 for (
size_t i = 0; i < this->nsteps.size() - 1; ++i) {
72 this->convrate.push_back(log10(this->err[i+1] / this->err[i]) /
73 log10(
double(this->nsteps[i]) /
double(this->nsteps[i + 1])));
88 switch (this->nodetype)
91 order = 2 * this->nnodes;
92 quad =
"Gauss-Legendre";
95 order = 2 * this->nnodes - 1;
103 for (
size_t i = 0; i < this->nsteps.size() - 1; ++i) {
104 EXPECT_THAT(convrate[i], Ge<double>(0.99 * order)) <<
"Convergence rate for "
105 << this->nnodes <<
" " << quad <<
" nodes"
106 <<
" for nsteps " << this->nsteps[i]
107 <<
" not within expected range.";
112 Combine(Range<size_t>(3, 4),
116 int main(
int argc,
char** argv)
119 testing::InitGoogleTest(&argc, argv);
120 return RUN_ALL_TESTS();
QuadratureType
Quadrature type descriptors.
pfasst::quadrature::QuadratureType nodetype
double run_vdp_sdc(const size_t nsteps, const double dt, const size_t nnodes, const size_t niters, const double nu, const double x0, const double y0, const quadrature::QuadratureType nodetype)
TEST_P(VdPConvergenceTest, AllNodes)
static void init(int argc, char **argv, std::function< void()> opts=nullptr, std::function< void()> logs=nullptr)
INSTANTIATE_TEST_CASE_P(VanDerPol, VdPConvergenceTest, Combine(Range< size_t >(3, 4), Values(pfasst::quadrature::QuadratureType::GaussLegendre, pfasst::quadrature::QuadratureType::GaussRadau)))
Gauss-Legendre quadrature
int main(int argc, char **argv)
vector< double > convrate