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