HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge and cell polynomials as unknowns
Loading...
Searching...
No Matches
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
18namespace HArDCore2D {
19
26//----------------------------------------------------------------------
27//----------------------------------------------------------------------
28// INTEGRALS OF MONOMIALS
29//----------------------------------------------------------------------
30//----------------------------------------------------------------------
31
32
34typedef std::vector<double> MonomialEdgeIntegralsType;
35
38 (const Edge & E,
39 const size_t 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
60Eigen::MatrixXd GramMatrix(
61 const Edge & E,
62 const MonomialScalarBasisEdge & basis1,
63 const MonomialScalarBasisEdge & basis2,
64 MonomialEdgeIntegralsType mono_int_map = {}
65 );
66
68template<typename BasisType1, typename BasisType2>
69Eigen::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
89template<typename BasisType1, typename BasisType2, size_t N>
90Eigen::MatrixXd GramMatrix(
91 const Edge& E,
94 MonomialEdgeIntegralsType mono_int_map = {}
95 )
96 {
97 Eigen::MatrixXd gm = Eigen::MatrixXd::Zero(basis1.dimension(), basis2.dimension());
98
99 Eigen::MatrixXd anc_gm = GramMatrix(E, basis1.ancestor(), basis2.ancestor(), mono_int_map);
100 size_t dim1 = anc_gm.rows();
101 size_t dim2 = anc_gm.cols();
102
103 for (size_t i=0; i<N; i++){
104 gm.block(i*dim1, i*dim2, dim1, dim2) = anc_gm;
105 }
106 return gm;
107 }
108
110template<typename BasisType>
111Eigen::MatrixXd GramMatrix(const Edge& E, const BasisType & basis, MonomialEdgeIntegralsType mono_int_map = {})
112 {
113 return GramMatrix(E, basis, basis, mono_int_map);
114 };
115
116/* GRADIENT-SCALAR bases */
117
119Eigen::MatrixXd GMDer(
120 const Edge & E,
121 const MonomialScalarBasisEdge & basis1,
122 const MonomialScalarBasisEdge & basis2,
123 MonomialEdgeIntegralsType mono_int_map = {}
124 );
125
127template<typename BasisType1, typename BasisType2>
128Eigen::MatrixXd GMDer(const Edge& E,
129 const BasisType1 & basis1,
130 const BasisType2 & basis2,
131 MonomialEdgeIntegralsType mono_int_map = {}
132 )
133 {
134 // If no ancestor is to be used, we shouldn't be in this overload
135 static_assert(useAncestor<BasisType1>() || useAncestor<BasisType2>(), "No method to compute this Gram matrix");
136
137 if constexpr (!useAncestor<BasisType1>() && useAncestor<BasisType2>()) {
138 return transformGM(basis2, 'C', GMDer(E, basis1, basis2.ancestor(), mono_int_map) );
139 } else if constexpr (useAncestor<BasisType1>() && !useAncestor<BasisType2>()) {
140 return transformGM(basis1, 'R', GMDer(E, basis1.ancestor(), basis2, mono_int_map) );
141 } else {
142 return transformGM(basis1, 'R', transformGM(basis2, 'C', GMDer(E, basis1.ancestor(), basis2.ancestor(), mono_int_map) ) );
143 }
144
145 };
146
147
149template<typename BasisType1, typename BasisType2>
150Eigen::MatrixXd GramMatrix(
151 const Edge & E,
152 const GradientBasis<BasisType1> & basis1,
153 const BasisType2 & basis2,
154 MonomialEdgeIntegralsType mono_int_map = {}
155 )
156 {
157 return GMDer(E, basis1.ancestor(), basis2, mono_int_map)/E.diam();
158 };
159
161template<typename BasisType1, typename BasisType2>
162Eigen::MatrixXd GramMatrix(
163 const Edge & E,
164 const BasisType1 & basis1,
165 const GradientBasis<BasisType2> & basis2,
166 MonomialEdgeIntegralsType mono_int_map = {}
167 )
168 {
169 return (GMDer(E, basis2.ancestor(), basis1, mono_int_map).transpose())/E.diam();
170 };
171
172
173
174
176} // end of namespace HArDCore2D
177
178#endif // end of _GMPOLY_EDGE_HPP
Basis for the space of gradients of polynomials.
Definition basis.hpp:1181
Vector family obtained by tensorization of a scalar family.
Definition basis.hpp:559
Compute max and min eigenvalues of all matrices for i
Definition compute_eigs.m:5
constexpr const ScalarFamilyType & ancestor() const
Return the ancestor (family that has been tensorized)
Definition basis.hpp:689
constexpr const BasisType & ancestor() const
Return the ancestor (basis that the gradient was taken of)
Definition basis.hpp:1227
size_t dimension() const
Return the dimension of the family.
Definition basis.hpp:595
std::vector< double > MonomialEdgeIntegralsType
Type for list of edge integrals of monomials.
Definition GMpoly_edge.hpp:34
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:76
MonomialEdgeIntegralsType IntegrateEdgeMonomials(const Edge &E, const size_t maxdeg)
Compute all integrals of edge monomials up to a total degree.
Definition GMpoly_edge.cpp:6
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:77
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:49
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:86
Definition ddr-klplate.hpp:27