PFASST++
gauss_radau_impl.hpp
Go to the documentation of this file.
2 
3 #include <stdexcept>
4 #include <vector>
5 using namespace std;
6 
8 
9 
10 namespace pfasst
11 {
12  namespace quadrature
13  {
14  template<typename precision>
15  GaussRadau<precision>::GaussRadau(const size_t num_nodes)
16  : IQuadrature<precision>(num_nodes)
17  {
18  if (this->num_nodes < 2) {
19  throw invalid_argument("Gauss-Radau quadrature requires at least two quadrature nodes.");
20  }
21  this->compute_nodes();
22  this->compute_weights();
23  }
24 
25  template<typename precision>
27  {
28  return LEFT_IS_NODE;
29  }
30 
31  template<typename precision>
33  {
34  return RIGHT_IS_NODE;
35  }
36 
37  template<typename precision>
39  {
40  this->nodes = vector<precision>(this->num_nodes, precision(0.0));
41  auto l = Polynomial<precision>::legendre(this->num_nodes);
42  auto lm1 = Polynomial<precision>::legendre(this->num_nodes - 1);
43 
44  for (size_t i = 0; i < this->num_nodes; i++) {
45  l[i] += lm1[i];
46  }
47  auto roots = l.roots();
48  for (size_t j = 1; j < this->num_nodes; j++) {
49  this->nodes[j - 1] = 0.5 * (1.0 - roots[this->num_nodes - j]);
50  }
51  this->nodes.back() = 1.0;
52  }
53  } // ::pfasst::quadrature
54 } // ::pfasst
virtual bool left_is_node() const override
Interface for quadrature handlers.
Definition: interface.hpp:232
STL namespace.
Quadrature handler for Gauss-Radau quadrature.
Definition: gauss_radau.hpp:23
virtual void compute_nodes() override
static Polynomial< CoeffT > legendre(const size_t order)
Computes the Legendre polynomial of given order.
virtual bool right_is_node() const override