HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
hhospace.hpp
Go to the documentation of this file.
1 // Core data structures and methods required to implement the Hybrid High-Order in 3D
2 //
3 // Provides:
4 // - Polynomial spaces on the element and faces
5 // - Interpolator of smooth functions
6 // - Full gradient, potential and stabilisation bilinear form in the elements
7 //
8 // Author: Jerome Droniou (jerome.droniou@monash.edu)
9 //
10 
11 /*
12  *
13  * This library was developed around HHO methods, although some parts of it have a more
14  * general purpose. If you use this code or part of it in a scientific publication,
15  * please mention the following book as a reference for the underlying principles
16  * of HHO schemes:
17  *
18  * The Hybrid High-Order Method for Polytopal Meshes: Design, Analysis, and Applications.
19  * D. A. Di Pietro and J. Droniou. Modeling, Simulation and Applications, vol. 19.
20  * Springer International Publishing, 2020, xxxi + 525p. doi: 10.1007/978-3-030-37203-3.
21  * url: https://hal.archives-ouvertes.fr/hal-02151813.
22  *
23  */
24 
25 
26 #ifndef HHOSPACE_HPP
27 #define HHOSPACE_HPP
28 
29 #include <iostream>
30 #include <globaldofspace.hpp>
31 #include <basis.hpp>
33 
40 namespace HArDCore3D
41 {
42 
49  //------------------------------------------------------------------------------
50 
52  class HHOSpace : public GlobalDOFSpace
53  {
54  public:
55  // Types for element bases
58 
59  // Types for face bases
61 
62  // Types for functions to interpolate
63  typedef std::function<double(const VectorRd &)> FunctionType;
64 
66 
70  struct CellBases
71  {
74 
75  std::unique_ptr<PolyBasisCellType> Polykpo;
76  std::unique_ptr<PolyBasisCellType> Polyk;
77  std::unique_ptr<PolydBasisCellType> Polykd;
78  };
79 
81 
82  struct FaceBases
83  {
86 
87  std::unique_ptr<PolyBasisFaceType> Polyk;
88  };
89 
92  {
94  const Eigen::MatrixXd & _gradient,
95  const Eigen::MatrixXd & _potential,
96  const Eigen::MatrixXd & _stabilisation
97  )
98  : gradient(_gradient),
99  potential(_potential),
100  stabilisation(_stabilisation)
101  {
102  // Do nothing
103  }
104 
105  Eigen::MatrixXd gradient;
106  Eigen::MatrixXd potential;
107  Eigen::MatrixXd stabilisation;
108  };
109 
111  HHOSpace(const Mesh & mesh, size_t K, bool use_threads = true, std::ostream & output = std::cout);
112 
114  const Mesh & mesh() const
115  {
116  return m_mesh;
117  }
118 
120  const size_t & degree() const
121  {
122  return m_K;
123  }
124 
126  Eigen::VectorXd interpolate(
127  const FunctionType & q,
128  const int doe_cell = -1,
129  const int doe_face = -1
130  ) const;
131 
133  inline const CellBases & cellBases(size_t iT) const
134  {
135  // Make sure that the basis has been created
136  assert( m_cell_bases[iT] );
137  return *m_cell_bases[iT].get();
138  }
139 
141  inline const CellBases & cellBases(const Cell & T) const
142  {
143  return cellBases(T.global_index());
144  }
145 
147  inline const FaceBases & faceBases(size_t iF) const
148  {
149  // Make sure that the basis has been created
150  assert( m_face_bases[iF] );
151  return *m_face_bases[iF].get();
152  }
153 
155  inline const FaceBases & faceBases(const Face & F) const
156  {
157  return faceBases(F.global_index());
158  }
159 
161  inline const LocalOperators & operators(size_t iT) const
162  {
163  assert( m_operators[iT] );
164  return *m_operators[iT];
165  }
166 
168  inline const LocalOperators & operators(const Cell & T) const
169  {
170  return operators(T.global_index());
171  }
172 
174  std::vector<std::pair<double,double>> computeNorms(
175  const std::vector<Eigen::VectorXd> & list_dofs
176  ) const;
177 
179  std::vector<double> computeVertexValues(
180  const Eigen::VectorXd & u
181  ) const;
182 
183  private:
185  CellBases _construct_cell_bases(size_t iT);
186 
188  FaceBases _construct_face_bases(size_t iF);
189 
191  LocalOperators _compute_operators(size_t iT);
192 
193  // Pointer to the mesh
194  const Mesh & m_mesh;
195  // Degrees
196  const size_t m_K;
197  // Parallel or not
198  bool m_use_threads;
199  // Output stream
200  std::ostream & m_output;
201 
202  // Cell bases
203  std::vector<std::unique_ptr<CellBases> > m_cell_bases;
204  // Face bases
205  std::vector<std::unique_ptr<FaceBases> > m_face_bases;
206 
207  // Local operators
208  std::vector<std::unique_ptr<LocalOperators> > m_operators;
209 
210  };
211 
212 } // end of namespace HArDCore3D
213 
214 #endif // HHOSPACE_HPP
Family of functions expressed as linear combination of the functions of a given basis.
Definition: basis.hpp:388
Base class for global DOF spaces. Provides functions to manipulate global DOFs (the local version bei...
Definition: globaldofspace.hpp:16
Class definition: polynomial bases and operators.
Definition: hhospace.hpp:53
Vector family obtained by tensorization of a scalar family.
Definition: basis.hpp:609
Class to describe a mesh.
Definition: MeshND.hpp:17
Eigen::MatrixXd gradient
Definition: hhospace.hpp:105
std::unique_ptr< PolyBasisCellType > Polykpo
Definition: hhospace.hpp:75
Eigen::MatrixXd stabilisation
Definition: hhospace.hpp:107
std::vector< double > computeVertexValues(const Eigen::VectorXd &u) const
Computes the values of the potential reconstruction at the mesh vertices.
Definition: hhospace.cpp:394
Face GeometricSupport
Geometric support.
Definition: hhospace.hpp:85
std::unique_ptr< PolyBasisCellType > Polyk
Definition: hhospace.hpp:76
const CellBases & cellBases(size_t iT) const
Return cell bases for element iT.
Definition: hhospace.hpp:133
Cell GeometricSupport
Geometric support.
Definition: hhospace.hpp:73
std::vector< std::pair< double, double > > computeNorms(const std::vector< Eigen::VectorXd > &list_dofs) const
Computes the discrete L2 (cell unknowns only) and H1 norms of a list of vectors.
Definition: hhospace.cpp:324
const Mesh & mesh() const
Return a const reference to the mesh.
Definition: hhospace.hpp:114
LocalOperators(const Eigen::MatrixXd &_gradient, const Eigen::MatrixXd &_potential, const Eigen::MatrixXd &_stabilisation)
Definition: hhospace.hpp:93
Family< MonomialScalarBasisCell > PolyBasisCellType
Definition: hhospace.hpp:56
const FaceBases & faceBases(const Face &F) const
Return cell bases for face F.
Definition: hhospace.hpp:155
const LocalOperators & operators(const Cell &T) const
Return cell operators for cell T.
Definition: hhospace.hpp:168
const LocalOperators & operators(size_t iT) const
Return operators for the cell of index iT.
Definition: hhospace.hpp:161
std::function< double(const VectorRd &)> FunctionType
Definition: hhospace.hpp:63
HHOSpace(const Mesh &mesh, size_t K, bool use_threads=true, std::ostream &output=std::cout)
Constructor.
Definition: hhospace.cpp:12
Eigen::MatrixXd potential
Definition: hhospace.hpp:106
TensorizedVectorFamily< PolyBasisCellType, dimspace > PolydBasisCellType
Definition: hhospace.hpp:57
Eigen::VectorXd interpolate(const FunctionType &q, const int doe_cell=-1, const int doe_face=-1) const
Interpolator of a continuous function.
Definition: hhospace.cpp:129
std::unique_ptr< PolyBasisFaceType > Polyk
Definition: hhospace.hpp:87
std::unique_ptr< PolydBasisCellType > Polykd
Definition: hhospace.hpp:77
Family< MonomialScalarBasisFace > PolyBasisFaceType
Definition: hhospace.hpp:60
const FaceBases & faceBases(size_t iF) const
Return face bases for face iF.
Definition: hhospace.hpp:147
const CellBases & cellBases(const Cell &T) const
Return cell bases for cell T.
Definition: hhospace.hpp:141
const size_t & degree() const
Return the polynomial degree (common face and elements)
Definition: hhospace.hpp:120
bool use_threads
Definition: HHO_DiffAdvecReac.hpp:47
size_t K
Definition: HHO_DiffAdvecReac.hpp:46
Definition: ddr-magnetostatics.hpp:40
MeshND::VectorRd< 2 > VectorRd
Definition: Mesh2D.hpp:14
MeshND::Face< 2 > Face
Definition: Mesh2D.hpp:12
MeshND::Cell< 2 > Cell
Definition: Mesh2D.hpp:13
Structure to store element bases.
Definition: hhospace.hpp:71
Structure to store face bases.
Definition: hhospace.hpp:83
A structure to store local operators (gradient, potential, stabilisation)
Definition: hhospace.hpp:92