HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge and cell polynomials as unknowns
Loading...
Searching...
No Matches
excurl.hpp
Go to the documentation of this file.
1#ifndef EXCURL_HPP
2#define EXCURL_HPP
3
4#include <xcurl.hpp>
5
6namespace HArDCore2D
7{
14
18 class EXCurl : public GlobalDOFSpace
19 {
20 public:
21 typedef std::function<Eigen::Vector2d(const Eigen::Vector2d &)> FunctionType;
24
27 {
29 const Eigen::MatrixXd & _gradient,
30 const Eigen::MatrixXd & _symmetric_gradient,
31 const Eigen::MatrixXd & _potential,
32 const Eigen::MatrixXd & _stabilisation
33 )
34 : gradient(_gradient),
35 symmetric_gradient(_symmetric_gradient),
36 potential(_potential),
37 stabilisation(_stabilisation)
38 {
39 // Do nothing
40 }
41
42 Eigen::MatrixXd gradient;
43 Eigen::MatrixXd symmetric_gradient;
44 Eigen::MatrixXd potential;
45 Eigen::MatrixXd stabilisation;
46 };
47
49 EXCurl(const DDRCore & ddr_core, bool use_threads = true, std::ostream & output = std::cout);
50
52 const Mesh & mesh() const
53 {
54 return m_ddr_core.mesh();
55 }
56
58 const size_t & degree() const
59 {
60 return m_ddr_core.degree();
61 }
62
64 Eigen::VectorXd interpolate(
65 const FunctionType & v,
66 const int deg_quad = -1
67 ) const;
68
70 // We don't store the potential and curl, as they are very cheap to construct from the (stored) operators in m_xcurl
71 inline const Eigen::MatrixXd ddrPotential(size_t iT) const
72 {
73 return m_xcurl.cellOperators(iT).potential * m_reduction[iT];
74 };
75
77 inline const Eigen::MatrixXd ddrCurl(size_t iT) const
78 {
79 return m_xcurl.cellOperators(iT).curl * m_reduction[iT];
80 };
81
83 inline const Eigen::MatrixXd ddrPotential(const Cell & T) const
84 {
85 return ddrPotential(T.global_index());
86 };
87
89 inline const Eigen::MatrixXd ddrCurl(const Cell & T) const
90 {
91 return ddrCurl(T.global_index());
92 };
93
95 inline const hhoLocalOperators & hhoOperators(size_t iT) const
96 {
97 assert( m_hho_operators[iT] );
98 return *m_hho_operators[iT];
99 }
100
102 inline const hhoLocalOperators & hhoOperators(const Cell & T) const
103 {
104 return * m_hho_operators[T.global_index()];
105 }
106
108 inline const DDRCore::CellBases & cellBases(size_t iT) const
109 {
110 return m_ddr_core.cellBases(iT);
111 }
112
114 inline const DDRCore::CellBases & cellBases(const Cell & T) const
115 {
116 return m_ddr_core.cellBases(T.global_index());
117 }
118
120 inline const Polyk2x2Type & Polyk2x2(size_t iT) const
121 {
122 // Make sure that the basis has been created
123 assert( m_Polyk2x2[iT] );
124 return *m_Polyk2x2[iT].get();
125 }
126
128 inline const Polykpo2Type & Polykpo2(size_t iT) const
129 {
130 // Make sure that the basis has been created
131 assert( m_Polykpo2[iT] );
132 return *m_Polykpo2[iT].get();
133 }
134
136 inline const DDRCore::EdgeBases & edgeBases(size_t iE) const
137 {
138 return m_ddr_core.edgeBases(iE);
139 }
140
142 inline const DDRCore::EdgeBases & edgeBases(const Edge & E) const
143 {
144 return m_ddr_core.edgeBases(E.global_index());
145 }
146
148 // The mass matrix of P^k(T)^2 is the most expensive mass matrix in the calculation of this norm, which
149 // is why there's the option of passing it as parameter if it's been already pre-computed when the norm is called.
150 Eigen::MatrixXd computeL2Product(
151 const size_t iT,
152 const double & penalty_factor = 1.,
153 const Eigen::MatrixXd & mass_Pk2_T = Eigen::MatrixXd::Zero(1,1),
154 const IntegralWeight & weight = IntegralWeight(1.)
155 ) const;
156
158 Eigen::MatrixXd computeL2ProductGradient(
159 const size_t iT,
160 const XGrad & x_grad,
161 const std::string & side,
162 const double & penalty_factor = 1.,
163 const Eigen::MatrixXd & mass_Pk2_T = Eigen::MatrixXd::Zero(1,1),
164 const IntegralWeight & weight = IntegralWeight(1.)
165 ) const;
166
169 const size_t iT,
170 const std::vector<Eigen::MatrixXd> & leftOp,
171 const std::vector<Eigen::MatrixXd> & rightOp,
172 const double & penalty_factor,
173 const Eigen::MatrixXd & w_mass_Pk2_T,
174 const IntegralWeight & weight
175 ) const;
176
177
178 private:
179 hhoLocalOperators _compute_hho_operators(size_t iT);
180
181 const DDRCore & m_ddr_core;
182 const XCurl m_xcurl; // Underlying standard XCurl space
183 std::vector<std::unique_ptr<Polyk2x2Type> > m_Polyk2x2;
184 std::vector<std::unique_ptr<Polykpo2Type> > m_Polykpo2;
185 std::vector<Eigen::MatrixXd> m_reduction; // reduction matrix to go from EXcurl DOFs to XCurl DOFs
186 bool m_use_threads;
187 std::ostream & m_output;
188
189 // Containers for local hho operators
190 std::vector<std::unique_ptr<hhoLocalOperators> > m_hho_operators;
191 };
192
193} // end of namespace HArDCore2D
194#endif
Construct all polynomial spaces for the DDR sequence.
Definition ddrcore.hpp:63
Extended XCurl space, with vector-valued polynomials on the edges.
Definition excurl.hpp:19
Base class for global DOF spaces. Provides functions to manipulate global DOFs (the local version bei...
Definition globaldofspace.hpp:16
Matrix family obtained from a scalar family.
Definition basis.hpp:719
Vector family obtained by tensorization of a scalar family.
Definition basis.hpp:559
Discrete Hcurl space: local operators, L2 product and global interpolator.
Definition xcurl.hpp:18
Discrete H1 space: local operators, L2 product and global interpolator.
Definition xgrad.hpp:17
Definition Mesh2D.hpp:26
std::function< Eigen::Vector2d(const Eigen::Vector2d &)> FunctionType
Definition excurl.hpp:21
const DDRCore::CellBases & cellBases(size_t iT) const
Return ddrcore cell bases for the cell of index iT.
Definition excurl.hpp:108
Eigen::MatrixXd computeL2Product_with_Ops(const size_t iT, const std::vector< Eigen::MatrixXd > &leftOp, const std::vector< Eigen::MatrixXd > &rightOp, const double &penalty_factor, const Eigen::MatrixXd &w_mass_Pk2_T, const IntegralWeight &weight) const
Compute the matrix of the L2 product, applying leftOp and rightOp to the variables....
const DDRCore::EdgeBases & edgeBases(size_t iE) const
Return ddrcore edge bases for the edge of index iE.
Definition excurl.hpp:136
const Mesh & mesh() const
Return a const reference to the mesh.
Definition ddrcore.hpp:115
const Eigen::MatrixXd ddrCurl(size_t iT) const
Return cell (scalar) curl for the cell of index iT.
Definition excurl.hpp:77
TensorizedVectorFamily< DDRCore::PolyBasisCellType, dimspace > Polykpo2Type
Definition excurl.hpp:23
const size_t & degree() const
Return the polynomial degree.
Definition ddrcore.hpp:121
const hhoLocalOperators & hhoOperators(const Cell &T) const
Return cell operators for cell T.
Definition excurl.hpp:102
Eigen::MatrixXd potential
Definition xcurl.hpp:36
Eigen::MatrixXd symmetric_gradient
Definition excurl.hpp:43
Eigen::MatrixXd computeL2Product(const size_t iT, const double &penalty_factor=1., const Eigen::MatrixXd &mass_Pk2_T=Eigen::MatrixXd::Zero(1, 1), const IntegralWeight &weight=IntegralWeight(1.)) const
Compute the matrix of the (weighted) L2-product for the cell of index iT.
Definition excurl.cpp:323
const Mesh & mesh() const
Return the mesh.
Definition excurl.hpp:52
Eigen::MatrixXd gradient
Definition excurl.hpp:42
const LocalOperators & cellOperators(size_t iT) const
Return cell operators for the cell of index iT.
Definition xcurl.hpp:61
const size_t & degree() const
Return the polynomial degree.
Definition excurl.hpp:58
const Polykpo2Type & Polykpo2(size_t iT) const
Return basis for the (P^{k+1})^2 space.
Definition excurl.hpp:128
const CellBases & cellBases(size_t iT) const
Return cell bases for element iT.
Definition ddrcore.hpp:127
Eigen::MatrixXd computeL2ProductGradient(const size_t iT, const XGrad &x_grad, const std::string &side, const double &penalty_factor=1., const Eigen::MatrixXd &mass_Pk2_T=Eigen::MatrixXd::Zero(1, 1), const IntegralWeight &weight=IntegralWeight(1.)) const
Compute the matrix of the (weighted) L2-product as 'computeL2Product', with application of the discre...
Definition excurl.cpp:333
hhoLocalOperators(const Eigen::MatrixXd &_gradient, const Eigen::MatrixXd &_symmetric_gradient, const Eigen::MatrixXd &_potential, const Eigen::MatrixXd &_stabilisation)
Definition excurl.hpp:28
const Eigen::MatrixXd ddrPotential(size_t iT) const
Return cell potential for the cell of index iT.
Definition excurl.hpp:71
const Eigen::MatrixXd ddrPotential(const Cell &T) const
Return cell potential for cell T.
Definition excurl.hpp:83
MatrixFamily< DDRCore::PolyBasisCellType, dimspace > Polyk2x2Type
Definition excurl.hpp:22
const DDRCore::CellBases & cellBases(const Cell &T) const
Return ddrcore cell bases for cell T.
Definition excurl.hpp:114
Eigen::MatrixXd stabilisation
Definition excurl.hpp:45
Eigen::VectorXd interpolate(const FunctionType &v, const int deg_quad=-1) const
Interpolator of a continuous function.
Definition excurl.cpp:60
const EdgeBases & edgeBases(size_t iE) const
Return edge bases for edge iE.
Definition ddrcore.hpp:135
const DDRCore::EdgeBases & edgeBases(const Edge &E) const
Return ddrcore edge bases for edge E.
Definition excurl.hpp:142
const Eigen::MatrixXd ddrCurl(const Cell &T) const
Return cell (scalar) curl for cell T.
Definition excurl.hpp:89
const Polyk2x2Type & Polyk2x2(size_t iT) const
Return basis for Matricial P^k space.
Definition excurl.hpp:120
Eigen::MatrixXd potential
Definition excurl.hpp:44
const hhoLocalOperators & hhoOperators(size_t iT) const
Return hho operators for the cell of index iT.
Definition excurl.hpp:95
Eigen::MatrixXd curl
Definition xcurl.hpp:35
bool use_threads
Definition HHO_DiffAdvecReac.hpp:47
if(strcmp(field, 'real')) % real valued entries T
Definition mmread.m:93
Definition ddr-klplate.hpp:27
static auto v
Definition ddrcore-test.hpp:32
Structure to store element bases.
Definition ddrcore.hpp:81
Structure to store edge bases.
Definition ddrcore.hpp:102
A structure to store the local HHO operators.
Definition excurl.hpp:27
Structure for weights (scalar, at the moment) in integral.
Definition integralweight.hpp:33