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
serendipity_problem.hpp
Go to the documentation of this file.
1// Class to select edges/faces to create serendipity spaces and compute serendipity operator
2//
3//
4// Author: Jerome Droniou (jerome.droniou@monash.edu)
5//
6
7/*
8 *
9 * This library was developed around HHO methods, although some parts of it have a more
10 * general purpose. If you use this code or part of it in a scientific publication,
11 * please mention the following book as a reference for the underlying principles
12 * of HHO schemes:
13 *
14 * The Hybrid High-Order Method for Polytopal Meshes: Design, Analysis, and Applications.
15 * D. A. Di Pietro and J. Droniou. Modeling, Simulation and Applications, vol. 19.
16 * Springer International Publishing, 2020, xxxi + 525p. doi: 10.1007/978-3-030-37203-3.
17 * url: https://hal.archives-ouvertes.fr/hal-02151813.
18 *
19 */
20
21
22#ifndef SERENDIPITY_PROBLEM_HPP
23#define SERENDIPITY_PROBLEM_HPP
24
25#include <ddrcore.hpp>
26
27namespace HArDCore3D
28{
29
36 //------------------------------------------------------------------------------
37
40 {
41 public:
46
48 /* PartialPivLU does not seem to always work... */
49 typedef Eigen::FullPivLU<Eigen::MatrixXd> InverseProblem;
50
53 bool use_threads = true,
54 std::ostream & output = std::cout,
55 bool use_serendipity = true
56 );
57
58 //---------- Serendipity edges and faces, and degrees -------------//
60 inline const std::vector<size_t> & serendipityEdges(size_t iF) const
61 {
62 return m_serendipity_edges[iF];
63 }
64
66 inline const int n_serendipityEdges(size_t iF) const
67 {
68 return m_serendipity_edges[iF].size();
69 }
70
72 inline const int serDegreeFace(size_t iF) const
73 {
74 return m_ddrcore.degree() + 1 - n_serendipityEdges(iF);
75 }
76
78 inline const std::vector<size_t> & serendipityFaces(size_t iT) const
79 {
80 return m_serendipity_faces[iT];
81 }
82
84 inline const int n_serendipityFaces(size_t iT) const
85 {
86 return m_serendipity_faces[iT].size();
87 }
88
90 inline const int serDegreeCell(size_t iT) const
91 {
92 return m_ddrcore.degree() + 1 - n_serendipityFaces(iT);
93 }
94
95 //---------- Serendipity dimensions and bases for grad -------------//
97 inline size_t dimFacePolyl(size_t iF) const
98 {
100 }
101
103 inline size_t dimFacePolyl(const Face & F) const
104 {
105 return dimFacePolyl(F.global_index());
106 }
107
109 inline const PolylBasisFaceType & faceBasisPolyl(size_t iF) const
110 {
111 // Make sure that the basis has been created
112 assert( m_face_bases_Polyl[iF] );
113 return *m_face_bases_Polyl[iF].get();
114
115 }
116
118 inline const PolylBasisFaceType & faceBasisPolyl(const Face & F) const
119 {
120 return faceBasisPolyl(F.global_index());
121 }
122
124 inline size_t dimCellPolyl(size_t iT) const
125 {
127 }
128
130 inline size_t dimCellPolyl(const Cell & T) const
131 {
132 return dimCellPolyl(T.global_index());
133 }
134
136 inline const PolylBasisCellType & cellBasisPolyl(size_t iT) const
137 {
138 // Make sure that the basis has been created
139 assert( m_cell_bases_Polyl[iT] );
140 return *m_cell_bases_Polyl[iT].get();
141
142 }
143
145 inline const PolylBasisCellType & cellBasisPolyl(const Cell & T) const
146 {
147 return cellBasisPolyl(T.global_index());
148 }
149
151 Eigen::VectorXi nDOFs_faces_SXGrad() const;
153 Eigen::VectorXi nDOFs_cells_SXGrad() const;
154
155 //---------- Serendipity dimensions and bases for curl -------------//
157 inline size_t dimFaceRolyCompllpo(size_t iF) const
158 {
160 }
161
163 inline size_t dimFaceRolyCompllpo(const Face & F) const
164 {
165 return dimFaceRolyCompllpo(F.global_index());
166 }
167
170 {
171 // Make sure that the basis has been created
172 assert( m_face_bases_RolyCompllpo[iF] );
173 return *m_face_bases_RolyCompllpo[iF].get();
174
175 }
176
178 inline const RolyCompllpoBasisFaceType & faceBasisRolyCompllpo(const Face & F) const
179 {
180 return faceBasisRolyCompllpo(F.global_index());
181 }
182
184 inline size_t dimCellRolyCompllpo(size_t iT) const
185 {
187 }
188
190 inline size_t dimCellRolyCompllpo(const Cell & T) const
191 {
192 return dimCellRolyCompllpo(T.global_index());
193 }
194
197 {
198 // Make sure that the basis has been created
199 assert( m_cell_bases_RolyCompllpo[iT] );
200 return *m_cell_bases_RolyCompllpo[iT].get();
201
202 }
203
205 inline const RolyCompllpoBasisCellType & cellBasisRolyCompllpo(const Cell & T) const
206 {
207 return cellBasisRolyCompllpo(T.global_index());
208 }
209
211 Eigen::VectorXi nDOFs_faces_SXCurl() const;
213 Eigen::VectorXi nDOFs_cells_SXCurl() const;
214
215 //------------ Serendipity operators ---------------//
217 const Eigen::MatrixXd SerendipityOperatorFace(const size_t iF, const Eigen::MatrixXd & LF) const;
218
220 inline const Eigen::MatrixXd SerendipityOperatorFace(const Face & F, const Eigen::MatrixXd & LF) const
221 {
222 return SerendipityOperatorFace(F.global_index(), LF);
223 };
224
226 const Eigen::MatrixXd SerendipityOperatorCell(const size_t iT, const Eigen::MatrixXd & LT) const;
227
229 inline const Eigen::MatrixXd SerendipityOperatorCell(const Cell & T, const Eigen::MatrixXd & LT) const
230 {
231 return SerendipityOperatorCell(T.global_index(), LT);
232 };
233
234
236 inline const Mesh & mesh() const
237 {
238 return m_ddrcore.mesh();
239 }
240
242 inline const DDRCore & ddrCore() const
243 {
244 return m_ddrcore;
245 }
246
247 private:
249 std::vector<size_t> _compute_serendipity_edges(size_t iF);
250
252 InverseProblem _compute_inverse_problem_faces(size_t iF);
253
255 std::vector<size_t> _compute_serendipity_faces(size_t iT);
256
258 InverseProblem _compute_inverse_problem_cells(size_t iT);
259
260 // Pointer do DDRCore
261 const DDRCore & m_ddrcore;
262 // Output stream
263 std::ostream & m_output;
264
265 // To determine if we want to actually use serendipity or not. False gives back the standard DDR
266 bool m_use_serendipity;
267
268 // Face and cell basis P^l
269 std::vector<std::unique_ptr<PolylBasisFaceType> > m_face_bases_Polyl;
270 std::vector<std::unique_ptr<PolylBasisCellType> > m_cell_bases_Polyl;
271
272 // Face and cell basis R^{c,l+1}
273 std::vector<std::unique_ptr<RolyCompllpoBasisFaceType> > m_face_bases_RolyCompllpo;
274 std::vector<std::unique_ptr<RolyCompllpoBasisCellType> > m_cell_bases_RolyCompllpo;
275
276 // List the local indices of edges/faces used for the serendipity on each face/cell
277 std::vector<std::vector<size_t>> m_serendipity_edges;
278 std::vector<std::vector<size_t>> m_serendipity_faces;
279
280 // Store the inverse of the matrix to compute serendipity operators on faces/cells
281 std::vector<InverseProblem> m_inverse_problem_faces;
282 std::vector<InverseProblem> m_inverse_problem_cells;
283
284 };
285
286} // end of namespace HArDCore3D
287
288#endif // SERENDIPITY_PROBLEM_HPP
Construct all polynomial spaces for the DDR sequence.
Definition ddrcore.hpp:62
Generate a basis restricted to the first "dimension" functions.
Definition basis.hpp:1147
Construct all polynomial spaces for the DDR sequence.
Definition serendipity_problem.hpp:40
Class to describe a mesh.
Definition MeshND.hpp:17
@ Matrix
Definition basis.hpp:67
size_t dimFaceRolyCompllpo(size_t iF) const
Return the dimension of R^{c,l+1} on face of index iF.
Definition serendipity_problem.hpp:157
size_t dimCellRolyCompllpo(const Cell &T) const
Return the dimension of R^{c,l+1} on cell T.
Definition serendipity_problem.hpp:190
const std::vector< size_t > & serendipityFaces(size_t iT) const
Return the list of serendipity face in a cell.
Definition serendipity_problem.hpp:78
RestrictedBasis< DDRCore::RolyComplBasisCellType > RolyCompllpoBasisCellType
Definition serendipity_problem.hpp:45
const Mesh & mesh() const
Return a const reference to the mesh.
Definition serendipity_problem.hpp:236
const Eigen::MatrixXd SerendipityOperatorCell(const size_t iT, const Eigen::MatrixXd &LT) const
Compute the serendipity operator on the cell of index iT.
Definition serendipity_problem.cpp:254
const PolylBasisFaceType & faceBasisPolyl(const Face &F) const
Return the basis of P^l on face F.
Definition serendipity_problem.hpp:118
const RolyCompllpoBasisCellType & cellBasisRolyCompllpo(const Cell &T) const
Return the basis of R^{c,l+1} on cell T.
Definition serendipity_problem.hpp:205
const RolyCompllpoBasisFaceType & faceBasisRolyCompllpo(size_t iF) const
Return the basis of R^{c,l+1} on face of index iF.
Definition serendipity_problem.hpp:169
const PolylBasisCellType & cellBasisPolyl(const Cell &T) const
Return the basis of P^l on cell T.
Definition serendipity_problem.hpp:145
const int n_serendipityEdges(size_t iF) const
Return the number of serendipity edges in a face.
Definition serendipity_problem.hpp:66
size_t dimCellPolyl(size_t iT) const
Return the dimension of P^l on cell of index iT.
Definition serendipity_problem.hpp:124
const RolyCompllpoBasisCellType & cellBasisRolyCompllpo(size_t iT) const
Return the basis of R^{c,l+1} on cell of index iT.
Definition serendipity_problem.hpp:196
Eigen::VectorXi nDOFs_cells_SXCurl() const
Number of DOFs on cells for serendipity XCurl space.
Definition serendipity_problem.cpp:295
const std::vector< size_t > & serendipityEdges(size_t iF) const
Return the list of serendipity edges in a face.
Definition serendipity_problem.hpp:60
const Mesh & mesh() const
Return a const reference to the mesh.
Definition ddrcore.hpp:134
const Eigen::MatrixXd SerendipityOperatorFace(const Face &F, const Eigen::MatrixXd &LF) const
Compute the serendipity operator on the face F.
Definition serendipity_problem.hpp:220
const int n_serendipityFaces(size_t iT) const
Return the number of serendipity faces in a cell.
Definition serendipity_problem.hpp:84
const Eigen::MatrixXd SerendipityOperatorFace(const size_t iF, const Eigen::MatrixXd &LF) const
Compute the serendipity operator on the face of index iF.
Definition serendipity_problem.cpp:161
Eigen::VectorXi nDOFs_faces_SXCurl() const
Number of DOFs on faces for serendipity XCurl space.
Definition serendipity_problem.cpp:284
size_t dimFacePolyl(size_t iF) const
Return the dimension of P^l on face of index iF.
Definition serendipity_problem.hpp:97
const size_t & degree() const
Return the polynomial degree.
Definition ddrcore.hpp:140
RestrictedBasis< DDRCore::PolyBasisFaceType > PolylBasisFaceType
Definition serendipity_problem.hpp:42
Eigen::FullPivLU< Eigen::MatrixXd > InverseProblem
Type for inverses of matrix for serendipity problem.
Definition serendipity_problem.hpp:49
size_t dimCellPolyl(const Cell &T) const
Return the dimension of P^l on cell T.
Definition serendipity_problem.hpp:130
const int serDegreeCell(size_t iT) const
Return the serendipity degree ell_T in a cell.
Definition serendipity_problem.hpp:90
RestrictedBasis< DDRCore::RolyComplBasisFaceType > RolyCompllpoBasisFaceType
Definition serendipity_problem.hpp:44
RestrictedBasis< DDRCore::PolyBasisCellType > PolylBasisCellType
Definition serendipity_problem.hpp:43
const int serDegreeFace(size_t iF) const
Return the serendipity degree ell_F in a face.
Definition serendipity_problem.hpp:72
const PolylBasisCellType & cellBasisPolyl(size_t iT) const
Return the basis of P^l on cell of index iT.
Definition serendipity_problem.hpp:136
Eigen::VectorXi nDOFs_cells_SXGrad() const
Number of DOFs on cells for serendipity XGrad space.
Definition serendipity_problem.cpp:272
size_t dimFaceRolyCompllpo(const Face &F) const
Return the dimension of R^{c,l+1} on face F.
Definition serendipity_problem.hpp:163
size_t dimFacePolyl(const Face &F) const
Return the dimension of P^{l+1} on face F.
Definition serendipity_problem.hpp:103
const DDRCore & ddrCore() const
Return a const reference to the underlying DDR core.
Definition serendipity_problem.hpp:242
const Eigen::MatrixXd SerendipityOperatorCell(const Cell &T, const Eigen::MatrixXd &LT) const
Compute the serendipity operator on the Cell T.
Definition serendipity_problem.hpp:229
const RolyCompllpoBasisFaceType & faceBasisRolyCompllpo(const Face &F) const
Return the basis of R^{c,l+1} on face F.
Definition serendipity_problem.hpp:178
size_t dimCellRolyCompllpo(size_t iT) const
Return the dimension of R^{c,l+1} on cell of index iT.
Definition serendipity_problem.hpp:184
const PolylBasisFaceType & faceBasisPolyl(size_t iF) const
Return the basis of P^l on face of index iF.
Definition serendipity_problem.hpp:109
Eigen::VectorXi nDOFs_faces_SXGrad() const
Number of DOFs on faces for serendipity XGrad space.
Definition serendipity_problem.cpp:262
bool use_threads
Definition HHO_DiffAdvecReac.hpp:47
Definition ddr-magnetostatics.hpp:41
Basis dimensions for various polynomial spaces on edges/faces/elements (when relevant): Pk,...
Definition polynomialspacedimension.hpp:54