HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
Loading...
Searching...
No Matches
lasxgrad.hpp
Go to the documentation of this file.
1#ifndef LASXGRAD_HPP
2#define LASXGRAD_HPP
3
4#include <sxgrad.hpp>
5#include <liealgebra.hpp>
6#include <unsupported/Eigen/KroneckerProduct>
7
8namespace HArDCore3D
9{
16
18 {
19 public:
20 typedef std::function<double(const Eigen::Vector3d &)> FunctionType;
21 typedef std::vector<FunctionType> LAFunctionType;
22
24
26 {
28 const Eigen::MatrixXd & _serendipity,
29 const Eigen::MatrixXd & _extension,
30 const Eigen::MatrixXd & _reduction
31 )
35 {
36 // Do nothing
37 }
38
39 Eigen::MatrixXd serendipity;
40 Eigen::MatrixXd extension;
41 Eigen::MatrixXd reduction;
42 };
43
45 LASXGrad(const LieAlgebra & lie_algebra, const SXGrad & sxgrad, bool use_threads = true, std::ostream & output = std::cout);
46
48 const Mesh & mesh() const
49 {
50 return m_sxgrad.mesh();
51 }
52
54 const size_t & degree() const
55 {
56 return m_sxgrad.degree();
57 }
58
60 inline const LieAlgebra & lieAlg() const
61 {
62 return m_lie_algebra;
63 }
64
66 const SerendipityProblem & serPro() const
67 {
68 return m_sxgrad.serPro();
69 }
70
72 Eigen::VectorXd interpolate(
73 const LAFunctionType & q,
74 const int doe_cell = -1,
75 const int doe_face = -1,
76 const int doe_edge = -1
77 ) const;
78
79 //---------------------------------//
80 //---- Face transfer operators-----//
81
83 inline const Eigen::MatrixXd & SgradFace(size_t iF) const
84 {
85 return (*m_face_transfer_operators[iF]).serendipity;
86 }
87
89 inline const Eigen::MatrixXd & EgradFace(size_t iF) const
90 {
91 return (*m_face_transfer_operators[iF]).extension;
92 }
93
95 inline const Eigen::MatrixXd & RgradFace(size_t iF) const
96 {
97 return (*m_face_transfer_operators[iF]).reduction;
98 }
99
101 inline const Eigen::MatrixXd & SgradFace(const Face & F) const
102 {
103 return SgradFace(F.global_index());
104 }
105
107 inline const Eigen::MatrixXd & EgradFace(const Face & F) const
108 {
109 return EgradFace(F.global_index());
110 }
111
113 inline const Eigen::MatrixXd & RgradFace(const Face & F) const
114 {
115 return RgradFace(F.global_index());
116 }
117
118 //---------------------------------//
119 //---- Cell transfer operators -----//
121 inline const Eigen::MatrixXd & SgradCell(size_t iT) const
122 {
123 return (*m_cell_transfer_operators[iT]).serendipity;
124 }
125
127 inline const Eigen::MatrixXd & EgradCell(size_t iT) const
128 {
129 return (*m_cell_transfer_operators[iT]).extension;
130 }
131
133 inline const Eigen::MatrixXd & RgradCell(size_t iT) const
134 {
135 return (*m_cell_transfer_operators[iT]).reduction;
136 }
137
139 inline const Eigen::MatrixXd & SgradCell(const Cell & T) const
140 {
141 return SgradCell(T.global_index());
142 }
143
145 inline const Eigen::MatrixXd & EgradCell(const Cell & T) const
146 {
147 return EgradCell(T.global_index());
148 }
149
151 inline const Eigen::MatrixXd & RgradCell(const Cell & T) const
152 {
153 return RgradCell(T.global_index());
154 }
155
156 //---------------------------------------------------------------------//
157 //---- Full gradient and potential reconstructions, and L2 product ----//
158
160 inline const Eigen::MatrixXd edgeGradient(size_t iE) const
161 {
162 Eigen::MatrixXd id = Eigen::MatrixXd::Identity(m_lie_algebra.dimension(), m_lie_algebra.dimension());
163 return Eigen::KroneckerProduct(m_sxgrad.edgeGradient(iE), id);
164 }
165
167 inline const Eigen::MatrixXd edgeGradient(const Edge & E) const
168 {
169 return edgeGradient(E.global_index());
170 }
171
173 inline const Eigen::MatrixXd edgePotential(size_t iE) const
174 {
175 Eigen::MatrixXd id = Eigen::MatrixXd::Identity(m_lie_algebra.dimension(), m_lie_algebra.dimension());
176 return Eigen::KroneckerProduct(m_sxgrad.edgePotential(iE), id);
177 }
178
180 inline const Eigen::MatrixXd edgePotential(const Edge & E) const
181 {
182 return edgePotential(E.global_index());
183 }
184
186 inline const Eigen::MatrixXd faceGradient(size_t iF) const
187 {
188 Eigen::MatrixXd id = Eigen::MatrixXd::Identity(m_lie_algebra.dimension(), m_lie_algebra.dimension());
189 return Eigen::KroneckerProduct(m_sxgrad.faceGradient(iF), id);
190 }
191
193 inline const Eigen::MatrixXd faceGradient(const Face & F) const
194 {
195 return faceGradient(F.global_index());
196 }
197
199 inline const Eigen::MatrixXd facePotential(size_t iF) const
200 {
201 Eigen::MatrixXd id = Eigen::MatrixXd::Identity(m_lie_algebra.dimension(), m_lie_algebra.dimension());
202 return Eigen::KroneckerProduct(m_sxgrad.facePotential(iF), id);
203 }
204
206 inline const Eigen::MatrixXd facePotential(const Face & F) const
207 {
208 return facePotential(F.global_index());
209 }
210
212 inline const Eigen::MatrixXd cellGradient(size_t iT) const
213 {
214 Eigen::MatrixXd id = Eigen::MatrixXd::Identity(m_lie_algebra.dimension(), m_lie_algebra.dimension());
215 return Eigen::KroneckerProduct(m_sxgrad.cellGradient(iT), id);
216 }
217
219 inline const Eigen::MatrixXd cellGradient(const Cell & T) const
220 {
221 return cellGradient(T.global_index());
222 }
223
225 inline const Eigen::MatrixXd cellPotential(size_t iT) const
226 {
227 Eigen::MatrixXd id = Eigen::MatrixXd::Identity(m_lie_algebra.dimension(), m_lie_algebra.dimension());
228 return Eigen::KroneckerProduct(m_sxgrad.cellPotential(iT), id);
229 }
230
232 inline const Eigen::MatrixXd cellPotential(const Cell & T) const
233 {
234 return cellPotential(T.global_index());
235 }
236
238 Eigen::MatrixXd computeL2Product(
239 const size_t iT,
240 const double & penalty_factor = 1.,
241 const Eigen::MatrixXd & mass_Pk3_T = Eigen::MatrixXd::Zero(1,1),
243 ) const
244 {
245 return Eigen::KroneckerProduct(m_sxgrad.computeL2Product(iT,penalty_factor,mass_Pk3_T, weight), m_lie_algebra.massMatrix());
246 }
247
248
249 //-----------------------//
250 //---- Getters ----------//
251
253 inline const DDRCore::CellBases & cellBases(size_t iT) const
254 {
255 return m_sxgrad.cellBases(iT);
256 }
257
259 inline const DDRCore::CellBases & cellBases(const Cell & T) const
260 {
261 return m_sxgrad.cellBases(T.global_index());
262 }
263
265 inline const DDRCore::FaceBases & faceBases(size_t iF) const
266 {
267 return m_sxgrad.faceBases(iF);
268 }
269
271 inline const DDRCore::FaceBases & faceBases(const Face & F) const
272 {
273 return m_sxgrad.faceBases(F.global_index());
274 }
275
277 inline const DDRCore::EdgeBases & edgeBases(size_t iE) const
278 {
279 return m_sxgrad.edgeBases(iE);
280 }
281
283 inline const DDRCore::EdgeBases & edgeBases(const Edge & E) const
284 {
285 return m_sxgrad.edgeBases(E.global_index());
286 }
287
288 private:
289 TransferOperators _compute_face_transfer_operators(size_t iF);
290 TransferOperators _compute_cell_transfer_operators(size_t iT);
291
292 const LieAlgebra & m_lie_algebra;
293 const SXGrad & m_sxgrad;
294
295 // Containers for serendipity, extension and reduction operators
296 std::vector<std::unique_ptr<TransferOperators> > m_face_transfer_operators;
297 std::vector<std::unique_ptr<TransferOperators> > m_cell_transfer_operators;
298
299 bool m_use_threads;
300 std::ostream & m_output;
301
302 };
303
304} // end of namespace HArDCore3D
305#endif
Discrete Serendipity Hgrad space: local operators, L2 product and global interpolator.
Definition lasxgrad.hpp:18
Lie algebra class: mass matrix, structure constants and Lie bracket.
Definition liealgebra.hpp:17
Discrete Serendipity Hgrad space: local operators, L2 product and global interpolator.
Definition sxgrad.hpp:20
Construct all polynomial spaces for the DDR sequence.
Definition serendipity_problem.hpp:40
Base class for global DOF spaces.
Definition variabledofspace.hpp:17
Class to describe a mesh.
Definition MeshND.hpp:17
@ Matrix
Definition basis.hpp:67
const size_t & degree() const
Return the polynomial degree.
Definition sxgrad.hpp:55
const Eigen::MatrixXd edgePotential(size_t iE) const
Return the potential operator on the edge of index iE.
Definition sxgrad.hpp:166
const Mesh & mesh() const
Return the mesh.
Definition sxgrad.hpp:49
const Eigen::MatrixXd facePotential(size_t iF) const
Return the potential operator on the face of index iF.
Definition sxgrad.hpp:190
const SerendipityProblem & serPro() const
Definition sxgrad.hpp:60
const Eigen::MatrixXd cellPotential(size_t iT) const
Return the potential operator on the cell of index iT.
Definition sxgrad.hpp:214
Eigen::MatrixXd computeL2Product(const size_t iT, const double &penalty_factor=1., const Eigen::MatrixXd &mass_Pkpo_T=Eigen::MatrixXd::Zero(1, 1), const IntegralWeight &weight=IntegralWeight(1.)) const
Compute the matrix of the (weighted) L2-product.
Definition sxgrad.hpp:226
const Eigen::MatrixXd edgeGradient(size_t iE) const
Return the full gradient operator on the edge of index iE.
Definition sxgrad.hpp:154
const DDRCore::CellBases & cellBases(size_t iT) const
Return cell bases for the face of index iT.
Definition sxgrad.hpp:260
const Eigen::MatrixXd faceGradient(size_t iF) const
Return the full gradient operator on the face of index iF.
Definition sxgrad.hpp:178
const Eigen::MatrixXd cellGradient(size_t iT) const
Return the full gradient operator on the cell of index iT.
Definition sxgrad.hpp:202
const DDRCore::EdgeBases & edgeBases(size_t iE) const
Return edge bases for the edge of index iE.
Definition sxgrad.hpp:284
const DDRCore::FaceBases & faceBases(size_t iF) const
Return face bases for the face of index iF.
Definition sxgrad.hpp:272
bool use_threads
Definition HHO_DiffAdvecReac.hpp:47
const LieAlgebra & lieAlg() const
Return the Lie algebra.
Definition lasxgrad.hpp:60
const Eigen::MatrixXd & RgradCell(size_t iT) const
Return the reduction for the cell of index iT.
Definition lasxgrad.hpp:133
const size_t & degree() const
Return the polynomial degree.
Definition lasxgrad.hpp:54
const Eigen::MatrixXd cellPotential(size_t iT) const
Return the potential operator on the cell of index iT.
Definition lasxgrad.hpp:225
const Eigen::MatrixXd edgePotential(const Edge &E) const
Return the potential operator on edge E.
Definition lasxgrad.hpp:180
const Eigen::MatrixXd facePotential(const Face &F) const
Return the potential operator on face F.
Definition lasxgrad.hpp:206
const Eigen::MatrixXd & SgradFace(size_t iF) const
Return the serendipity reconstruction for the face of index iF.
Definition lasxgrad.hpp:83
std::function< double(const Eigen::Vector3d &)> FunctionType
Definition lasxgrad.hpp:20
const Eigen::MatrixXd & SgradCell(const Cell &T) const
Return the serendipity reconstruction for cell T.
Definition lasxgrad.hpp:139
const Eigen::MatrixXd faceGradient(size_t iF) const
Return the full gradient operator on the face of index iF.
Definition lasxgrad.hpp:186
const Eigen::MatrixXd & EgradCell(size_t iT) const
Return the extension for the cell of index iT.
Definition lasxgrad.hpp:127
const DDRCore::EdgeBases & edgeBases(size_t iE) const
Return edge bases for the edge of index iE.
Definition lasxgrad.hpp:277
const Eigen::MatrixXd edgeGradient(size_t iE) const
Return the full gradient operator on the edge of index iE.
Definition lasxgrad.hpp:160
const Eigen::MatrixXd cellGradient(const Cell &T) const
Return the full gradient operator on cell T.
Definition lasxgrad.hpp:219
const Eigen::MatrixXd faceGradient(const Face &F) const
Return the full gradient operator on face F.
Definition lasxgrad.hpp:193
const Eigen::MatrixXd edgeGradient(const Edge &E) const
Return the full gradient operator on edge E.
Definition lasxgrad.hpp:167
Eigen::VectorXd interpolate(const LAFunctionType &q, const int doe_cell=-1, const int doe_face=-1, const int doe_edge=-1) const
Interpolator of a continuous function.
Definition lasxgrad.cpp:61
Eigen::MatrixXd reduction
Definition lasxgrad.hpp:41
const DDRCore::FaceBases & faceBases(const Face &F) const
Return cell bases for face F.
Definition lasxgrad.hpp:271
Eigen::MatrixXd computeL2Product(const size_t iT, const double &penalty_factor=1., const Eigen::MatrixXd &mass_Pk3_T=Eigen::MatrixXd::Zero(1, 1), const IntegralWeight &weight=IntegralWeight(1.)) const
Compute the matrix of the (weighted) L2-product.
Definition lasxgrad.hpp:238
const Eigen::MatrixXd cellPotential(const Cell &T) const
Return the potential operator on cell T.
Definition lasxgrad.hpp:232
const Eigen::MatrixXd cellGradient(size_t iT) const
Return the full gradient operator on the cell of index iT.
Definition lasxgrad.hpp:212
TransferOperators(const Eigen::MatrixXd &_serendipity, const Eigen::MatrixXd &_extension, const Eigen::MatrixXd &_reduction)
Definition lasxgrad.hpp:27
const Eigen::MatrixXd & EgradFace(const Face &F) const
Return the extension for face F.
Definition lasxgrad.hpp:107
const Eigen::MatrixXd & massMatrix() const
Returns the Gram matrix of the Lie algebra.
Definition liealgebra.hpp:40
const Eigen::MatrixXd & EgradCell(const Cell &T) const
Return the extension for cell T.
Definition lasxgrad.hpp:145
const size_t dimension() const
Assuming orthonormal basis.
Definition liealgebra.hpp:28
const Eigen::MatrixXd & SgradCell(size_t iT) const
Return the serendipity reconstruction for the cell of index iT.
Definition lasxgrad.hpp:121
const SerendipityProblem & serPro() const
Return the serendipity operators.
Definition lasxgrad.hpp:66
Eigen::MatrixXd extension
Definition lasxgrad.hpp:40
Eigen::MatrixXd serendipity
Definition lasxgrad.hpp:39
std::vector< FunctionType > LAFunctionType
Definition lasxgrad.hpp:21
const DDRCore::FaceBases & faceBases(size_t iF) const
Return face bases for the face of index iF.
Definition lasxgrad.hpp:265
const Eigen::MatrixXd & EgradFace(size_t iF) const
Return the extension for the face of index iF.
Definition lasxgrad.hpp:89
const Eigen::MatrixXd & RgradFace(size_t iF) const
Return the reduction for the face of index iF.
Definition lasxgrad.hpp:95
const DDRCore::EdgeBases & edgeBases(const Edge &E) const
Return edge bases for edge E.
Definition lasxgrad.hpp:283
const Eigen::MatrixXd & RgradCell(const Cell &T) const
Return the reduction for cell T.
Definition lasxgrad.hpp:151
const DDRCore::CellBases & cellBases(const Cell &T) const
Return cell bases for cell T.
Definition lasxgrad.hpp:259
const Eigen::MatrixXd & RgradFace(const Face &F) const
Return cell reduction for cell T.
Definition lasxgrad.hpp:113
const Mesh & mesh() const
Return the mesh.
Definition lasxgrad.hpp:48
const DDRCore::CellBases & cellBases(size_t iT) const
Return cell bases for the face of index iT.
Definition lasxgrad.hpp:253
const Eigen::MatrixXd & SgradFace(const Face &F) const
Return the serendipity reconstruction for face F.
Definition lasxgrad.hpp:101
const Eigen::MatrixXd facePotential(size_t iF) const
Return the potential operator on the face of index iF.
Definition lasxgrad.hpp:199
const Eigen::MatrixXd edgePotential(size_t iE) const
Return the potential operator on the edge of index iE.
Definition lasxgrad.hpp:173
Definition ddr-magnetostatics.hpp:41
Structure to store element bases.
Definition ddrcore.hpp:86
Structure to store edge bases.
Definition ddrcore.hpp:121
Structure to store face bases.
Definition ddrcore.hpp:105
Structure for weights (scalar, at the moment) in integral.
Definition integralweight.hpp:36
A structure to store the serendipity, extension and reduction operators.
Definition lasxgrad.hpp:26