PolyFEM
Loading...
Searching...
No Matches
QuadQuadrature.cpp
Go to the documentation of this file.
1#include "QuadQuadrature.hpp"
2#include "LineQuadrature.hpp"
3
4#include <vector>
5#include <cassert>
6#include <cmath>
7
8namespace polyfem
9{
10 namespace quadrature
11 {
15
16 void QuadQuadrature::get_quadrature(const int order, Quadrature &quad)
17 {
18 Quadrature tmp;
19 LineQuadrature one_d_quad;
20 one_d_quad.get_quadrature(order, tmp);
21
22 const long n_quad_pts = tmp.weights.size();
23
24 quad.points = Eigen::MatrixXd(n_quad_pts * n_quad_pts, 2);
25 quad.weights = Eigen::MatrixXd(n_quad_pts * n_quad_pts, 1);
26
27 for (long i = 0; i < n_quad_pts; ++i)
28 {
29 for (long j = 0; j < n_quad_pts; ++j)
30 {
31 quad.points.row(i * n_quad_pts + j) = Eigen::Vector2d(tmp.points(j), tmp.points(i));
32 quad.weights(i * n_quad_pts + j) = tmp.weights(i) * tmp.weights(j);
33 }
34 }
35
36 assert(fabs(quad.weights.sum() - 1) < 1e-14);
37 assert(quad.points.minCoeff() >= 0 && quad.points.maxCoeff() <= 1);
38
39 assert((quad.points.rows() == quad.weights.size()));
40 }
41 } // namespace quadrature
42} // namespace polyfem
Quadrature quadrature
void get_quadrature(const int order, Quadrature &quad)
void get_quadrature(const int order, Quadrature &quad)