Manicore
Library to implement schemes on n-dimensionnal manifolds.
quadraturerule.hpp
Go to the documentation of this file.
1 // Author: Daniele Di Pietro (daniele.di-pietro@umontpellier.fr)
2 // Author: Jérome Droniou (jerome.droniou@monash.edu)
3 //
4 // Adapted to Manicore by Marien Hanot
5 
6 #ifndef QUADRATURERULE_HPP
7 #define QUADRATURERULE_HPP
8 
9 #include "dcell.hpp"
10 #include "legendregauss.hpp"
11 #include "quad_2d.hpp"
12 
22 namespace Manicore {
25 
27  constexpr int QuadratureMaxDegree[] = {21*2,20};
28 
30 
31  template<size_t d>
33  {
34  Eigen::Vector<double,d> vector ;
35  double w ;
36  };
37 
39 
40  template<size_t d>
41  using QuadratureRule = std::vector<QuadratureNode<d>>;
42 
44 
45  template<typename CellType> requires(CellType::cell_dim == 1)
46  QuadratureRule<CellType::cell_dim> generate_quadrature_rule(const CellType &f , const int doe )
47  {
48  auto const &T = f.get_reference_elem();
49  QuadratureRule<1> quad;
50  for (auto const & trig : T) {
51  double v = trig[1](0) - trig[0](0);
52  double x0 = trig[0](0);
53  LegendreGauss rule(std::max(doe,1));
54  for (size_t iqn = 0; iqn < rule.npts(); ++iqn) {
55  Eigen::Vector<double,1> vect = Eigen::Vector<double,1>{rule.tq(iqn)*v + x0};
56  quad.push_back({vect,rule.wq(iqn)});
57  }
58  }
59  return quad;
60  }
61 
63 
64  template<typename CellType> requires(CellType::cell_dim == 2)
65  QuadratureRule<CellType::cell_dim> generate_quadrature_rule(const CellType &f , const int doe )
66  {
67  QuadRuleTriangle quadCell(std::max(doe,0));
68  QuadratureRule<2> quad;
69 
70  auto const &T = f.get_reference_elem();
71  for (auto const & trig : T) {
72  double xTt[] = {trig[0](0),trig[1](0),trig[2](0)};
73  double yTt[] = {trig[0](1),trig[1](1),trig[2](1)};
74  quadCell.setup(xTt, yTt);
75  for (size_t iqn = 0; iqn < quadCell.nq(); iqn++) {
76  quad.push_back({Eigen::Vector2d{quadCell.xq(iqn), quadCell.yq(iqn)}, quadCell.wq(iqn)});
77  }
78  }
79  return quad;
80  }
81 
83 } // end of namespace
84 #endif
Compute the number of node, their location and the associated weight for a given degree of exactness.
Definition: legendregauss.hpp:17
Store the geometrical description of each cell and their topological relations.
requires(d > 0 &&d<=dimension) struct dCell_mass
Compute the mass matrices of a d-cell.
Definition: dcell_integral.hpp:17
std::vector< QuadratureNode< d > > QuadratureRule
Vector of locations and weights.
Definition: quadraturerule.hpp:41
constexpr int QuadratureMaxDegree[]
Maximum degree of quadrature implemented for each dimension (start with dimension 1)
Definition: quadraturerule.hpp:27
Definition: maxwell.hpp:23
Description of one node and one weight from a quadrature rule.
Definition: quadraturerule.hpp:33
Eigen::Vector< double, d > vector
Definition: quadraturerule.hpp:34
double w
Definition: quadraturerule.hpp:35