HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge and cell polynomials as unknowns
Loading...
Searching...
No Matches
sxgrad.hpp
Go to the documentation of this file.
1#ifndef SXGRAD_HPP
2#define SXGRAD_HPP
3
5#include <ddrcore.hpp>
6#include <integralweight.hpp>
7#include <xgrad.hpp>
9
10namespace HArDCore2D
11{
18
19 class SXGrad : public VariableDOFSpace
20 {
21 public:
22 typedef std::function<double(const Eigen::Vector2d &)> FunctionType;
23
25
27 {
29 const Eigen::MatrixXd & _serendipity,
30 const Eigen::MatrixXd & _extension,
31 const Eigen::MatrixXd & _reduction
32 )
33 : serendipity(_serendipity),
34 extension(_extension),
35 reduction(_reduction)
36 {
37 // Do nothing
38 }
39
40 Eigen::MatrixXd serendipity;
41 Eigen::MatrixXd extension;
42 Eigen::MatrixXd reduction;
43 };
44
46 SXGrad(const DDRCore & ddr_core, const SerendipityProblem & ser_pro, bool use_threads = true, std::ostream & output = std::cout);
47
49 const Mesh & mesh() const
50 {
51 return m_ddr_core.mesh();
52 }
53
55 const size_t & degree() const
56 {
57 return m_ddr_core.degree();
58 }
59
61 Eigen::VectorXd interpolate(
62 const FunctionType & q,
63 const int deg_quad = -1
64 ) const;
65
66 //---------------------------------//
67
68 //---------------------------------//
69 //---- Cell transfer operators -----//
71 inline const Eigen::MatrixXd & SgradCell(size_t iT) const
72 {
73 return (*m_cell_transfer_operators[iT]).serendipity;
74 }
75
77 inline const Eigen::MatrixXd & EgradCell(size_t iT) const
78 {
79 return (*m_cell_transfer_operators[iT]).extension;
80 }
81
83 inline const Eigen::MatrixXd & RgradCell(size_t iT) const
84 {
85 return (*m_cell_transfer_operators[iT]).reduction;
86 }
87
89 inline const Eigen::MatrixXd & SgradCell(const Cell & T) const
90 {
91 return SgradCell(T.global_index());
92 }
93
95 inline const Eigen::MatrixXd & EgradCell(const Cell & T) const
96 {
97 return EgradCell(T.global_index());
98 }
99
101 inline const Eigen::MatrixXd & RgradCell(const Cell & T) const
102 {
103 return RgradCell(T.global_index());
104 }
106 inline const TransferOperators & cellOperators(size_t iT) const
107 {
108 return *m_cell_transfer_operators[iT];
109 }
110
112 inline const TransferOperators & cellOperators(const Cell & T) const
113 {
114 return *m_cell_transfer_operators[T.global_index()];
115 }
116
117
118 //---------------------------------------------------------------------//
119 //---- Full gradient and potential reconstructions, and L2 product ----//
120
122 inline const Eigen::MatrixXd edgeGradient(size_t iE) const
123 {
124 return m_xgrad.edgeOperators(iE).gradient;
125 }
126
128 inline const Eigen::MatrixXd edgeGradient(const Edge & E) const
129 {
130 return edgeGradient(E.global_index());
131 }
132
134 inline const Eigen::MatrixXd edgePotential(size_t iE) const
135 {
136 return m_xgrad.edgeOperators(iE).potential;
137 }
138
140 inline const Eigen::MatrixXd edgePotential(const Edge & E) const
141 {
142 return edgePotential(E.global_index());
143 }
144
146 inline const Eigen::MatrixXd cellGradient(size_t iT) const
147 {
148 return m_xgrad.cellOperators(iT).gradient * EgradCell(iT);
149 }
150
152 inline const Eigen::MatrixXd cellGradient(const Cell & T) const
153 {
154 return cellGradient(T.global_index());
155 }
156
158 inline const Eigen::MatrixXd cellPotential(size_t iT) const
159 {
160 return m_xgrad.cellOperators(iT).potential * EgradCell(iT);
161 }
162
164 inline const Eigen::MatrixXd cellPotential(const Cell & T) const
165 {
166 return cellPotential(T.global_index());
167 }
168
170 Eigen::MatrixXd computeL2Product(
171 const size_t iT,
172 const double & penalty_factor = 1.,
173 const Eigen::MatrixXd & mass_Pk2_T = Eigen::MatrixXd::Zero(1,1),
174 const IntegralWeight & weight = IntegralWeight(1.)
175 ) const
176 {
177 return EgradCell(iT).transpose()
178 * m_xgrad.computeL2Product(iT, penalty_factor, mass_Pk2_T, weight)
179 *EgradCell(iT);
180 }
181
183 double computeL2Norm(const Eigen::VectorXd & v) const;
184
186 Eigen::MatrixXd computeStabilisation(
187 const size_t iT,
188 const IntegralWeight & weight = IntegralWeight(1.)
189 ) const
190 {
191 return EgradCell(iT).transpose()
192 * m_xgrad.computeStabilisation(iT, weight)
193 * EgradCell(iT);
194 }
195
196
198 std::vector<double> computeVertexValues(
199 const Eigen::VectorXd & u
200 ) const;
201
202
203
204 //-----------------------//
205 //---- Getters ----------//
206
208 inline const DDRCore::CellBases & cellBases (size_t iT) const
209 {
210 return m_ddr_core.cellBases(iT);
211 }
212
214 inline const DDRCore::CellBases & cellBases (const Cell & T) const
215 {
216 return m_ddr_core.cellBases(T.global_index());
217 }
218
219
221 inline const DDRCore::EdgeBases & edgeBases(size_t iE) const
222 {
223 return m_ddr_core.edgeBases(iE);
224 }
225
227 inline const DDRCore::EdgeBases & edgeBases(const Edge & E) const
228 {
229 return m_ddr_core.edgeBases(E.global_index());
230 }
231
232 private:
233 TransferOperators _compute_cell_transfer_operators(size_t iT);
234 double _compute_squared_l2_norm(size_t iT, const Eigen::VectorXd & vT) const;
235 const DDRCore & m_ddr_core;
236 const SerendipityProblem & m_ser_pro;
237 const XGrad m_xgrad;
238
239 // Containers for serendipity, extension and reduction operators
240 std::vector<std::shared_ptr<TransferOperators> > m_cell_transfer_operators;
241
242 bool m_use_threads;
243 std::ostream & m_output;
244
245 };
246
247} // end of namespace HArDCore2D
248#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
Base class for global DOF spaces.
Definition variabledofspace.hpp:17
Discrete H1 space: local operators, L2 product and global interpolator.
Definition xgrad.hpp:17
Definition Mesh2D.hpp:26
Eigen::MatrixXd serendipity
Definition sxgrad.hpp:40
const size_t & degree() const
Return the polynomial degree.
Definition sxgrad.hpp:55
const Mesh & mesh() const
Return the mesh.
Definition sxgrad.hpp:49
const Mesh & mesh() const
Return a const reference to the mesh.
Definition ddrcore.hpp:116
const Eigen::MatrixXd & EgradCell(const Cell &T) const
Return the extension for cell T.
Definition sxgrad.hpp:95
const size_t & degree() const
Return the polynomial degree.
Definition ddrcore.hpp:122
Eigen::MatrixXd potential
Definition xgrad.hpp:35
const TransferOperators & cellOperators(const Cell &T) const
Return cell operators for cell T.
Definition sxgrad.hpp:112
const TransferOperators & cellOperators(size_t iT) const
Return cell operators for the cell of index iT.
Definition sxgrad.hpp:106
const DDRCore::CellBases & cellBases(const Cell &T) const
Return cell bases for cell T.
Definition sxgrad.hpp:214
const Eigen::MatrixXd & SgradCell(const Cell &T) const
Return the serendipity reconstruction for cell T.
Definition sxgrad.hpp:89
std::function< double(const Eigen::Vector2d &)> FunctionType
Definition sxgrad.hpp:22
Eigen::MatrixXd extension
Definition sxgrad.hpp:41
const Eigen::MatrixXd & EgradCell(size_t iT) const
Return the extension for the cell of index iT.
Definition sxgrad.hpp:77
const DDRCore::EdgeBases & edgeBases(const Edge &E) const
Return edge bases for edge E.
Definition sxgrad.hpp:227
TransferOperators(const Eigen::MatrixXd &_serendipity, const Eigen::MatrixXd &_extension, const Eigen::MatrixXd &_reduction)
Definition sxgrad.hpp:28
const CellBases & cellBases(size_t iT) const
Return cell bases for element iT.
Definition ddrcore.hpp:128
const LocalOperators & cellOperators(size_t iT) const
Return cell operators for the cell of index iT.
Definition xgrad.hpp:72
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
Compute the matrix of the (weighted) L2-product for the cell of index iT.
Definition xgrad.cpp:273
const Eigen::MatrixXd cellGradient(const Cell &T) const
Return the full gradient operator on cell T.
Definition sxgrad.hpp:152
const Eigen::MatrixXd cellPotential(const Cell &T) const
Return the potential operator on cell T.
Definition sxgrad.hpp:164
const Eigen::MatrixXd edgePotential(size_t iE) const
Return the potential operator on the edge of index iE.
Definition sxgrad.hpp:134
Eigen::VectorXd interpolate(const FunctionType &q, const int deg_quad=-1) const
Definition sxgrad.cpp:50
const DDRCore::CellBases & cellBases(size_t iT) const
Return cell bases for the cell of index iT.
Definition sxgrad.hpp:208
const LocalOperators & edgeOperators(size_t iE) const
Return edge operators for the edge of index iE.
Definition xgrad.hpp:60
Eigen::MatrixXd computeL2Product(const size_t iT, const double &penalty_factor=1., const Eigen::MatrixXd &mass_Pk2_T=Eigen::MatrixXd::Zero(1, 1), const IntegralWeight &weight=IntegralWeight(1.)) const
Compute the matrix of the (weighted) L2-product.
Definition sxgrad.hpp:170
Eigen::MatrixXd computeStabilisation(const size_t iT, const IntegralWeight &weight=IntegralWeight(1.)) const
Computes only the stabilisation matrix of the (weighted) L2-product for the cell of index iT....
Definition xgrad.cpp:350
const Eigen::MatrixXd & SgradCell(size_t iT) const
Return the serendipity reconstruction for the cell of index iT.
Definition sxgrad.hpp:71
const Eigen::MatrixXd & RgradCell(size_t iT) const
Return the reduction for the cell of index iT.
Definition sxgrad.hpp:83
Eigen::MatrixXd gradient
Definition xgrad.hpp:34
Eigen::MatrixXd computeStabilisation(const size_t iT, const IntegralWeight &weight=IntegralWeight(1.)) const
Computes only the stabilisation matrix of the (weighted) L2-product for the cell of index iT.
Definition sxgrad.hpp:186
const Eigen::MatrixXd cellGradient(size_t iT) const
Return the full gradient operator on the cell of index iT.
Definition sxgrad.hpp:146
const EdgeBases & edgeBases(size_t iE) const
Return edge bases for edge iE.
Definition ddrcore.hpp:136
const Eigen::MatrixXd & RgradCell(const Cell &T) const
Return the reduction for cell T.
Definition sxgrad.hpp:101
const DDRCore::EdgeBases & edgeBases(size_t iE) const
Return edge bases for the edge of index iE.
Definition sxgrad.hpp:221
const Eigen::MatrixXd cellPotential(size_t iT) const
Return the potential operator on the cell of index iT.
Definition sxgrad.hpp:158
std::vector< double > computeVertexValues(const Eigen::VectorXd &u) const
Computes the values of the potential reconstruction at the mesh vertices.
const Eigen::MatrixXd edgeGradient(const Edge &E) const
Return the full gradient operator on edge E.
Definition sxgrad.hpp:128
Eigen::MatrixXd reduction
Definition sxgrad.hpp:42
double computeL2Norm(const Eigen::VectorXd &v) const
Compute the L2-norm of a vector of the space.
Definition sxgrad.cpp:205
const Eigen::MatrixXd edgeGradient(size_t iE) const
Return the full gradient operator on the edge of index iE.
Definition sxgrad.hpp:122
const Eigen::MatrixXd edgePotential(const Edge &E) const
Return the potential operator on edge E.
Definition sxgrad.hpp:140
bool use_threads
Definition HHO_DiffAdvecReac.hpp:47
if(strcmp(field, 'real')) % real valued entries T
Definition mmread.m:93
Definition ddr-klplate.hpp:27
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 the serendipity, extension and reduction operators.
Definition sxgrad.hpp:27