HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
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 
27 namespace 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 
52  SerendipityProblem(const DDRCore & ddrcore, bool use_threads = true, std::ostream & output = std::cout);
53 
54  //---------- Serendipity edges and faces, and degrees -------------//
56  inline const std::vector<size_t> & serendipityEdges(size_t iF) const
57  {
58  return m_serendipity_edges[iF];
59  }
60 
62  inline const int n_serendipityEdges(size_t iF) const
63  {
64  return m_serendipity_edges[iF].size();
65  }
66 
68  inline const int serDegreeFace(size_t iF) const
69  {
70  return m_ddrcore.degree() + 1 - n_serendipityEdges(iF);
71  }
72 
74  inline const std::vector<size_t> & serendipityFaces(size_t iT) const
75  {
76  return m_serendipity_faces[iT];
77  }
78 
80  inline const int n_serendipityFaces(size_t iT) const
81  {
82  return m_serendipity_faces[iT].size();
83  }
84 
86  inline const int serDegreeCell(size_t iT) const
87  {
88  return m_ddrcore.degree() + 1 - n_serendipityFaces(iT);
89  }
90 
91  //---------- Serendipity dimensions and bases for grad -------------//
93  inline size_t dimFacePolyl(size_t iF) const
94  {
96  }
97 
99  inline size_t dimFacePolyl(const Face & F) const
100  {
101  return dimFacePolyl(F.global_index());
102  }
103 
105  inline const PolylBasisFaceType & faceBasisPolyl(size_t iF) const
106  {
107  // Make sure that the basis has been created
108  assert( m_face_bases_Polyl[iF] );
109  return *m_face_bases_Polyl[iF].get();
110 
111  }
112 
114  inline const PolylBasisFaceType & faceBasisPolyl(const Face & F) const
115  {
116  return faceBasisPolyl(F.global_index());
117  }
118 
120  inline size_t dimCellPolyl(size_t iT) const
121  {
123  }
124 
126  inline size_t dimCellPolyl(const Cell & T) const
127  {
128  return dimCellPolyl(T.global_index());
129  }
130 
132  inline const PolylBasisCellType & cellBasisPolyl(size_t iT) const
133  {
134  // Make sure that the basis has been created
135  assert( m_cell_bases_Polyl[iT] );
136  return *m_cell_bases_Polyl[iT].get();
137 
138  }
139 
141  inline const PolylBasisCellType & cellBasisPolyl(const Cell & T) const
142  {
143  return cellBasisPolyl(T.global_index());
144  }
145 
147  Eigen::VectorXd nDOFs_faces_SXGrad() const;
149  Eigen::VectorXd nDOFs_cells_SXGrad() const;
150 
151  //---------- Serendipity dimensions and bases for curl -------------//
153  inline size_t dimFaceRolyCompllpo(size_t iF) const
154  {
156  }
157 
159  inline size_t dimFaceRolyCompllpo(const Face & F) const
160  {
161  return dimFaceRolyCompllpo(F.global_index());
162  }
163 
165  inline const RolyCompllpoBasisFaceType & faceBasisRolyCompllpo(size_t iF) const
166  {
167  // Make sure that the basis has been created
168  assert( m_face_bases_RolyCompllpo[iF] );
169  return *m_face_bases_RolyCompllpo[iF].get();
170 
171  }
172 
174  inline const RolyCompllpoBasisFaceType & faceBasisRolyCompllpo(const Face & F) const
175  {
176  return faceBasisRolyCompllpo(F.global_index());
177  }
178 
180  inline size_t dimCellRolyCompllpo(size_t iT) const
181  {
183  }
184 
186  inline size_t dimCellRolyCompllpo(const Cell & T) const
187  {
188  return dimCellRolyCompllpo(T.global_index());
189  }
190 
192  inline const RolyCompllpoBasisCellType & cellBasisRolyCompllpo(size_t iT) const
193  {
194  // Make sure that the basis has been created
195  assert( m_cell_bases_RolyCompllpo[iT] );
196  return *m_cell_bases_RolyCompllpo[iT].get();
197 
198  }
199 
201  inline const RolyCompllpoBasisCellType & cellBasisRolyCompllpo(const Cell & T) const
202  {
203  return cellBasisRolyCompllpo(T.global_index());
204  }
205 
207  Eigen::VectorXd nDOFs_faces_SXCurl() const;
209  Eigen::VectorXd nDOFs_cells_SXCurl() const;
210 
211  //------------ Serendipity operators ---------------//
213  const Eigen::MatrixXd SerendipityOperatorFace(const size_t iF, const Eigen::MatrixXd & LF) const;
214 
216  inline const Eigen::MatrixXd SerendipityOperatorFace(const Face & F, const Eigen::MatrixXd & LF) const
217  {
218  return SerendipityOperatorFace(F.global_index(), LF);
219  };
220 
222  const Eigen::MatrixXd SerendipityOperatorCell(const size_t iT, const Eigen::MatrixXd & LT) const;
223 
225  inline const Eigen::MatrixXd SerendipityOperatorCell(const Cell & T, const Eigen::MatrixXd & LT) const
226  {
227  return SerendipityOperatorCell(T.global_index(), LT);
228  };
229 
230 
232  inline const Mesh & mesh() const
233  {
234  return m_ddrcore.mesh();
235  }
236 
237  private:
239  std::vector<size_t> _compute_serendipity_edges(size_t iF);
240 
242  InverseProblem _compute_inverse_problem_faces(size_t iF);
243 
245  std::vector<size_t> _compute_serendipity_faces(size_t iT);
246 
248  InverseProblem _compute_inverse_problem_cells(size_t iT);
249 
250  // Pointer do DDRCore
251  const DDRCore & m_ddrcore;
252  // Output stream
253  std::ostream & m_output;
254 
255  // Face and cell basis P^l
256  std::vector<std::unique_ptr<PolylBasisFaceType> > m_face_bases_Polyl;
257  std::vector<std::unique_ptr<PolylBasisCellType> > m_cell_bases_Polyl;
258 
259  // Face and cell basis R^{c,l+1}
260  std::vector<std::unique_ptr<RolyCompllpoBasisFaceType> > m_face_bases_RolyCompllpo;
261  std::vector<std::unique_ptr<RolyCompllpoBasisCellType> > m_cell_bases_RolyCompllpo;
262 
263  // List the local indices of edges/faces used for the serendipity on each face/cell
264  std::vector<std::vector<size_t>> m_serendipity_edges;
265  std::vector<std::vector<size_t>> m_serendipity_faces;
266 
267  // Store the inverse of the matrix to compute serendipity operators on faces/cells
268  std::vector<InverseProblem> m_inverse_problem_faces;
269  std::vector<InverseProblem> m_inverse_problem_cells;
270 
271  };
272 
273 } // end of namespace HArDCore3D
274 
275 #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:1119
Construct all polynomial spaces for the DDR sequence.
Definition: serendipity_problem.hpp:40
Class to describe a mesh.
Definition: MeshND.hpp:17
size_t dimFaceRolyCompllpo(size_t iF) const
Return the dimension of R^{c,l+1} on face of index iF.
Definition: serendipity_problem.hpp:153
size_t dimCellRolyCompllpo(const Cell &T) const
Return the dimension of R^{c,l+1} on cell T.
Definition: serendipity_problem.hpp:186
const size_t & degree() const
Return the polynomial degree.
Definition: ddrcore.hpp:140
RestrictedBasis< DDRCore::RolyComplBasisCellType > RolyCompllpoBasisCellType
Definition: serendipity_problem.hpp:45
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:247
const PolylBasisFaceType & faceBasisPolyl(size_t iF) const
Return the basis of P^l on face of index iF.
Definition: serendipity_problem.hpp:105
const RolyCompllpoBasisFaceType & faceBasisRolyCompllpo(size_t iF) const
Return the basis of R^{c,l+1} on face of index iF.
Definition: serendipity_problem.hpp:165
const int n_serendipityEdges(size_t iF) const
Return the number of serendipity edges in a face.
Definition: serendipity_problem.hpp:62
size_t dimCellPolyl(size_t iT) const
Return the dimension of P^l on cell of index iT.
Definition: serendipity_problem.hpp:120
const RolyCompllpoBasisCellType & cellBasisRolyCompllpo(size_t iT) const
Return the basis of R^{c,l+1} on cell of index iT.
Definition: serendipity_problem.hpp:192
Eigen::VectorXd nDOFs_faces_SXGrad() const
Number of DOFs on faces for serendipity XGrad space.
Definition: serendipity_problem.cpp:255
const PolylBasisCellType & cellBasisPolyl(size_t iT) const
Return the basis of P^l on cell of index iT.
Definition: serendipity_problem.hpp:132
const Mesh & mesh() const
Return a const reference to the mesh.
Definition: ddrcore.hpp:134
const PolylBasisFaceType & faceBasisPolyl(const Face &F) const
Return the basis of P^l on face F.
Definition: serendipity_problem.hpp:114
Eigen::VectorXd nDOFs_cells_SXCurl() const
Number of DOFs on cells for serendipity XCurl space.
Definition: serendipity_problem.cpp:288
const Eigen::MatrixXd SerendipityOperatorFace(const Face &F, const Eigen::MatrixXd &LF) const
Compute the serendipity operator on the face F.
Definition: serendipity_problem.hpp:216
const int n_serendipityFaces(size_t iT) const
Return the number of serendipity faces in a cell.
Definition: serendipity_problem.hpp:80
const RolyCompllpoBasisFaceType & faceBasisRolyCompllpo(const Face &F) const
Return the basis of R^{c,l+1} on face F.
Definition: serendipity_problem.hpp:174
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:157
Eigen::VectorXd nDOFs_faces_SXCurl() const
Number of DOFs on faces for serendipity XCurl space.
Definition: serendipity_problem.cpp:277
size_t dimFacePolyl(size_t iF) const
Return the dimension of P^l on face of index iF.
Definition: serendipity_problem.hpp:93
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
const PolylBasisCellType & cellBasisPolyl(const Cell &T) const
Return the basis of P^l on cell T.
Definition: serendipity_problem.hpp:141
Eigen::VectorXd nDOFs_cells_SXGrad() const
Number of DOFs on cells for serendipity XGrad space.
Definition: serendipity_problem.cpp:265
size_t dimCellPolyl(const Cell &T) const
Return the dimension of P^l on cell T.
Definition: serendipity_problem.hpp:126
const int serDegreeCell(size_t iT) const
Return the serendipity degree ell_T in a cell.
Definition: serendipity_problem.hpp:86
const RolyCompllpoBasisCellType & cellBasisRolyCompllpo(const Cell &T) const
Return the basis of R^{c,l+1} on cell T.
Definition: serendipity_problem.hpp:201
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:68
const Mesh & mesh() const
Return a const reference to the mesh.
Definition: serendipity_problem.hpp:232
size_t dimFaceRolyCompllpo(const Face &F) const
Return the dimension of R^{c,l+1} on face F.
Definition: serendipity_problem.hpp:159
size_t dimFacePolyl(const Face &F) const
Return the dimension of P^{l+1} on face F.
Definition: serendipity_problem.hpp:99
SerendipityProblem(const DDRCore &ddrcore, bool use_threads=true, std::ostream &output=std::cout)
Constructor.
Definition: serendipity_problem.cpp:11
const Eigen::MatrixXd SerendipityOperatorCell(const Cell &T, const Eigen::MatrixXd &LT) const
Compute the serendipity operator on the Cell T.
Definition: serendipity_problem.hpp:225
const std::vector< size_t > & serendipityFaces(size_t iT) const
Return the list of serendipity face in a cell.
Definition: serendipity_problem.hpp:74
const std::vector< size_t > & serendipityEdges(size_t iF) const
Return the list of serendipity edges in a face.
Definition: serendipity_problem.hpp:56
size_t dimCellRolyCompllpo(size_t iT) const
Return the dimension of R^{c,l+1} on cell of index iT.
Definition: serendipity_problem.hpp:180
bool use_threads
Definition: HHO_DiffAdvecReac.hpp:47
Definition: ddr-magnetostatics.hpp:40
MeshND::Face< 2 > Face
Definition: Mesh2D.hpp:12
MeshND::Cell< 2 > Cell
Definition: Mesh2D.hpp:13
Basis dimensions for various polynomial spaces on edges/faces/elements (when relevant): Pk,...
Definition: polynomialspacedimension.hpp:54