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
sxgrad.hpp
Go to the documentation of this file.
1#ifndef SXGRAD_HPP
2#define SXGRAD_HPP
3
5#include <ddrcore.hpp>
6#include <integralweight.hpp>
7#include <xgrad.hpp>
9
10namespace HArDCore3D
11{
18
19 class SXGrad : public VariableDOFSpace
20 {
21 public:
22 typedef std::function<double(const Eigen::Vector3d &)> FunctionType;
23
25
27 {
29 const Eigen::MatrixXd & _serendipity,
30 const Eigen::MatrixXd & _extension,
31 const Eigen::MatrixXd & _reduction
32 )
36 {
37 // Do nothing
38 }
39
40 Eigen::MatrixXd serendipity;
41 Eigen::MatrixXd extension;
42 Eigen::MatrixXd reduction;
43 };
44
46 SXGrad(const DDRCore & ddr_core, const SerendipityProblem & ser_pro, bool use_threads = true, std::ostream & output = std::cout);
47
49 const Mesh & mesh() const
50 {
51 return m_ddr_core.mesh();
52 }
53
55 const size_t & degree() const
56 {
57 return m_ddr_core.degree();
58 }
59
60 const SerendipityProblem & serPro() const
61 {
62 return m_ser_pro;
63 }
64
66 Eigen::VectorXd interpolate(
67 const FunctionType & q,
68 const int doe_cell = -1,
69 const int doe_face = -1,
70 const int doe_edge = -1
71 ) const;
72
73 //---------------------------------//
74 //---- Face transfer operators-----//
75
77 inline const Eigen::MatrixXd & SgradFace(size_t iF) const
78 {
79 return (*m_face_transfer_operators[iF]).serendipity;
80 }
81
83 inline const Eigen::MatrixXd & EgradFace(size_t iF) const
84 {
85 return (*m_face_transfer_operators[iF]).extension;
86 }
87
89 inline const Eigen::MatrixXd & RgradFace(size_t iF) const
90 {
91 return (*m_face_transfer_operators[iF]).reduction;
92 }
93
95 inline const Eigen::MatrixXd & SgradFace(const Face & F) const
96 {
97 return SgradFace(F.global_index());
98 }
99
101 inline const Eigen::MatrixXd & EgradFace(const Face & F) const
102 {
103 return EgradFace(F.global_index());
104 }
105
107 inline const Eigen::MatrixXd & RgradFace(const Face & F) const
108 {
109 return RgradFace(F.global_index());
110 }
111
112 //---------------------------------//
113 //---- Cell transfer operators -----//
115 inline const Eigen::MatrixXd & SgradCell(size_t iT) const
116 {
117 return (*m_cell_transfer_operators[iT]).serendipity;
118 }
119
121 inline const Eigen::MatrixXd & EgradCell(size_t iT) const
122 {
123 return (*m_cell_transfer_operators[iT]).extension;
124 }
125
127 inline const Eigen::MatrixXd & RgradCell(size_t iT) const
128 {
129 return (*m_cell_transfer_operators[iT]).reduction;
130 }
131
133 inline const Eigen::MatrixXd & SgradCell(const Cell & T) const
134 {
135 return SgradCell(T.global_index());
136 }
137
139 inline const Eigen::MatrixXd & EgradCell(const Cell & T) const
140 {
141 return EgradCell(T.global_index());
142 }
143
145 inline const Eigen::MatrixXd & RgradCell(const Cell & T) const
146 {
147 return RgradCell(T.global_index());
148 }
149
150 //---------------------------------------------------------------------//
151 //---- Full gradient and potential reconstructions, and L2 product ----//
152
154 inline const Eigen::MatrixXd edgeGradient(size_t iE) const
155 {
156 return m_xgrad.edgeOperators(iE).gradient;
157 }
158
160 inline const Eigen::MatrixXd edgeGradient(const Edge & E) const
161 {
162 return edgeGradient(E.global_index());
163 }
164
166 inline const Eigen::MatrixXd edgePotential(size_t iE) const
167 {
168 return m_xgrad.edgeOperators(iE).potential;
169 }
170
172 inline const Eigen::MatrixXd edgePotential(const Edge & E) const
173 {
174 return edgePotential(E.global_index());
175 }
176
178 inline const Eigen::MatrixXd faceGradient(size_t iF) const
179 {
180 return m_xgrad.faceOperators(iF).gradient * EgradFace(iF);
181 }
182
184 inline const Eigen::MatrixXd faceGradient(const Face & F) const
185 {
186 return faceGradient(F.global_index());
187 }
188
190 inline const Eigen::MatrixXd facePotential(size_t iF) const
191 {
192 return m_xgrad.faceOperators(iF).potential * EgradFace(iF);
193 }
194
196 inline const Eigen::MatrixXd facePotential(const Face & F) const
197 {
198 return facePotential(F.global_index());
199 }
200
202 inline const Eigen::MatrixXd cellGradient(size_t iT) const
203 {
204 return m_xgrad.cellOperators(iT).gradient * EgradCell(iT);
205 }
206
208 inline const Eigen::MatrixXd cellGradient(const Cell & T) const
209 {
210 return cellGradient(T.global_index());
211 }
212
214 inline const Eigen::MatrixXd cellPotential(size_t iT) const
215 {
216 return m_xgrad.cellOperators(iT).potential * EgradCell(iT);
217 }
218
220 inline const Eigen::MatrixXd cellPotential(const Cell & T) const
221 {
222 return cellPotential(T.global_index());
223 }
224
226 Eigen::MatrixXd computeL2Product(
227 const size_t iT,
228 const double & penalty_factor = 1.,
229 const Eigen::MatrixXd & mass_Pkpo_T = Eigen::MatrixXd::Zero(1,1),
231 ) const
232 {
233 return EgradCell(iT).transpose()
235 * EgradCell(iT);
236 }
237
239 Eigen::MatrixXd computeStabilisation(
240 const size_t iT,
242 ) const
243 {
244 return EgradCell(iT).transpose()
245 * m_xgrad.computeStabilisation(iT, weight)
246 * EgradCell(iT);
247 }
248
249
251 std::vector<double> computeVertexValues(
252 const Eigen::VectorXd & u
253 ) const;
254
255
256 //-----------------------//
257 //---- Getters ----------//
258
260 inline const DDRCore::CellBases & cellBases(size_t iT) const
261 {
262 return m_ddr_core.cellBases(iT);
263 }
264
266 inline const DDRCore::CellBases & cellBases(const Cell & T) const
267 {
268 return m_ddr_core.cellBases(T.global_index());
269 }
270
272 inline const DDRCore::FaceBases & faceBases(size_t iF) const
273 {
274 return m_ddr_core.faceBases(iF);
275 }
276
278 inline const DDRCore::FaceBases & faceBases(const Face & F) const
279 {
280 return m_ddr_core.faceBases(F.global_index());
281 }
282
284 inline const DDRCore::EdgeBases & edgeBases(size_t iE) const
285 {
286 return m_ddr_core.edgeBases(iE);
287 }
288
290 inline const DDRCore::EdgeBases & edgeBases(const Edge & E) const
291 {
292 return m_ddr_core.edgeBases(E.global_index());
293 }
294
295 private:
296 TransferOperators _compute_face_transfer_operators(size_t iF);
297 TransferOperators _compute_cell_transfer_operators(size_t iT);
298
299 const DDRCore & m_ddr_core;
300 const SerendipityProblem & m_ser_pro;
301 const XGrad m_xgrad;
302
303 // Containers for serendipity, extension and reduction operators
304 std::vector<std::unique_ptr<TransferOperators> > m_face_transfer_operators;
305 std::vector<std::unique_ptr<TransferOperators> > m_cell_transfer_operators;
306
307 bool m_use_threads;
308 std::ostream & m_output;
309
310 };
311
312} // end of namespace HArDCore3D
313#endif
Construct all polynomial spaces for the DDR sequence.
Definition ddrcore.hpp:62
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
Discrete H1 space: local operators, L2 product and global interpolator.
Definition xgrad.hpp:18
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 DDRCore::CellBases & cellBases(const Cell &T) const
Return cell bases for cell T.
Definition sxgrad.hpp:266
const Eigen::MatrixXd & SgradCell(const Cell &T) const
Return the serendipity reconstruction for cell T.
Definition sxgrad.hpp:133
std::vector< double > computeVertexValues(const Eigen::VectorXd &u) const
Computes the values of the potential reconstruction at the mesh vertices.
Definition sxgrad.cpp:356
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
TransferOperators(const Eigen::MatrixXd &_serendipity, const Eigen::MatrixXd &_extension, const Eigen::MatrixXd &_reduction)
Definition sxgrad.hpp:28
const Mesh & mesh() const
Return a const reference to the mesh.
Definition ddrcore.hpp:134
const SerendipityProblem & serPro() const
Definition sxgrad.hpp:60
const EdgeBases & edgeBases(size_t iE) const
Return edge bases for edge iE.
Definition ddrcore.hpp:162
Eigen::MatrixXd extension
Definition sxgrad.hpp:41
const Eigen::MatrixXd & RgradCell(size_t iT) const
Return the reduction for the cell of index iT.
Definition sxgrad.hpp:127
const Eigen::MatrixXd cellPotential(size_t iT) const
Return the potential operator on the cell of index iT.
Definition sxgrad.hpp:214
const Eigen::MatrixXd & EgradFace(size_t iF) const
Return the extension for the face of index iF.
Definition sxgrad.hpp:83
const Eigen::MatrixXd & RgradCell(const Cell &T) const
Return the reduction for cell T.
Definition sxgrad.hpp:145
const LocalOperators & edgeOperators(size_t iE) const
Return edge operators for the edge of index iE.
Definition xgrad.hpp:63
const Eigen::MatrixXd edgePotential(const Edge &E) const
Return the potential operator on edge E.
Definition sxgrad.hpp:172
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
Eigen::MatrixXd potential
Definition xgrad.hpp:36
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 for the cell of index iT. The stabilisation here is b...
Definition xgrad.cpp:401
const Eigen::MatrixXd edgeGradient(size_t iE) const
Return the full gradient operator on the edge of index iE.
Definition sxgrad.hpp:154
const Eigen::MatrixXd edgeGradient(const Edge &E) const
Return the full gradient operator on edge E.
Definition sxgrad.hpp:160
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 & EgradCell(size_t iT) const
Return the extension for the cell of index iT.
Definition sxgrad.hpp:121
const Eigen::MatrixXd cellGradient(size_t iT) const
Return the full gradient operator on the cell of index iT.
Definition sxgrad.hpp:202
const size_t & degree() const
Return the polynomial degree.
Definition ddrcore.hpp:140
Eigen::MatrixXd gradient
Definition xgrad.hpp:35
const LocalOperators & faceOperators(size_t iF) const
Return face operators for the face of index iF.
Definition xgrad.hpp:75
Eigen::VectorXd interpolate(const FunctionType &q, const int doe_cell=-1, const int doe_face=-1, const int doe_edge=-1) const
Interpolator of a continuous function.
Definition sxgrad.cpp:65
const Eigen::MatrixXd & EgradFace(const Face &F) const
Return the extension for face F.
Definition sxgrad.hpp:101
const DDRCore::EdgeBases & edgeBases(const Edge &E) const
Return edge bases for edge E.
Definition sxgrad.hpp:290
Eigen::MatrixXd computeStabilisation(const size_t iT, const IntegralWeight &weight=IntegralWeight(1.)) const
Computes only the stabilisation matrix of the (weighted) L2-product for the cell of index iT....
Definition xgrad.cpp:441
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(const Face &F) const
Return face bases for face F.
Definition sxgrad.hpp:278
const Eigen::MatrixXd faceGradient(const Face &F) const
Return the full gradient operator on face F.
Definition sxgrad.hpp:184
const Eigen::MatrixXd & RgradFace(size_t iF) const
Return the reduction for the face of index iF.
Definition sxgrad.hpp:89
const Eigen::MatrixXd cellGradient(const Cell &T) const
Return the full gradient operator on cell T.
Definition sxgrad.hpp:208
Eigen::MatrixXd reduction
Definition sxgrad.hpp:42
const Eigen::MatrixXd facePotential(const Face &F) const
Return the potential operator on face F.
Definition sxgrad.hpp:196
const Eigen::MatrixXd cellPotential(const Cell &T) const
Return the potential operator on cell T.
Definition sxgrad.hpp:220
Eigen::MatrixXd serendipity
Definition sxgrad.hpp:40
const Eigen::MatrixXd & SgradCell(size_t iT) const
Return the serendipity reconstruction for the cell of index iT.
Definition sxgrad.hpp:115
std::function< double(const Eigen::Vector3d &)> FunctionType
Definition sxgrad.hpp:22
const Eigen::MatrixXd & EgradCell(const Cell &T) const
Return the extension for cell T.
Definition sxgrad.hpp:139
const LocalOperators & cellOperators(size_t iT) const
Return cell operators for the cell of index iT.
Definition xgrad.hpp:87
const DDRCore::FaceBases & faceBases(size_t iF) const
Return face bases for the face of index iF.
Definition sxgrad.hpp:272
const Eigen::MatrixXd & RgradFace(const Face &F) const
Return cell reduction for cell T.
Definition sxgrad.hpp:107
const FaceBases & faceBases(size_t iF) const
Return face bases for face iF.
Definition ddrcore.hpp:154
const Eigen::MatrixXd & SgradFace(const Face &F) const
Return the serendipity reconstruction for face F.
Definition sxgrad.hpp:95
const CellBases & cellBases(size_t iT) const
Return cell bases for element iT.
Definition ddrcore.hpp:146
const Eigen::MatrixXd & SgradFace(size_t iF) const
Return the serendipity reconstruction for the face of index iF.
Definition sxgrad.hpp:77
Eigen::MatrixXd computeStabilisation(const size_t iT, const IntegralWeight &weight=IntegralWeight(1.)) const
Computes only the stabilisation matrix of the (weighted) L2-product for the cell of index iT.
Definition sxgrad.hpp:239
bool use_threads
Definition HHO_DiffAdvecReac.hpp:47
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 sxgrad.hpp:27