HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
GMpoly_edge.hpp
Go to the documentation of this file.
1 # ifndef _GMPOLY_EDGE_HPP
2 # define _GMPOLY_EDGE_HPP
3 
4 /*
5 
6  Classes to implement the quadrature-free polynomial integration rules
7 
8 */
9 
10 #include <cassert>
11 #include <cmath>
12 
13 #include <mesh.hpp>
14 #include <quadraturerule.hpp>
15 #include <basis.hpp>
16 #include <GMpoly_cell.hpp>
17 
18 namespace HArDCore3D {
19 
26 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 // INTEGRALS OF MONOMIALS
29 //----------------------------------------------------------------------
30 //----------------------------------------------------------------------
31 
32 
34 typedef std::vector<double> MonomialEdgeIntegralsType;
35 
38  (const Edge & E,
39  const int maxdeg
40  );
41 
42 
45  (const Edge & E,
46  const size_t degree,
47  const MonomialEdgeIntegralsType & mono_int_map = {}
48  );
49 
50 //----------------------------------------------------------------------
51 //----------------------------------------------------------------------
52 // FUNCTIONS TO COMPUTE GRAM MATRICES
53 //----------------------------------------------------------------------
54 //----------------------------------------------------------------------
55 
56 //
57 /* SCALAR bases */
58 
60 Eigen::MatrixXd GramMatrix(
61  const Edge & E,
62  const MonomialScalarBasisEdge & basis1,
63  const MonomialScalarBasisEdge & basis2,
64  MonomialEdgeIntegralsType mono_int_map = {}
65  );
66 
68 template<typename BasisType1, typename BasisType2>
69 Eigen::MatrixXd GramMatrix(const Edge& E,
70  const BasisType1 & basis1,
71  const BasisType2 & basis2,
72  MonomialEdgeIntegralsType mono_int_map = {}
73  )
74  {
75  // If no ancestor is to be used, we shouldn't be in this overload
76  static_assert(useAncestor<BasisType1>() || useAncestor<BasisType2>(), "No method to compute this Gram matrix");
77 
78  if constexpr (!useAncestor<BasisType1>() && useAncestor<BasisType2>()) {
79  return transformGM(basis2, 'C', GramMatrix(E, basis1, basis2.ancestor(), mono_int_map) );
80  } else if constexpr (useAncestor<BasisType1>() && !useAncestor<BasisType2>()) {
81  return transformGM(basis1, 'R', GramMatrix(E, basis1.ancestor(), basis2, mono_int_map) );
82  } else {
83  return transformGM(basis1, 'R', transformGM(basis2, 'C', GramMatrix(E, basis1.ancestor(), basis2.ancestor(), mono_int_map) ) );
84  }
85 
86  }
87 
89 template<typename BasisType>
90 Eigen::MatrixXd GramMatrix(const Edge& E, const BasisType & basis, MonomialEdgeIntegralsType mono_int_map = {})
91  {
92  return GramMatrix(E, basis, basis, mono_int_map);
93  }
94 
95 /* GRADIENT-SCALAR bases */
96 
98 Eigen::MatrixXd GMDer(
99  const Edge & E,
100  const MonomialScalarBasisEdge & basis1,
101  const MonomialScalarBasisEdge & basis2,
102  MonomialEdgeIntegralsType mono_int_map = {}
103  );
104 
106 template<typename BasisType1, typename BasisType2>
107 Eigen::MatrixXd GMDer(const Edge& E,
108  const BasisType1 & basis1,
109  const BasisType2 & basis2,
110  MonomialEdgeIntegralsType mono_int_map = {}
111  )
112  {
113  // If no ancestor is to be used, we shouldn't be in this overload
114  static_assert(useAncestor<BasisType1>() || useAncestor<BasisType2>(), "No method to compute this Gram matrix");
115 
116  if constexpr (!useAncestor<BasisType1>() && useAncestor<BasisType2>()) {
117  return transformGM(basis2, 'C', GMDer(E, basis1, basis2.ancestor(), mono_int_map) );
118  } else if constexpr (useAncestor<BasisType1>() && !useAncestor<BasisType2>()) {
119  return transformGM(basis1, 'R', GMDer(E, basis1.ancestor(), basis2, mono_int_map) );
120  } else {
121  return transformGM(basis1, 'R', transformGM(basis2, 'C', GMDer(E, basis1.ancestor(), basis2.ancestor(), mono_int_map) ) );
122  }
123 
124  }
125 
126 
128 template<typename BasisType1, typename BasisType2>
129 Eigen::MatrixXd GramMatrix(
130  const Edge & E,
131  const GradientBasis<BasisType1> & basis1,
132  const BasisType2 & basis2,
133  MonomialEdgeIntegralsType mono_int_map = {}
134  )
135  {
136  return GMDer(E, basis1.ancestor(), basis2, mono_int_map)/E.diam();
137  }
138 
140 template<typename BasisType1, typename BasisType2>
141 Eigen::MatrixXd GramMatrix(
142  const Edge & E,
143  const BasisType1 & basis1,
144  const GradientBasis<BasisType2> & basis2,
145  MonomialEdgeIntegralsType mono_int_map = {}
146  )
147  {
148  return (GMDer(E, basis2.ancestor(), basis1, mono_int_map).transpose())/E.diam();
149  }
150 
151 
152 
153 
155 } // end of namespace HArDCore3D
156 
157 #endif // end of _GMPOLY_EDGE_HPP
Basis for the space of gradients of polynomials.
Definition: basis.hpp:1228
constexpr const BasisType & ancestor() const
Return the ancestor (basis that the gradient was taken of)
Definition: basis.hpp:1273
Eigen::MatrixXd GramMatrix(const Cell &T, const MonomialScalarBasisCell &basis1, const MonomialScalarBasisCell &basis2, MonomialCellIntegralsType mono_int_map={})
Computes the Gram Matrix of a pair of local scalar monomial bases.
Definition: GMpoly_cell.cpp:170
Eigen::MatrixXd GMDer(const Edge &E, const MonomialScalarBasisEdge &basis1, const MonomialScalarBasisEdge &basis2, MonomialEdgeIntegralsType mono_int_map={})
Computes the Gram Matrix of the derivative of a monomial basis with another monomial basis.
Definition: GMpoly_edge.cpp:52
MonomialCellIntegralsType CheckIntegralsDegree(const Cell &T, const size_t degree, const MonomialCellIntegralsType &mono_int_map={})
Checks if the degree of an existing list of monomial integrals is sufficient, other re-compute and re...
Definition: GMpoly_cell.cpp:160
MonomialEdgeIntegralsType IntegrateEdgeMonomials(const Edge &E, const int maxdeg)
Compute all integrals of edge monomials up to a total degree.
Definition: GMpoly_edge.cpp:6
std::vector< double > MonomialEdgeIntegralsType
Type for list of edge integrals of monomials.
Definition: GMpoly_edge.hpp:34
Eigen::MatrixXd transformGM(const Family< BasisType > &family_basis, const char RC, const Eigen::MatrixXd &anc_GM)
Transforms a Gram Matrix from an ancestor to a family basis.
Definition: GMpoly_cell.hpp:85
Definition: ddr-magnetostatics.hpp:40
MeshND::Edge< 2 > Edge
Definition: Mesh2D.hpp:11