PFASST++
test_scalar_highprec.cpp
Go to the documentation of this file.
1 /*
2  * Tests for the scalar example solving the test equation
3  */
4 #include <cmath>
5 using namespace std;
6 
7 #include <gtest/gtest.h>
8 #include <gmock/gmock.h>
9 using namespace ::testing;
10 
11 #include <pfasst/quadrature.hpp>
12 
13 #define PFASST_UNIT_TESTING
14 #include "../examples/scalar/scalar_sdc.cpp"
15 #undef PFASST_UNIT_TESTING
16 using namespace pfasst::examples::scalar;
17 
18 /*
19  * parameterized test that verifies that given sufficiently many nodes and iterations,
20  * SDC can reproduce the analytic solution with very high precision
21  */
23  : public TestWithParam<pfasst::quadrature::QuadratureType>
24 {
25  protected:
27 
28  const complex<double> lambda = complex<double>(-1.0,1.0);
29  const double dt = 0.2; // = Tend for single step
30  const size_t nsteps = 1;
31  const size_t niters = 30;
32  const size_t nnodes = 8;
34  double err;
35 
37  {
38  switch (this->nodetype)
39  {
41  this->nnodes_in_call = this->nnodes;
42  break;
43 
45  this->nnodes_in_call = this->nnodes + 2;
46  break;
47 
49  this->nnodes_in_call = this->nnodes + 1;
50  break;
51 
53  this->nnodes_in_call = this->nnodes + 1;
54  break;
55 
57  this->nnodes_in_call = this->nnodes + 1;
58  break;
59 
60  default:
61  break;
62  }
63  }
64 
65  public:
66  virtual void SetUp()
67  {
68  this->nodetype = GetParam();
69  this->set_parameters();
70  this->err = run_scalar_sdc(this->nsteps, this->dt, this->nnodes_in_call,
71  this->niters, this->lambda, this->nodetype);
72  }
73 
74  virtual void TearDown()
75  {}
76 };
77 
79 {
80  EXPECT_THAT(err, Le<double>(9e-12)) << "Failed to bring relative error below 9e-12";
81 }
82 
89 );
90 
91 int main(int argc, char** argv)
92 {
93  testing::InitGoogleTest(&argc, argv);
94  return RUN_ALL_TESTS();
95 }
int main(int argc, char **argv)
QuadratureType
Quadrature type descriptors.
Definition: interface.hpp:32
STL namespace.
pfasst::quadrature::QuadratureType nodetype
INSTANTIATE_TEST_CASE_P(ScalarSDC, HighPrecisionTest, Values(pfasst::quadrature::QuadratureType::GaussLobatto, pfasst::quadrature::QuadratureType::GaussLegendre, pfasst::quadrature::QuadratureType::GaussRadau, pfasst::quadrature::QuadratureType::ClenshawCurtis, pfasst::quadrature::QuadratureType::Uniform))
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.
Definition: scalar_sdc.cpp:38
float dt
Definition: plot.py:10
TEST_P(HighPrecisionTest, AllNodes)