7 #include <gtest/gtest.h>
8 #include <gmock/gmock.h>
9 using namespace ::testing;
13 #define PFASST_UNIT_TESTING
14 #include "../examples/advection_diffusion/serial_mlsdc.cpp"
15 #undef PFASST_UNIT_TESTING
22 :
public TestWithParam<tuple<size_t, pfasst::quadrature::QuadratureType>>
36 this->nnodes = get<0>(GetParam());
37 this->nodetype = get<1>(GetParam());
39 switch (this->nodetype)
42 this->niters = 2 * this->nnodes - 2;
43 this->nsteps = { 4, 8, 16, 32 };
48 this->niters = 2 * this->nnodes;
49 this->nsteps = { 4, 8, 16, 32 };
53 this->niters = this->nnodes;
54 this->nsteps = { 4, 8, 16, 32 };
58 this->niters = this->nnodes;
59 this->nsteps = { 4, 8, 16, 32 };
67 for (
size_t i = 0; i < this->nsteps.size(); ++i) {
68 auto dt = 0.5 / double(this->nsteps[i]);
79 auto errors = get<0>(errors_and_residuals);
81 this->err.push_back(errors.at(last_error));
85 for (
size_t i = 0; i < this->nsteps.size() - 1; ++i) {
86 this->convrate.push_back(log10(this->err.at(i+1) / this->err.at(i)) /
87 log10(
double(this->nsteps.at(i)) /
double(this->nsteps.at(i + 1))));
102 switch (this->nodetype)
105 order = 2 * this->nnodes - 2;
106 quad =
"Gauss-Lobatto";
111 order = 2 * this->nnodes;
112 quad =
"Gauss-Legendre";
116 order = 2 * this->nnodes - 1;
117 quad =
"Gauss-Radau";
121 order = this->nnodes;
122 quad =
"Clenshaw-Curtis";
126 order = this->nnodes;
135 for (
size_t i = 0; i < this->nsteps.size() - 1; ++i) {
136 EXPECT_THAT(convrate[i], Ge<double>(fudge * order)) <<
"Convergence rate for "
137 << this->nnodes <<
" " << quad <<
" nodes"
138 <<
" for nsteps " << this->nsteps[i]
139 <<
" not within expected range.";
144 Combine(Range<size_t>(5, 6),
150 int main(
int argc,
char** argv)
152 testing::InitGoogleTest(&argc, argv);
156 return RUN_ALL_TESTS();
pfasst::quadrature::QuadratureType nodetype
QuadratureType
Quadrature type descriptors.
static void init(int argc, char **argv, std::function< void()> opts=nullptr, std::function< void()> logs=nullptr)
Clenshaw-Curtis quadrature
Gauss-Legendre quadrature
int main(int argc, char **argv)
vector< double > convrate
TEST_P(ConvergenceTest, AllNodes)
advection-diffusion sweeper with semi-implicit time-integration.
error_map::key_type ktype
INSTANTIATE_TEST_CASE_P(AdvectionDiffusionPFASST, ConvergenceTest, Combine(Range< size_t >(5, 6), Values(pfasst::quadrature::QuadratureType::GaussLobatto, pfasst::quadrature::QuadratureType::ClenshawCurtis, pfasst::quadrature::QuadratureType::Uniform)))
tuple< error_map, residual_map > run_serial_mlsdc(size_t nlevs, size_t nsteps_in=4, double step_size_in=0.01, size_t num_iter_in=8, size_t nnodes_in=5, size_t ndofs_in=128)
Advection/diffusion example using an encapsulated IMEX sweeper.