PFASST++
gauss_lobatto_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  GaussLobatto<precision>::GaussLobatto(const size_t num_nodes)
16  : IQuadrature<precision>(num_nodes)
17  {
18  if (this->num_nodes < 2) {
19  throw invalid_argument("Gauss-Lobatto 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 roots = Polynomial<precision>::legendre(this->num_nodes - 1).differentiate().roots();
42 
43  for (size_t j = 0; j < this->num_nodes - 2; j++) {
44  this->nodes[j + 1] = 0.5 * (1.0 + roots[j]);
45  }
46  this->nodes.front() = 0.0;
47  this->nodes.back() = 1.0;
48  }
49  } // ::pfasst::quadrature
50 } // ::pfasst
virtual void compute_nodes() override
Interface for quadrature handlers.
Definition: interface.hpp:232
virtual bool left_is_node() const override
STL namespace.
Quadrature handler for Gauss-Lobatto quadrature.
virtual bool right_is_node() const override
static Polynomial< CoeffT > legendre(const size_t order)
Computes the Legendre polynomial of given order.