1# ifndef _GMPOLY_CELL_HPP
2# define _GMPOLY_CELL_HPP
17#include <unordered_map>
43 constexpr size_t b = 100;
44 return p(0) + p(1) *
b + p(2) *
b*
b;
84template<
typename BasisType>
87 const Eigen::MatrixXd &
anc_GM
98template<
typename BasisType>
101 const Eigen::MatrixXd &
anc_GM
112template<
typename BasisType>
115 const Eigen::MatrixXd &
anc_GM
138 const MonomialScalarBasisCell &
basis1,
139 const MonomialScalarBasisCell &
basis2,
144template<
typename BasisType>
151template<
typename BasisType1,
typename BasisType2,
size_t N>
159 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
basis1.dimension(),
basis2.dimension());
165 for (
size_t i=0;
i<
N;
i++){
175 const RolyComplBasisCell &
basis1,
176 const RolyComplBasisCell &
basis2,
181template<
typename BasisType1,
size_t N>
191 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
dim1,
dim2);
197 for (
size_t m=0;
m<
N;
m++){
204template<
typename BasisType1,
size_t N>
218 const GolyComplBasisCell &
basis1,
219 const GolyComplBasisCell &
basis2,
224template<
typename BasisType1,
size_t N>
234 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
dim1,
dim2);
253template<
typename BasisType1,
size_t N>
274template<
typename BasisType>
284 static_assert(BasisType::hasAncestor,
"No method to compute this Gram matrix of derivatives");
301template<
typename BasisType>
314 static_assert(BasisType::hasAncestor,
"No method to compute this Gram matrix of derivatives");
321 const GolyComplBasisCell &
basis1,
322 const GolyComplBasisCell &
basis2,
334template<
typename BasisType>
340 if constexpr(BasisType::hasAncestor){
341 return (BasisType::tensorRank == BasisType::AncestorType::tensorRank);
348template<
typename BasisType1,
typename BasisType2>
374 const MonomialScalarBasisCell &
basis1,
375 const MonomialScalarBasisCell &
basis2,
383 const MonomialScalarBasisCell &
basis1,
384 const MonomialScalarBasisCell &
basis2,
391template<
typename BasisType1,
typename BasisType2>
401 static_assert(BasisType1::hasAncestor || BasisType2::hasAncestor,
"No method to compute this Gram matrix of derivatives");
403 if constexpr (!BasisType1::hasAncestor && BasisType2::hasAncestor) {
405 }
else if constexpr (BasisType1::hasAncestor && !BasisType2::hasAncestor) {
413template<
typename BasisType1,
typename BasisType2>
424 static_assert(BasisType1::hasAncestor || BasisType2::hasAncestor,
"No method to compute this Gram matrix of derivatives");
426 if constexpr (!BasisType1::hasAncestor && BasisType2::hasAncestor) {
428 }
else if constexpr (BasisType1::hasAncestor && !BasisType2::hasAncestor) {
440template<
typename BasisType1,
typename BasisType2,
size_t N>
450 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
dim1,
dim2);
456 for (
size_t m=0;
m<
N;
m++){
464template<
typename BasisType1,
typename BasisType2,
size_t N>
477template<
typename BasisType1,
typename BasisType2>
487 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
dim1,
dim2);
493 for (
size_t m=0;
m<3;
m++){
496 return gm/std::pow(T.diam(), 2);
500template<
typename BasisType1,
typename BasisType2>
511template<
typename BasisType1,
typename BasisType2>
512typename boost::disable_if<boost::is_same<BasisType2, MonomialCellIntegralsType>, Eigen::MatrixXd>::type
GramMatrix(
523template<
typename BasisType1,
typename Basis2>
535template<
typename BasisType1,
typename BasisType2,
size_t N>
565 return gm/std::pow(T.diam(), 2);
571 const GolyComplBasisCell &
basis1,
572 const GolyComplBasisCell &
basis2,
577template<
typename BasisType2,
size_t N>
594 gm.block(0, 0,
dim_l1,
dim2/
N) =
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 0,
intmap, 1, 0, 2) -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 0,
intmap, 2, 0, 1);
595 gm.block(0,
dim2/
N,
dim_l1,
dim2/
N) =
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 0,
intmap, 2, 0, 0) +
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 0,
intmap, 1, 1, 2)
596 +
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 0,
intmap, 2, 2, 2) + 2/T.diam()*
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 0,
intmap, 3, 3, 2);
597 gm.block(0, 2*
dim2/
N,
dim_l1,
dim2/
N) = -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 0,
intmap, 1, 0, 0) -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 0,
intmap, 1, 1, 1)
598 -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 0,
intmap, 2, 2, 1) - 2/T.diam()*
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 0,
intmap, 3, 3, 1);
599 gm.block(
dim_l1, 0,
dim_l1,
dim2/
N) = -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 1,
intmap, 2, 1, 1) -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 1,
intmap, 0, 0, 2)
600 -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 1,
intmap, 2, 2, 2) - 2/T.diam()*
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 1,
intmap, 3, 3, 2);
601 gm.block(
dim_l1,
dim2/
N,
dim_l1,
dim2/
N) = -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 1,
intmap, 0, 1, 2) +
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 1,
intmap, 2, 1, 0);
602 gm.block(
dim_l1, 2*
dim2/
N,
dim_l1,
dim2/
N) =
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 1,
intmap, 0, 1, 1) +
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 1,
intmap, 0, 0, 0)
603 +
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 1,
intmap, 2, 2, 0) + 2/T.diam()*
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 1,
intmap, 3, 3, 0);
604 gm.block(2*
dim_l1, 0,
dim1-2*
dim_l1,
dim2/
N) = -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 2,
intmap, 1, 2, 2) +
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 2,
intmap, 0, 0, 1)
605 +
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 2,
intmap, 1, 1, 1) + 2/T.diam()*
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 2,
intmap, 3, 3, 1);
606 gm.block(2*
dim_l1,
dim2/
N,
dim1-2*
dim_l1,
dim2/
N) = -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 2,
intmap, 0, 2, 2) -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 2,
intmap, 0, 0, 0)
607 -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 2,
intmap, 1, 1, 0) - 2/T.diam()*
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 2,
intmap, 3, 3, 0);
608 gm.block(2*
dim_l1, 2*
dim2/
N,
dim1-2*
dim_l1,
dim2/
N) =
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 2,
intmap, 0, 2, 1) -
GMGolyComplScalar(T,
basis1,
basis2.ancestor(), 2,
intmap, 1, 2, 0);
614template<
typename BasisType1,
size_t N>
626template<
typename BasisType1,
typename BasisType2>
647template<
typename BasisType1,
typename BasisType2,
size_t N>
657 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
dim1,
dim2);
678template<
typename BasisType2,
size_t N>
715template<
typename BasisType1,
typename BasisType2>
736template<
typename BasisType1,
typename BasisType2>
752template<
typename BasisType1,
typename BasisType2>
772template<
typename BasisType>
782 static_assert(BasisType::hasAncestor,
"No method to compute this Gram matrix of derivatives");
787template<
typename BasisType1,
typename BasisType2,
size_t N>
803 for (
size_t i = 0;
i <
N;
i++) {
804 for (
size_t j = 0;
j <
N;
j++) {
809 return gm/std::pow(T.diam(), 2);
815 const RolyComplBasisCell &
basis1,
816 const RolyComplBasisCell &
basis2,
821template<
typename BasisType2,
size_t N>
833template<
typename BasisType1,
size_t N>
849 for (
size_t i = 0;
i <
N;
i++) {
857template<
typename BasisType1,
typename BasisType2>
878template<
typename BasisType1,
typename BasisType2>
879typename boost::disable_if<boost::is_same<BasisType2, MonomialCellIntegralsType>, Eigen::MatrixXd>::type
GramMatrix(
890template<
typename BasisType1,
typename Basis2>
902template<
typename BasisType1,
size_t N>
912 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
dim1,
dim2);
918 for (
size_t i = 0;
i <
N;
i++) {
928 const RolyComplBasisCell &
basis1,
929 const MonomialScalarBasisCell &
basis2,
934template<
typename BasisType1,
typename BasisType2>
955template<
typename BasisType1,
typename BasisType2>
973template<
typename BasisType1,
typename BasisType2,
size_t N>
981 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
basis1.dimension(),
basis2.dimension());
987 for (
size_t i=0;
i<
N*
N;
i++){
994template<
typename BasisType1,
typename BasisType2>
1002 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
basis1.dimension(),
basis2.dimension());
1026template<
typename BasisType1,
typename BasisType2>
1039template<
typename BasisType1,
typename BasisType2>
1047 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
basis1.dimension(),
basis2.dimension());
1070template<
typename BasisType1,
typename BasisType2>
1082template<
typename BasisType1,
typename BasisType2,
size_t N>
1090 Eigen::MatrixXd
gm = Eigen::MatrixXd::Zero(
basis1.dimension(),
basis2.dimension());
1108 for (
size_t i=0;
i <
N;
i++){
1112 return gm/(std::pow(T.diam(),2));
Basis for the space of curls of polynomials.
Definition basis.hpp:1318
Basis (or rather family) of divergence of an existing basis.
Definition basis.hpp:1381
Family of functions expressed as linear combination of the functions of a given basis.
Definition basis.hpp:389
Basis for the complement G^{c,k}(T) in P^k(T)^3 of the range of grad.
Definition basis.hpp:1531
Basis for the space of gradients of polynomials.
Definition basis.hpp:1256
Matrix family obtained from a scalar family.
Definition basis.hpp:778
Scalar monomial basis on a cell.
Definition basis.hpp:155
Generate a basis restricted to the first "dimension" functions.
Definition basis.hpp:1147
Basis for the complement R^{c,k}(T) in P^k(T)^3 of the range of curl.
Definition basis.hpp:1460
Generate a basis where the function indices are shifted.
Definition basis.hpp:1040
Vector family obtained by tensorization of a scalar family.
Definition basis.hpp:610
constexpr int dimspace
Dimension, and generic types for vector in correct dimension (makes it easier to translate a code bet...
Definition basis.hpp:50
@ Matrix
Definition basis.hpp:67
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 GramMatrixDiv(const Cell &T, const TensorizedVectorFamily< BasisType1, N > &basis1, const MonomialScalarBasisCell &basis2, MonomialCellIntegralsType mono_int_map={})
Template to compute the Gram Matrix of a Divergence<Tensorized> basis and a monomial scalar basis.
Definition GMpoly_cell.hpp:903
Eigen::MatrixXd GramMatrixCurlCurl(const Cell &T, const TensorizedVectorFamily< BasisType1, N > &basis1, const TensorizedVectorFamily< BasisType2, N > &basis2, MonomialCellIntegralsType mono_int_map={})
Template to compute the Gram Matrix of the curl of a tensorized basis and the curl of another tensori...
Definition GMpoly_cell.hpp:536
Eigen::MatrixXd GramMatrixDivDiv(const Cell &T, const TensorizedVectorFamily< BasisType1, N > &basis1, const TensorizedVectorFamily< BasisType2, N > &basis2, MonomialCellIntegralsType mono_int_map={})
Template to compute the Gram Matrix of the divergence of a tensorized basis and the divergence of ano...
Definition GMpoly_cell.hpp:788
Eigen::MatrixXd GMScalarDerivative(const Cell &T, const MonomialScalarBasisCell &basis1, const MonomialScalarBasisCell &basis2, const size_t m, MonomialCellIntegralsType mono_int_map={})
Computes the Gram Matrix of a pair of local scalar monomial bases, taking a partial derivative of the...
Definition GMpoly_cell.cpp:244
MonomialCellIntegralsType IntegrateCellMonomials(const Cell &T, const int maxdeg)
Compute all the integrals of a cell's monomials on the cell.
Definition GMpoly_cell.cpp:117
Eigen::MatrixXd GMGolyComplScalar(const Cell &T, const GolyComplBasisCell &golycompl_basis, const MonomialScalarBasisCell &mono_basis, const size_t s, MonomialCellIntegralsType mono_int_map, const size_t m=3, const size_t k1=3, const size_t k2=3)
Computes the Gram Matrix of the sth section of a GolyCompl Basis and a monomial basis.
Definition GMpoly_cell.cpp:321
Eigen::MatrixXd GMRolyComplScalarDiv(const Cell &T, const MonomialScalarBasisCell &mono_basis, const RolyComplBasisCell &rolycompl_basis, const size_t k, MonomialCellIntegralsType mono_int_map)
Gram Matrix of the divergence of a RolyCompl Basis and the kth derivative of a monomial basis.
Definition GMpoly_cell.cpp:506
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
size_t operator()(const VectorZd &p) const
Definition GMpoly_cell.hpp:41
std::vector< MonomialCellIntegralsType > IntegrateCellMonomials_onEdges(const Cell &T, const size_t maxdeg)
Compute all the integrals, on the edges of a cell, of this cell's monomials up to a max degree.
Definition GMpoly_cell.cpp:7
Eigen::MatrixXd GramMatrixCurl(const Cell &T, const TensorizedVectorFamily< BasisType1, N > &basis1, const TensorizedVectorFamily< BasisType2, N > &basis2, MonomialCellIntegralsType mono_int_map={})
Template to compute the Gram Matrix of a Curl<Tensorized> basis and a tensorized scalar basis.
Definition GMpoly_cell.hpp:648
Eigen::MatrixXd GMGolyCompl(const Cell &T, const GolyComplBasisCell &basis1, const GolyComplBasisCell &basis2, const size_t s1, const size_t s2, MonomialCellIntegralsType mono_int_map, const size_t m1=3, const size_t m2=3, const size_t k1=3, const size_t k2=3)
Computes the Gram Matrix of the (optionally k1th derivative of the) s1th section of GolyCompl (option...
Definition GMpoly_cell.cpp:362
Eigen::MatrixXd GMRolyComplScalar(const Cell &T, const RolyComplBasisCell &rolycompl_basis, const MonomialScalarBasisCell &mono_basis, const size_t m, MonomialCellIntegralsType mono_int_map={})
Computes the Gram Matrix of the mth component of a RolyCompl Basis and a monomial basis.
Definition GMpoly_cell.cpp:298
constexpr bool useAncestor()
Determines if the ancestor of a basis will be used to compute a Gram matrix for this basis.
Definition GMpoly_cell.hpp:335
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
std::unordered_map< VectorZd, double, VecHash > MonomialCellIntegralsType
Type for list of integrals of monomials.
Definition GMpoly_cell.hpp:49
std::vector< MonomialCellIntegralsType > IntegrateCellMonomials_onFaces(const Cell &T, const size_t maxdeg, std::vector< MonomialCellIntegralsType > &integrals_edges)
Compute all the integrals, on the faces of a cell, of this cell's monomials up to a max degree.
Definition GMpoly_cell.cpp:61
Definition ddr-magnetostatics.hpp:41
Hash function for VectorZd type.
Definition GMpoly_cell.hpp:40