HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge and cell polynomials as unknowns
Loading...
Searching...
No Matches
xhess_full.hpp
Go to the documentation of this file.
1#ifndef XHESS_HPP
2#define XHESS_HPP
3
4#include <globaldofspace.hpp>
5#include <ddrcore.hpp>
6#include <integralweight.hpp>
8#include "xgrad.hpp"
9#include "sxgrad.hpp"
10#include "vsxgrad.hpp"
11
12namespace HArDCore2D
13{
20 class XHess : public GlobalDOFSpace
21 {
22 public:
23 typedef std::function<double(const Eigen::Vector2d &)> FunctionType;
24 typedef std::function<Eigen::Vector2d(const Eigen::Vector2d &)> GradFunctionType;
25
26
28 struct LocalOperators
29 {
31 const Eigen::MatrixXd & _gradient,
32 const Eigen::MatrixXd & _potential
33 )
36 {
37 // Do nothing
38 }
39
40 Eigen::MatrixXd gradient;
41 Eigen::MatrixXd potential;
42 };
43 struct TransferOperators
44 {
46 const Eigen::MatrixXd & _serendipity,
47 const Eigen::MatrixXd & _extension
48 )
51 {
52 // Do nothing
53 }
54
55 Eigen::MatrixXd serendipity;
56 Eigen::MatrixXd extension;
57 };
58 Eigen::MatrixXd SerExtension(size_t iT) const;
60 XHess(const DDRCore & ddr_core, const SerendipityProblem & ser_pro, bool use_threads = true, std::ostream & output = std::cout);//ajout senredipity ser_pro
61
63 const Mesh & mesh() const
64 {
65 return m_ddr_core.mesh();
66 }
67
69 const size_t & degree() const
70 {
71 return m_ddr_core.degree();
72 }
73
75 Eigen::VectorXd interpolate(
76 const FunctionType & q,
77 const GradFunctionType & Dq,
78 const int deg_quad = -1
79 ) const;
80
81 //---------------------------------//
82 //---- Cell transfer operators -----//
84 inline const Eigen::MatrixXd & SgradCell(size_t iT) const
85 {
86 return (*m_cell_transfer_operators[iT]).serendipity;
87 }
88
90 inline const Eigen::MatrixXd & SgradCell(const Cell & T) const
91 {
92 return SgradCell(T.global_index());
93 }
94
95 inline const Eigen::MatrixXd & EgradCell(size_t iT) const
96 {
97 return (*m_cell_transfer_operators[iT]).extension;
98 }
99
101 inline const Eigen::MatrixXd & EgradCell(const Cell & T) const
102 {
103 return EgradCell(T.global_index());
104 }
105
107 inline const TransferOperators & TcellOperators(size_t iT) const
108 {
109 return *m_cell_transfer_operators[iT];
110 }
111
113 inline const TransferOperators & TcellOperators(const Cell & T) const
114 {
115 return *m_cell_transfer_operators[T.global_index()];
116 }
117
119 inline const LocalOperators & edgeOperators(size_t iE) const
120 {
121 return *m_edge_operators[iE];
122 }
123
125 inline const LocalOperators & edgeOperators(const Edge & E) const
126 {
127 return *m_edge_operators[E.global_index()];
128 }
129
131 inline const LocalOperators & cellOperators(size_t iT) const
132 {
133 return *m_cell_operators[iT];
134 }
135
137 inline const LocalOperators & cellOperators(const Cell & T) const
138 {
139 return *m_cell_operators[T.global_index()];
140 }
141
143 inline const DDRCore::CellBases & cellBases(size_t iT) const
144 {
145 return m_ddr_core.cellBases(iT);
146 }
147
149 inline const DDRCore::CellBases & cellBases(const Cell & T) const
150 {
151 return m_ddr_core.cellBases(T.global_index());
152 }
153
155 inline const DDRCore::EdgeBases & edgeBases(size_t iE) const
156 {
157 return m_ddr_core.edgeBases(iE);
158 }
159
161 inline const DDRCore::EdgeBases & edgeBases(const Edge & E) const
162 {
163 return m_ddr_core.edgeBases(E.global_index());
164 }
165
167 // The mass matrix of P^{k+1}(T) is the most expensive mass matrix in the calculation of this norm, which
168 // is why there's the option of passing it as parameter if it's been already pre-computed when the norm is called.
169
170 Eigen::MatrixXd computeStabilisation(
171 const size_t iT,
172 const double & penalty_factor = 1.,
173 const Eigen::MatrixXd & mass_Pkpo_T = Eigen::MatrixXd::Zero(1,1),
175 ) const;
176
177 Eigen::MatrixXd computeL2Product(
178 const size_t iT,
179 const double & penalty_factor = 1.,
180 const Eigen::MatrixXd & mass_Pkpo_T = Eigen::MatrixXd::Zero(1,1),
182 ) const;
183
184
185
186 Eigen::MatrixXd computeGradientFull(
187 const size_t iT,
188 const VSXGrad & vsx_grad
189 ) const;
190
191 Eigen::MatrixXd potential2(
192 const size_t iT,
193 const VSXGrad & vsx_grad
194 ) const;
195
198 const size_t iT,
199 const Eigen::VectorXd & vT,
200 const VectorRd & x
201 ) const;
202
204 double computeL2Norm(const Eigen::VectorXd & v) const;
205
206 private:
207 Eigen::MatrixXd _compute_cell_serendipity_operator(size_t iT);
208 Eigen::MatrixXd _compute_cell_extension_operator(size_t iT) const;
209
210 LocalOperators _compute_edge_gradient_potential(size_t iE);
211 LocalOperators _compute_cell_gradient_potential(size_t iT);
212 double _compute_squared_l2_norm(size_t iT, const Eigen::VectorXd & vT) const;
213
214 const DDRCore & m_ddr_core;
215 const SerendipityProblem & m_ser_pro;
216 const SXGrad m_sxgrad;
217
218 bool m_use_threads;
219 std::ostream & m_output;
220
221 // Containers for local operators
222 std::vector<std::unique_ptr<LocalOperators> > m_edge_operators;
223 std::vector<std::unique_ptr<LocalOperators> > m_cell_operators;
224
225 // Containers for serendipity
226 std::vector<std::shared_ptr<TransferOperators> > m_cell_transfer_operators;
227 };
228
229} // end of namespace HArDCore2D
230
231#endif
Construct all polynomial spaces for the DDR sequence.
Definition ddrcore.hpp:63
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:20
Vector version of sXgrad, the arbitrary order space with nodal primal unknowns.
Definition vsxgrad.hpp:32
const LocalOperators & cellOperators(size_t iT) const
Return cell operators for the cell of index iT.
Definition xhess_full.hpp:131
const TransferOperators & TcellOperators(const Cell &T) const
Return cell operators for cell T.
Definition xhess_full.hpp:113
const size_t & degree() const
Return the polynomial degree.
Definition xhess_full.hpp:69
double evaluatePotential(const size_t iT, const Eigen::VectorXd &vT, const VectorRd &x) const
Evaluate the value of the potential at a point x.
const DDRCore::EdgeBases & edgeBases(const Edge &E) const
Return edge bases for edge E.
Definition xhess_full.hpp:161
Eigen::VectorXd interpolate(const FunctionType &q, const GradFunctionType &Dq, const int deg_quad=-1) const
Interpolator of a continuous function.
Eigen::MatrixXd computeStabilisation(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.
const Eigen::MatrixXd & SgradCell(const Cell &T) const
Return the serendipity reconstruction for cell T.
Definition xhess_full.hpp:90
const LocalOperators & edgeOperators(const Edge &E) const
Return edge operators for edge E.
Definition xhess_full.hpp:125
const DDRCore::EdgeBases & edgeBases(size_t iE) const
Return edge bases for the edge of index iE.
Definition xhess_full.hpp:155
const DDRCore::CellBases & cellBases(const Cell &T) const
Return cell bases for cell T.
Definition xhess_full.hpp:149
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
Eigen::MatrixXd computeGradientFull(const size_t iT, const VSXGrad &vsx_grad) const
const Eigen::MatrixXd & SgradCell(size_t iT) const
Return the serendipity reconstruction for the cell of index iT.
Definition xhess_full.hpp:84
const DDRCore::CellBases & cellBases(size_t iT) const
Return cell bases for the cell of index iT.
Definition xhess_full.hpp:143
const LocalOperators & cellOperators(const Cell &T) const
Return cell operators for cell T.
Definition xhess_full.hpp:137
const TransferOperators & TcellOperators(size_t iT) const
Return cell operators for the cell of index iT.
Definition xhess_full.hpp:107
const Mesh & mesh() const
Return the mesh.
Definition xhess_full.hpp:63
const LocalOperators & edgeOperators(size_t iE) const
Return edge operators for the edge of index iE.
Definition xhess_full.hpp:119
double computeL2Norm(const Eigen::VectorXd &v) const
Compute the L2-norm of a vector of the space.
XHess(const DDRCore &ddr_core, const SerendipityProblem &ser_pro, bool use_threads=true, std::ostream &output=std::cout)
Constructor.
Definition Mesh2D.hpp:26
Create grid points x
Definition generate_cartesian_mesh.m:22
Eigen::Vector2d VectorRd
Definition basis.hpp:55
const Mesh & mesh() const
Return a const reference to the mesh.
Definition ddrcore.hpp:116
std::function< Eigen::Vector2d(const Eigen::Vector2d &)> GradFunctionType
Definition xhess_full.hpp:24
const size_t & degree() const
Return the polynomial degree.
Definition ddrcore.hpp:122
TransferOperators(const Eigen::MatrixXd &_serendipity, const Eigen::MatrixXd &_extension)
Definition xhess_full.hpp:45
Eigen::MatrixXd potential
Definition xhess.hpp:41
Eigen::MatrixXd gradient
Definition xhess.hpp:40
const CellBases & cellBases(size_t iT) const
Return cell bases for element iT.
Definition ddrcore.hpp:128
const Eigen::MatrixXd & EgradCell(size_t iT) const
Definition xhess_full.hpp:95
const Eigen::MatrixXd & SgradCell(size_t iT) const
Return the serendipity reconstruction for the cell of index iT.
Definition xhess.hpp:80
Eigen::MatrixXd SerExtension(size_t iT) const
Definition xhess_full.cpp:271
Eigen::MatrixXd extension
Definition xhess_full.hpp:56
Eigen::MatrixXd potential2(const size_t iT, const VSXGrad &vsx_grad) const
Definition xhess_full.cpp:659
std::function< double(const Eigen::Vector2d &)> FunctionType
Definition xhess_full.hpp:23
const EdgeBases & edgeBases(size_t iE) const
Return edge bases for edge iE.
Definition ddrcore.hpp:136
Eigen::MatrixXd serendipity
Definition xhess.hpp:53
const Eigen::MatrixXd & EgradCell(const Cell &T) const
Return the serendipity reconstruction for cell T.
Definition xhess_full.hpp:101
bool use_threads
Definition HHO_DiffAdvecReac.hpp:45
depending on the Matrix Market format indicated by or array(dense array storage). The data will be duplicated % as appropriate if symmetry is indicated in the header. % % Optionally
if(strcmp(field, 'real')) % real valued entries T
Definition mmread.m:93
Definition mhd-solutions.hpp:9
static auto v
Definition ddrcore-test.hpp:32
static auto q
Definition ddrcore-test.hpp:14
Structure to store element bases.
Definition ddrcore.hpp:81
Structure to store edge bases.
Definition ddrcore.hpp:103
Structure for weights (scalar, at the moment) in integral.
Definition integralweight.hpp:33
A structure to store local operators (gradient and potential)
Definition xhess.hpp:29
LocalOperators(const Eigen::MatrixXd &_gradient, const Eigen::MatrixXd &_potential)
Definition xhess_full.hpp:30