7 #include <gtest/gtest.h>
8 #include <gmock/gmock.h>
9 using namespace ::testing;
13 #define PFASST_UNIT_TESTING
14 #include "../examples/scalar/scalar_sdc.cpp"
15 #undef PFASST_UNIT_TESTING
22 :
public TestWithParam<tuple<size_t, pfasst::quadrature::QuadratureType>>
28 vector<size_t> nsteps;
30 vector<double> convrate;
37 this->nnodes = get<0>(GetParam());
38 this->nodetype = get<1>(GetParam());
40 switch (this->nodetype)
43 this->niters = 2 * this->nnodes - 2;
45 this->lambda = complex<double>(-1.0, 1.0);
46 this->nsteps = { 2, 5, 10, 15 };
50 this->niters = 2 * this->nnodes;
52 this->lambda = complex<double>(-1.0, 2.0);
53 this->nsteps = { 2, 4, 6, 8, 10 };
57 this->niters = 2 * this->nnodes;
59 this->lambda = complex<double>(-1.0, 2.0);
60 this->nsteps = { 4, 6, 8, 10, 12 };
64 this->niters = this->nnodes + 1;
66 this->lambda = complex<double>(-1.0, 1.0);
67 this->nsteps = { 7, 9, 11, 13 };
71 this->niters = this->nnodes;
73 this->lambda = complex<double>(-1.0, 1.0);
74 this->nsteps = { 9, 11, 13, 15 };
82 for (
size_t i = 0; i < this->nsteps.size(); ++i) {
83 auto dt = this->end_time / double(this->nsteps[i]);
85 this->niters, this->lambda, this->nodetype));
89 for (
size_t i = 0; i < this->nsteps.size() - 1; ++i) {
90 this->convrate.push_back(log10(this->err[i+1] / this->err[i]) /
91 log10(
double(this->nsteps[i]) /
double(this->nsteps[i + 1])));
107 switch (this->nodetype)
110 order = 2 * this->nnodes - 2;
111 quad =
"Gauss-Lobatto";
115 order = 2 * this->nnodes;
116 quad =
"Gauss-Legendre";
120 order = 2 * this->nnodes;
121 quad =
"Gauss-Radau";
125 order = this->nnodes;
126 quad =
"Clenshaw-Curtis";
130 order = this->nnodes;
140 for (
size_t i = 0; i < this->nsteps.size() - 1; ++i) {
141 EXPECT_THAT(convrate[i], Ge<double>(fudge * order)) <<
"Convergence rate for "
142 << this->nnodes <<
" " << quad <<
" nodes"
143 <<
" for nsteps " << this->nsteps[i]
144 <<
" not within expected range.";
149 Combine(Range<size_t>(3, 7),
157 int main(
int argc,
char** argv)
159 testing::InitGoogleTest(&argc, argv);
160 return RUN_ALL_TESTS();
QuadratureType
Quadrature type descriptors.
int main(int argc, char **argv)
INSTANTIATE_TEST_CASE_P(ScalarSDC, ConvergenceTest, Combine(Range< size_t >(3, 7), Values(pfasst::quadrature::QuadratureType::GaussLobatto, pfasst::quadrature::QuadratureType::GaussLegendre, pfasst::quadrature::QuadratureType::GaussRadau, pfasst::quadrature::QuadratureType::ClenshawCurtis, pfasst::quadrature::QuadratureType::Uniform)))
Clenshaw-Curtis quadrature
Gauss-Legendre quadrature
double run_scalar_sdc(const size_t nsteps, const double dt, const size_t nnodes, const size_t niters, const complex< double > lambda, const quadrature::QuadratureType nodetype)
Scalar test equation example using an encapsulated IMEX sweeper.
TEST_P(ConvergenceTest, AllNodes)