27 #ifndef QGAUSSLEGENDRESIMPLEX_HPP_
28 #define QGAUSSLEGENDRESIMPLEX_HPP_
30 #include <deal.II/base/config.h>
32 #include <deal.II/base/quadrature.h>
39 extern std::pair<std::vector<dealii::Point<1>>, std::vector<double>>
41 const double right_position,
44 AssertThrow(left_position < right_position,
45 dealii::StandardExceptions::ExcMessage(
46 "(a,b) is an interval, hence a must be lower than b."));
51 const double middle_point = 0.5 * (right_position + left_position);
52 const double half_length = 0.5 * (right_position - left_position);
54 std::vector<dealii::Point<1>> coords(
n);
55 std::vector<double> weights(
n);
57 double z, z1, p1, p2, p3, pp = 0.0;
59 for (
unsigned int i = 1; i <= (
n + 1) / 2.; ++i)
61 z = std::cos(M_PI * (i - 0.25) / (
n + 0.5));
64 while (!(std::abs(z - z1) < 1e-10))
69 for (
unsigned int j = 1; j <=
n; ++j)
73 p1 = ((2 * j - 1) * z * p2 - (j - 1) * p3) / j;
76 pp =
n * (z * p1 - p2) / (pow(z, 2) - 1);
81 const dealii::Point<1> P1(middle_point - half_length * z);
82 const dealii::Point<1> P2(middle_point + half_length * z);
85 weights[i - 1] = 2.0 * half_length / ((1.0 - z * z) * pp * pp);
86 weights[
n - i] = weights[i - 1];
89 return {coords, weights};
98 template <
unsigned int dim>
109 : dealii::Quadrature<1>(
n)
111 std::vector<dealii::Point<1>> coords_1D(
n);
112 std::vector<double> weights_1D(
n);
113 std::tie(coords_1D, weights_1D) =
gauleg(0, 1,
n);
115 this->quadrature_points = coords_1D;
116 this->weights = weights_1D;
123 : dealii::Quadrature<2>(
n)
125 std::vector<dealii::Point<1>> coords_1D(
n);
126 std::vector<double> weights_1D(
n);
127 std::tie(coords_1D, weights_1D) =
gauleg(-1, 1,
n);
129 std::vector<dealii::Point<2>> coords_2D;
130 std::vector<double> weights_2D;
132 for (
unsigned int i = 0; i <
n; ++i)
134 for (
unsigned int j = 0; j <
n; ++j)
136 const dealii::Point<2> P((1 + coords_1D[i][0]) / 2,
137 (1 - coords_1D[i][0]) *
138 (1 + coords_1D[j][0]) / 4);
140 coords_2D.push_back(P);
141 weights_2D.push_back((1 - coords_1D[i][0]) * weights_1D[i] *
146 this->quadrature_points = coords_2D;
147 this->weights = weights_2D;
155 : dealii::Quadrature<3>(
n)
157 std::vector<dealii::Point<1>> coords_1D(
n);
158 std::vector<double> weights_1D(
n);
159 std::tie(coords_1D, weights_1D) =
gauleg(-1, 1,
n);
161 std::vector<dealii::Point<3>> coords_3D;
162 std::vector<double> weights_3D;
164 for (
unsigned int i = 0; i <
n; ++i)
166 for (
unsigned int j = 0; j <
n; ++j)
168 for (
unsigned int k = 0;
k <
n; ++
k)
170 const dealii::Point<3> new_coords((coords_1D[i][0] + 1) *
171 (coords_1D[j][0] - 1) *
172 (coords_1D[
k][0] - 1) / 8,
173 (1 - coords_1D[
k][0]) *
174 (1 + coords_1D[j][0]) / 4,
175 (coords_1D[
k][0] + 1) / 2);
177 coords_3D.push_back(new_coords);
178 weights_3D.push_back((1 - coords_1D[
k][0]) *
179 (1 - coords_1D[
k][0]) *
180 (1 - coords_1D[j][0]) * weights_1D[i] *
181 weights_1D[j] * weights_1D[
k] / 64);
186 this->quadrature_points = coords_3D;
187 this->weights = weights_3D;
std::pair< std::vector< dealii::Point< 1 > >, std::vector< double > > gauleg(const double left_position, const double right_position, const unsigned int n)
This routine computes the Gauss-Legendre nodes and weights on a given interval (a,...
Class representing the Gauss-Legendre quadrature formula on simplex elements.
QGaussLegendreSimplex(const unsigned int n)
Constructor.