HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge and cell polynomials as unknowns
Loading...
Searching...
No Matches
vhhospace.hpp
Go to the documentation of this file.
1// Core data structures and methods required to implement the Hybrid High-Order in 2D, for vector-valued functions
2//
3// Provides:
4// - Polynomial spaces on the element and edges
5// - Interpolator of smooth functions
6// - Full gradient, potential and stabilisation bilinear form in the elements
7//
8// Author: Alessandra Crippa (alessandra.crippa@ifpen.fr)
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 VHHOSPACE_HPP
27#define VHHOSPACE_HPP
28
29#include <iostream>
30#include <globaldofspace.hpp>
31#include <basis.hpp>
33
34
35namespace HArDCore2D
36{
37
44 //------------------------------------------------------------------------------
45
46 // Type for selecting some cells (return 0 or 1 for each cell T)
47 typedef std::function<bool(const Cell &)> CellSelection;
48 static const CellSelection allcells = [](const Cell &)->bool {return true;};
49
52 {
53 public:
54 // Types for element bases
58 // added AC
60
61 // Types for edge bases
64
65 // Types for functions to interpolate
66 typedef std::function<VectorRd(const VectorRd &)> FunctionType;
67 // AC - type needed only for tests
68 typedef std::function<MatrixRd(const VectorRd &)> GradientType;
69
71
75 struct CellBases
76 {
78 typedef Cell GeometricSupport;
79
80 std::unique_ptr<PolyBasisCellType> Polykpo;
81 std::unique_ptr<PolyBasisCellType> Polyk;
82 std::unique_ptr<PolydBasisCellType> Polykpod;
83 std::unique_ptr<PolydBasisCellType> Polykd;
84 std::unique_ptr<PolydxdBasisCellType> Polykdxd;
85 // added AC
86 std::unique_ptr<PolySymdxdBasisCellType> PolySymkdxd;
87 };
88
90
91 struct EdgeBases
92 {
94 typedef Edge GeometricSupport;
95
96 std::unique_ptr<PolyBasisEdgeType> Polyk;
97 std::unique_ptr<PolydBasisEdgeType> Polykd;
98 };
99
102 {
104 const Eigen::MatrixXd & _gradient,
105 // Added AC - symmetric gradient
106 const Eigen::MatrixXd & _symmetric_gradient,
107 const Eigen::MatrixXd & _potential,
108 // added AC - potential from symmetrix gradient definition
109 const Eigen::MatrixXd & _potential_sym,
110 const Eigen::MatrixXd & _stabilisation,
111 // added AC to remove diff operator
112 const Eigen::MatrixXd & _difference
113 )
114 : gradient(_gradient),
115 symmetric_gradient(_symmetric_gradient), // added AC
116 potential(_potential),
117 potential_sym(_potential_sym), // added AC
118 stabilisation(_stabilisation),
119 difference(_difference) //AC remove
120 {
121 // Do nothing
122 }
123
124 Eigen::MatrixXd gradient;
125 Eigen::MatrixXd symmetric_gradient; //added AC
126 Eigen::MatrixXd potential;
127 Eigen::MatrixXd potential_sym; // added AC
128 Eigen::MatrixXd stabilisation;
129 Eigen::MatrixXd difference; // AC remove
130 };
131
133 VHHOSpace(const Mesh & mesh, size_t K, const CellSelection & BoundaryStab, bool use_threads = true, std::ostream & output = std::cout);
134
136 VHHOSpace(const Mesh & mesh, size_t K, bool use_threads = true, std::ostream & output = std::cout)
137 : VHHOSpace(mesh, K, allcells, use_threads, output) {};
138
140 const Mesh & mesh() const
141 {
142 return m_mesh;
143 }
144
146 const size_t & degree() const
147 {
148 return m_K;
149 }
150
153 {
154 return m_boundary_stab;
155 }
156
158 Eigen::VectorXd interpolate(
159 const FunctionType & q,
160 const int doe_cell = -1,
161 const int doe_face = -1
162 ) const;
163
164 // AC
166 Eigen::VectorXd local_interpolate(
167 size_t iT,
168 const FunctionType & q,
169 const int doe_cell = -1,
170 const int doe_face = -1
171 ) const;
172
173 // AC
175 Eigen::VectorXd components(
176 size_t iT,
177 const FunctionType & q,
178 const int doe = -1
179 ) const;
180
181 // AC
183 Eigen::VectorXd components(
184 size_t iT,
185 const GradientType & q,
186 const int doe = -1
187 ) const;
188
190 inline const CellBases & cellBases(size_t iT) const
191 {
192 // Make sure that the basis has been created
193 assert( m_cell_bases[iT] );
194 return *m_cell_bases[iT].get();
195 }
196
198 inline const CellBases & cellBases(const Cell & T) const
199 {
200 return cellBases(T.global_index());
201 }
202
204 inline const EdgeBases & edgeBases(size_t iE) const
205 {
206 // Make sure that the basis has been created
207 assert( m_edge_bases[iE] );
208 return *m_edge_bases[iE].get();
209 }
210
212 inline const EdgeBases & edgeBases(const Edge & E) const
213 {
214 return edgeBases(E.global_index());
215 }
216
218 inline const LocalOperators & operators(size_t iT) const
219 {
220 assert( m_operators[iT] );
221 return *m_operators[iT];
222 }
223
225 inline const LocalOperators & operators(const Cell & T) const
226 {
227 return operators(T.global_index());
228 }
229
231 std::vector<std::pair<double,double>> computeNorms(
232 const std::vector<Eigen::VectorXd> & list_dofs
233 ) const;
234
237 std::vector<Eigen::VectorXd> computeVertexValues(
238 const Eigen::VectorXd & u
239 ) const;
240
241 private:
243 CellBases _construct_cell_bases(size_t iT);
244
246 EdgeBases _construct_edge_bases(size_t iE);
247
249 LocalOperators _compute_operators(size_t iT);
250
251 // Pointer to the mesh
252 const Mesh & m_mesh;
253 // Degrees
254 const size_t m_K;
255 // Choice of boundary stabilisation
256 CellSelection m_boundary_stab;
257 // Parallel or not
258 bool m_use_threads;
259 // Output stream
260 std::ostream & m_output;
261
262 // Cell bases
263 std::vector<std::unique_ptr<CellBases> > m_cell_bases;
264 // Edge bases
265 std::vector<std::unique_ptr<EdgeBases> > m_edge_bases;
266
267 // Local operators
268 std::vector<std::unique_ptr<LocalOperators> > m_operators;
269
270 };
271
272
273} // end of namespace HArDCore2D
274
275#endif // VHHOSPACE_HPP
Definition basis.hpp:311
Base class for global DOF spaces. Provides functions to manipulate global DOFs (the local version bei...
Definition globaldofspace.hpp:16
Matrix family obtained from a scalar family.
Definition basis.hpp:719
Vector family obtained by tensorization of a scalar family.
Definition basis.hpp:559
Class definition: polynomial bases and operators.
Definition vhhospace.hpp:52
Definition Mesh2D.hpp:26
Eigen::Vector2d VectorRd
Definition basis.hpp:55
Eigen::Matrix2d MatrixRd
Definition basis.hpp:54
MatrixFamily< PolyBasisCellType, dimspace > PolydxdBasisCellType
Definition vhhospace.hpp:57
std::unique_ptr< PolydBasisCellType > Polykpod
Definition vhhospace.hpp:82
std::unique_ptr< PolyBasisCellType > Polyk
Definition vhhospace.hpp:81
const LocalOperators & operators(size_t iT) const
Return operators for the cell of index iT.
Definition vhhospace.hpp:218
std::unique_ptr< PolydBasisEdgeType > Polykd
Definition vhhospace.hpp:97
Family< PolydxdBasisCellType > PolySymdxdBasisCellType
Definition vhhospace.hpp:59
const CellBases & cellBases(const Cell &T) const
Return cell bases for cell T.
Definition vhhospace.hpp:198
std::function< VectorRd(const VectorRd &)> FunctionType
Definition vhhospace.hpp:66
Eigen::VectorXd interpolate(const FunctionType &q, const int doe_cell=-1, const int doe_face=-1) const
Interpolator of a continuous function.
Definition vhhospace.cpp:163
std::vector< Eigen::VectorXd > computeVertexValues(const Eigen::VectorXd &u) const
Definition vhhospace.cpp:557
Edge GeometricSupport
Geometric support.
Definition vhhospace.hpp:94
TensorizedVectorFamily< PolyBasisCellType, dimspace > PolydBasisCellType
Definition vhhospace.hpp:56
Eigen::MatrixXd stabilisation
Definition vhhospace.hpp:128
static const CellSelection allcells
Definition vhhospace.hpp:48
Eigen::MatrixXd gradient
Definition vhhospace.hpp:124
std::unique_ptr< PolydxdBasisCellType > Polykdxd
Definition vhhospace.hpp:84
std::unique_ptr< PolyBasisEdgeType > Polyk
Definition vhhospace.hpp:96
std::unique_ptr< PolySymdxdBasisCellType > PolySymkdxd
Definition vhhospace.hpp:86
Eigen::VectorXd components(size_t iT, const FunctionType &q, const int doe=-1) const
Discrete components of continuous function in [P^k(T)]^d TODO more general function,...
Definition vhhospace.cpp:224
Eigen::MatrixXd symmetric_gradient
Definition vhhospace.hpp:125
std::unique_ptr< PolyBasisCellType > Polykpo
Definition vhhospace.hpp:80
Eigen::VectorXd local_interpolate(size_t iT, const FunctionType &q, const int doe_cell=-1, const int doe_face=-1) const
Local Interpolator of a continuous function on the element iT.
Definition vhhospace.cpp:203
const CellBases & cellBases(size_t iT) const
Return cell bases for element iT.
Definition vhhospace.hpp:190
VHHOSpace(const Mesh &mesh, size_t K, bool use_threads=true, std::ostream &output=std::cout)
Overloaded constructor when the selection of boundary stabilisation is not entered (all boundary face...
Definition vhhospace.hpp:136
LocalOperators(const Eigen::MatrixXd &_gradient, const Eigen::MatrixXd &_symmetric_gradient, const Eigen::MatrixXd &_potential, const Eigen::MatrixXd &_potential_sym, const Eigen::MatrixXd &_stabilisation, const Eigen::MatrixXd &_difference)
Definition vhhospace.hpp:103
Cell GeometricSupport
Geometric support.
Definition vhhospace.hpp:78
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 vhhospace.cpp:475
const size_t & degree() const
Return the polynomial degree (common face and elements)
Definition vhhospace.hpp:146
const EdgeBases & edgeBases(const Edge &E) const
Return cell bases for edge E.
Definition vhhospace.hpp:212
const LocalOperators & operators(const Cell &T) const
Return cell operators for cell T.
Definition vhhospace.hpp:225
Eigen::MatrixXd potential
Definition vhhospace.hpp:126
Family< TensorizedVectorFamily< PolyBasisEdgeType, dimspace > > PolydBasisEdgeType
Definition vhhospace.hpp:63
Family< MonomialScalarBasisEdge > PolyBasisEdgeType
Definition vhhospace.hpp:62
const Mesh & mesh() const
Return a const reference to the mesh.
Definition vhhospace.hpp:140
Eigen::MatrixXd potential_sym
Definition vhhospace.hpp:127
Eigen::MatrixXd difference
Definition vhhospace.hpp:129
Family< MonomialScalarBasisCell > PolyBasisCellType
Definition vhhospace.hpp:55
std::function< MatrixRd(const VectorRd &)> GradientType
Definition vhhospace.hpp:68
std::unique_ptr< PolydBasisCellType > Polykd
Definition vhhospace.hpp:83
const EdgeBases & edgeBases(size_t iE) const
Return edge bases for edge iE.
Definition vhhospace.hpp:204
std::function< bool(const Cell &)> CellSelection
Definition vhhospace.hpp:47
const CellSelection & boundaryStab() const
Return the function to select the cells with boundary stabilisation.
Definition vhhospace.hpp:152
bool use_threads
Definition HHO_DiffAdvecReac.hpp:47
size_t K
Definition HHO_DiffAdvecReac.hpp:46
if(strcmp(field, 'real')) % real valued entries T
Definition mmread.m:93
Definition ddr-klplate.hpp:27
static auto q
Definition ddrcore-test.hpp:14
Structure to store element bases.
Definition vhhospace.hpp:76
Structure to store edge bases.
Definition vhhospace.hpp:92
A structure to store local operators (gradient, potential, stabilisation)
Definition vhhospace.hpp:102